Question: i have this c sharp assigment that im stuck on..i genarlly struggle with loops and when to use them this is my code so far

i have this c sharp assigment that im stuck on..i genarlly struggle with loops and when to use them this is my code so far

class Print_A_Range_Of_Numbers {

public void RunExercise() { int lowNumber; int highNumb; int printNumb = 0; int evenOdd=;

Console.WriteLine("Greetings user"); Console.WriteLine("Welcome to the number printer"); Console.WriteLine("Do you want to quit the program(1) or print a number (2)");

while (printNumb < 1 || printNumb > 2)

{ if (Int32.TryParse(Console.ReadLine(), out printNumb) == false) Console.WriteLine(" you must enter 1 to exit or 2 to continue"); else if (printNumb < 1) Console.WriteLine(" your value is smaller than 1"); else if (printNumb > 2) Console.WriteLine("your value is greater than 2");

}

Console.WriteLine("do you want to print even(1) or odd(2)");

while (evenOdd < 1 || evenOdd > 2) { if (Int32.TryParse(Console.ReadLine(), out evenOdd) == false) Console.WriteLine(" you must enter 1 to exit or 2 to continue"); else if (evenOdd < 1) Console.WriteLine(" your value is smaller than 1"); else if (evenOdd > 2) Console.WriteLine("your value is greater than 2");

} Console.WriteLine();

Console.WriteLine("what is the min value?"); lowNumber = Int32.MinValue; while (lowNumber == Int32.MinValue) { if (Int32.TryParse(Console.ReadLine(), out lowNumber) == false) { Console.WriteLine(" you need to type a whole number"); }

}

Console.WriteLine("what is the max value?"); lowNumber = Int32.MinValue; while (highNumb == Int32.MaxValue) { if (Int32.TryParse(Console.ReadLine(), out highNumb) == false) { Console.WriteLine(" you need to type a whole number"); } else if (highNumb < lowNumber) { Console.WriteLine("your smaller value cant be larger than the larger value "); } }

Console.WriteLine("thanks for using the program have a great day"); } }

and this is the required outcome

In the starter project, fill in the Print_A_Range_Of_Numbers.RunExercise method, so that it will prompt the user to pick a starting number, an ending number, and whether to print even or odd numbers. Your program should then print out only those (odd or even) numbers that are equal to (or greater than) the starting number, and less than (or equal to) the ending number. You should write your code so that is as efficient as possible, where efficiency is measured by the amount of work the computer needs to do.

An example transcript of what your program might look like follows. User input looks like this.

Greetings, User! Welcome to NumberPrinter! Do you want to quit (1), or print numbers (2) ? 2 Do you want to print even (1) or odd (2) numbers? 1 Lowest number? 3 Highest Number? 10 Numbers: 4 6 8 10 Do you want to quit (1), or print numbers (2) ? 2 Do you want to print even (1) or odd (2) numbers? 2 Lowest number? 3 Highest Number? 10 Numbers: 3 5 7 9 Do you want to quit (1), or print numbers (2) ? 1 Have a nice day!

any help would be appreciated, i wasted too much time tryig to figure it out on my own

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!