using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NotEndsInZero
{
class Program
{
static void Main(string[] args)
{
//Mr. Keller
String str_users_name; //Hold onto the user's name
int int_i = 0; //loop counter
int int_max = 0; //Maximum integer entered by user
int int_min = 0; //Minimum integer entered by user
int int_increment = 0; //Increase or Decrease based on odd or even by this amount
bool bool_true; //Logical operator
// Ask for User's Name
Console.WriteLine("Please enter your name");
// Read Users Name
str_users_name = Console.ReadLine();
// Process the Maximum Number
bool_true = true;
while (bool_true)
{
Console.WriteLine("\nPlease enter your Maximum number as an integer:");
try
{
int_max = Convert.ToInt32(Console.ReadLine());
if (int_max <= 0)
{
Console.WriteLine("Only positive numbers are valid.");
bool_true = true;
}
else
{
bool_true = false;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine("You did not enter an INTEGER.");
bool_true = true;
}
}
// Process the Minimum Number
bool_true = true;
while (bool_true)
{
Console.WriteLine("\nPlease enter your Minimum number as an integer:");
try
{
int_min = Convert.ToInt32(Console.ReadLine());
if (int_min >= int_max)
{
Console.WriteLine("Your minimum number needs to be LESS Than Your Maximum of: " + int_max);
bool_true = true;
}
else
{
bool_true = false;
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine("Please enter an integer.");
bool_true = true;
}
}
// Determine if Maximum is even or odd
int_increment = 3;
if (IsEven(int_max))
{
int_increment = 2;
}
// Write out the decreasing amount from int_max to int_min
Console.WriteLine(str_users_name + ", here are your numbers in decreasing order from : " + int_max + " to " + int_min);
for (int_i = int_max; int_i >= int_min; int_i = int_i - int_increment)
{
if (!EndsInZero(int_i))
{
Console.WriteLine("int_i= " + int_i);
}
}
// Determine if Minimum is even or odd
int_increment = 3;
if (IsEven(int_min))
{
int_increment = 2;
}
// Write out the decreasing amount from int_min to int_max
Console.WriteLine(str_users_name + ", here are your numbers in increasing order from : " + int_min + " to " + int_max);
for (int_i = int_min; int_i <= int_max; int_i = int_i + int_increment)
{
if (!EndsInZero(int_i))
{
Console.WriteLine("int_i= " + int_i);
}
}
Console.ReadLine();
}
// Method to determine if the integer being passed in is positive
public static bool IsEven(int value)
{
return value % 2 == 0;
}
// Method to determine if the integer being passed ends in 0
public static bool EndsInZero(int value2)
{
return value2 % 10 == 0;
}
}
}