fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace NotEndsInZero
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. //Mr. Keller
  13. String str_users_name; //Hold onto the user's name
  14.  
  15. int int_i = 0; //loop counter
  16. int int_max = 0; //Maximum integer entered by user
  17. int int_min = 0; //Minimum integer entered by user
  18. int int_increment = 0; //Increase or Decrease based on odd or even by this amount
  19.  
  20. bool bool_true; //Logical operator
  21.  
  22. // Ask for User's Name
  23. Console.WriteLine("Please enter your name");
  24. // Read Users Name
  25. str_users_name = Console.ReadLine();
  26.  
  27. // Process the Maximum Number
  28. bool_true = true;
  29. while (bool_true)
  30. {
  31. Console.WriteLine("\nPlease enter your Maximum number as an integer:");
  32.  
  33. try
  34. {
  35. int_max = Convert.ToInt32(Console.ReadLine());
  36. if (int_max <= 0)
  37. {
  38. Console.WriteLine("Only positive numbers are valid.");
  39. bool_true = true;
  40. }
  41. else
  42. {
  43. bool_true = false;
  44. }
  45. }
  46. catch (Exception ex)
  47. {
  48. Console.WriteLine(ex.Message);
  49. Console.WriteLine("You did not enter an INTEGER.");
  50. bool_true = true;
  51.  
  52. }
  53. }
  54.  
  55. // Process the Minimum Number
  56. bool_true = true;
  57. while (bool_true)
  58. {
  59. Console.WriteLine("\nPlease enter your Minimum number as an integer:");
  60.  
  61. try
  62. {
  63. int_min = Convert.ToInt32(Console.ReadLine());
  64. if (int_min >= int_max)
  65. {
  66. Console.WriteLine("Your minimum number needs to be LESS Than Your Maximum of: " + int_max);
  67. bool_true = true;
  68. }
  69. else
  70. {
  71. bool_true = false;
  72. }
  73. }
  74. catch (Exception ex)
  75. {
  76. Console.WriteLine(ex.Message);
  77. Console.WriteLine("Please enter an integer.");
  78. bool_true = true;
  79.  
  80. }
  81. }
  82.  
  83. // Determine if Maximum is even or odd
  84. int_increment = 3;
  85. if (IsEven(int_max))
  86. {
  87. int_increment = 2;
  88. }
  89.  
  90.  
  91. // Write out the decreasing amount from int_max to int_min
  92.  
  93. Console.WriteLine(str_users_name + ", here are your numbers in decreasing order from : " + int_max + " to " + int_min);
  94. for (int_i = int_max; int_i >= int_min; int_i = int_i - int_increment)
  95. {
  96. if (!EndsInZero(int_i))
  97. {
  98. Console.WriteLine("int_i= " + int_i);
  99. }
  100. }
  101.  
  102. // Determine if Minimum is even or odd
  103. int_increment = 3;
  104. if (IsEven(int_min))
  105. {
  106. int_increment = 2;
  107. }
  108.  
  109. // Write out the decreasing amount from int_min to int_max
  110. Console.WriteLine(str_users_name + ", here are your numbers in increasing order from : " + int_min + " to " + int_max);
  111.  
  112. for (int_i = int_min; int_i <= int_max; int_i = int_i + int_increment)
  113. {
  114. if (!EndsInZero(int_i))
  115. {
  116. Console.WriteLine("int_i= " + int_i);
  117. }
  118. }
  119.  
  120. Console.ReadLine();
  121. }
  122.  
  123. // Method to determine if the integer being passed in is positive
  124. public static bool IsEven(int value)
  125. {
  126. return value % 2 == 0;
  127. }
  128.  
  129. // Method to determine if the integer being passed ends in 0
  130. public static bool EndsInZero(int value2)
  131. {
  132. return value2 % 10 == 0;
  133. }
  134.  
  135. }
  136. }
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:7: error: expected nested-name-specifier before ‘System’
prog.cpp:1:7: error: ‘System’ has not been declared
prog.cpp:2:7: error: expected nested-name-specifier before ‘System’
prog.cpp:2:7: error: ‘System’ has not been declared
prog.cpp:2:13: error: expected ‘;’ before ‘.’ token
prog.cpp:2:13: error: expected unqualified-id before ‘.’ token
prog.cpp:3:7: error: expected nested-name-specifier before ‘System’
prog.cpp:3:7: error: ‘System’ has not been declared
prog.cpp:3:13: error: expected ‘;’ before ‘.’ token
prog.cpp:3:13: error: expected unqualified-id before ‘.’ token
prog.cpp:4:7: error: expected nested-name-specifier before ‘System’
prog.cpp:4:7: error: ‘System’ has not been declared
prog.cpp:4:13: error: expected ‘;’ before ‘.’ token
prog.cpp:4:13: error: expected unqualified-id before ‘.’ token
prog.cpp:10:26: error: ‘string’ has not been declared
prog.cpp:10:35: error: expected ‘,’ or ‘...’ before ‘args’
prog.cpp:124:16: error: expected ‘:’ before ‘static’
prog.cpp:130:16: error: expected ‘:’ before ‘static’
prog.cpp:135:5: error: expected ‘;’ after class definition
prog.cpp: In static member function ‘static void NotEndsInZero::Program::Main(int*)’:
prog.cpp:13:13: error: ‘String’ was not declared in this scope
prog.cpp:13:20: error: expected ‘;’ before ‘str_users_name’
prog.cpp:23:13: error: ‘Console’ was not declared in this scope
prog.cpp:25:13: error: ‘str_users_name’ was not declared in this scope
prog.cpp:35:31: error: ‘Convert’ was not declared in this scope
prog.cpp:46:24: error: expected type-specifier before ‘Exception’
prog.cpp:46:34: error: expected ‘)’ before ‘ex’
prog.cpp:46:34: error: expected ‘{’ before ‘ex’
prog.cpp:46:34: error: ‘ex’ was not declared in this scope
prog.cpp:46:36: error: expected ‘;’ before ‘)’ token
prog.cpp:63:31: error: ‘Convert’ was not declared in this scope
prog.cpp:74:24: error: expected type-specifier before ‘Exception’
prog.cpp:74:34: error: expected ‘)’ before ‘ex’
prog.cpp:74:34: error: expected ‘{’ before ‘ex’
prog.cpp:74:34: error: ‘ex’ was not declared in this scope
prog.cpp:74:36: error: expected ‘;’ before ‘)’ token
stdout
Standard output is empty