I have created a quiz program which goes through 5 questions. If you get a question wrong you are forced to start again from the beginning, I added this loop by
placing the code goto start; and placed start: where I wanted it to loop from.
My question is: I want to add a part at the end where it says how many times the program was looped so I can add a writeline saying "well done you took X times to complete the quiz"
here is the main part of the program:(without the namespaces and using statements)
/*----------------------------------------Declaration----------------------------------------- */
string q1, q2, q3, q4, q5;
/*----------------------------------------TITLE----------------------------------------- */
Console.WriteLine("Welcome to the Ultimate quiz!");
Console.WriteLine();
/*----------------------------------------QUESTION 1----------------------------------------- */
start:
Console.WriteLine("The JavaScript Language is not object oriented (True/False)");
Console.WriteLine();
q1 = Console.ReadLine();
q1 = q1.ToUpper();
if (q1 == "TRUE")
{
Console.WriteLine();
Console.WriteLine("Well Done, you may move on to the next question");
}
else
{
Console.WriteLine("Sorry you got the answer wrong, you have to start again");
goto start;
}
Console.WriteLine();
/*----------------------------------------QUESTION 2----------------------------------------- */
Console.WriteLine("What is the age range to qualify for an apprenticeship in the uk? Please type in the following format xx-yy");
Console.WriteLine();
q2 = Console.ReadLine();
if (q2 == "16-24")
{
Console.WriteLine();
Console.WriteLine("Well Done, you may move on to the next question");
}
else
{
Console.WriteLine("Sorry you got the answer wrong, you have to start again");
goto start;
}
Console.WriteLine();
/*----------------------------------------QUESTION 3----------------------------------------- */
Console.WriteLine("Is HTML a programming language (Yes or No)");
Console.WriteLine();
q3 = Console.ReadLine();
q3 = q3.ToUpper();
if (q3 == "NO")
{
Console.WriteLine();
Console.WriteLine("Well Done, you may move on to the next question");
}
else
{
Console.WriteLine("Sorry you got the answer wrong, you have to start again");
goto start;
}
Console.WriteLine();
/*----------------------------------------QUESTION 4----------------------------------------- */
Console.WriteLine("In JavaScript, What are the 2 charecters used to symbolise a single line comment?");
Console.WriteLine();
q4 = Console.ReadLine();
if (q4 == "//")
{
Console.WriteLine();
Console.WriteLine("Well Done, you may move on to the next question");
}
else
{
Console.WriteLine("Sorry you got the answer wrong, you have to start again");
goto start;
}
Console.WriteLine();
/*----------------------------------------QUESTION 5----------------------------------------- */
Console.WriteLine("500 < 600 && 700 < 600");
Console.WriteLine();
Console.WriteLine("Is the above statement true or false ?");
Console.WriteLine();
q5 = Console.ReadLine();
q5 = q5.ToUpper();
if (q5 == "FALSE")
{
Console.WriteLine();
Console.WriteLine("Well Done, you may move on to the next question");
Console.WriteLine();
Console.WriteLine("Congratulations You have passed the quiz!");
}
else
{
Console.WriteLine("Sorry you got the answer wrong, you have to start again");
goto start;
}
Console.WriteLine();
}
}
}
Thanks for all the help.
Simply add three line in your code -->
Before Start: --> int count = 0;
After Start: --> count++;
Last line of your code. -->
Console.WriteLine("well done you took " + count + " times to complete the quiz");
Ok, so you might already have your answer, and this is a solution too BUT (and i hope you don't take this as a negative thing) i remade the whole thing, to me at least it is simpler and less line consuming (at least i think so)
string q;
int retryCount = 1;
Console.WriteLine("Welcome to the Ultimate quiz!");
Console.WriteLine();
start:
const int numberOfQuestions = 5;
for (int i = 1; i <= numberOfQuestions; i++) {
if (i > 1) {Console.WriteLine();}
switch (i) {
case 1:
Console.WriteLine("The JavaScript Language is not object oriented (True/False)");
break;
case 2:
Console.WriteLine("What is the age range to qualify for an apprenticeship in the uk? Please type in the following format xx-yy");
break;
case 3:
Console.WriteLine("Is HTML a programming language (Yes or No)");
break;
case 4:
Console.WriteLine("In JavaScript, What are the 2 charecters used to symbolise a single line comment?");
break;
case 5:
Console.WriteLine("500 < 600 && 700 < 600");
Console.WriteLine();
Console.WriteLine("Is the above statement true or false ?");
break;
}
Console.WriteLine();
q = Console.ReadLine();
q = q.ToUpper();
switch (i) {
case 1:
if (q == "TRUE") {
Console.WriteLine();
Console.WriteLine("Well Done, you may move on to the next question");
} else { goto restart; }
break;
case 2:
if (q == "16-24") {
Console.WriteLine();
Console.WriteLine("Well Done, you may move on to the next question");
} else { goto restart; }
break;
case 3:
if (q == "NO") {
Console.WriteLine();
Console.WriteLine("Well Done, you may move on to the next question");
} else { goto restart; }
break;
case 4:
if (q == "//") {
Console.WriteLine();
Console.WriteLine("Well Done, you may move on to the next question");
} else { goto restart; }
break;
case 5:
if (q == "FALSE") {
Console.WriteLine();
goto end;
} else { goto restart; }
break;
}
}
restart:
Console.WriteLine("Sorry you got the answer wrong, you have to start again");
retryCount += 1;
goto start;
end:
Console.WriteLine("Congratulations You have passed the quiz!");
Console.WriteLine(String.Format("Well done!, you took {0} times to complete the quiz.", retryCount));
Console.ReadKey();
I hope this is what you were trying to acheive and you don't need to use all the code, was just showing you dont need to create q1,q2,q3 etc....
just add more cases at will.
put
count++
in the loop you want to know the number of loops it went, then for example if you want to check if the loop have gone 15 then
if(count = 15)
then add your code
declare
int count = 0;
at the begginging and everytime someone fails send them to repeat:
repeat:
count++;
goto start;
Like this:
void a() {
string q, q1;
int count = 0;
start:
int a = 2;
if (a != 3) goto repeat;
else goto end;
repeat:
count++;
goto start;
end:
string congrats = "you have repeated: " + count.ToString() + "times!";
}
Though others have answered the specific goto question I want to offer a way without using gotos, which might prove better in the long run if you want to count things while you loop.
Add a count:
string q1, q2, q3, q4, q5;
int count = 0;
Then let's use a while loop.
/*------------------------------QUESTION 1-------------------------------- */
while (true)
{
++count;
Console.WriteLine("The JavaScript Language is not object oriented (True/False)");
//... other questions as they were....
// with one small change e.g.
if (q1 == "TRUE")
{
Console.WriteLine();
Console.WriteLine("Well Done, you may move on to the next question");
}
else
{
Console.WriteLine("Sorry you got the answer wrong, you have to start again");
continue; // <-----------instead of goto start;
}
//... other questions as they were....
//with one small change
if (q5 == "FALSE")
{
Console.WriteLine();
Console.WriteLine("Well Done, you may move on to the next question");
Console.WriteLine();
Console.WriteLine("Congratulations You have passed the quiz!");
break; //<--------- if they get the final question right,
// break out of the while loop
}
} //<- end of while loop
//Output message you suggested
Console.WriteLine("You took {0} attempts", count);
Realistically, the goto and while/continue/break have the same effect, but give the program a bit more structure.
If you want to give them a maximum number of tries you can start considering using a for loop instead.
Related
int number;
do
{
DisplayMenu();
number = Convert.ToInt32(Console.ReadLine()); //here need int, string, and char
if (number < 0 || number > 6)
{
Console.WriteLine("An error occured!");
break;
}
} while (number != 0);
static void DisplayMenu()
{
Console.WriteLine("Main Menu");
Console.WriteLine("1) Calculate Sum ");
Console.WriteLine("2) Calculate Average");
Console.WriteLine("3) Display Numbers");
Console.WriteLine("4) Display Poem");
Console.WriteLine("5) Create Numbers Array");
Console.WriteLine("0) To Exit");
Console.WriteLine();
Console.WriteLine("Enter the number that corresponds to your choice: ");
}
I need to take the user input in integer, string, and character. Moreover, this code should then still work properly.
I was searching on other boards but there is no such thing I could find.
Reading your code, it appears that you are asking the user to enter a single digit from 0-5 to select the next function. One straightforward way of doing this is to substitute the ReadKey() method and switch on the result. As a bonus, the menu will execute immediately without having to wait for the [Enter] key.
// Loop until a valid int is received.
bool exit = false;
while (!exit)
{
DisplayMenu();
switch (Console.ReadKey().Key)
{
case ConsoleKey.D0: exit = true; break;
case ConsoleKey.D1: calculateSum(); break;
case ConsoleKey.D2: calculateAverage(); break;
case ConsoleKey.D3: displayNumbers(); break;
case ConsoleKey.D4: displayPoem(); break;
case ConsoleKey.D5: createNumbersArray(); break;
default:
Console.Clear();
Console.WriteLine("Please enter a number 0-5");
Thread.Sleep(1000);
break;
}
}
I'm a beginner in C# and I'd like to know if there a better way to write this 3+3 math problem by using loops, like maybe a do while loop ?
My code is the following :
static void Main (string[] args) {
Console.WriteLine ("What is 3+3?");
int answer = int.Parse (Console.ReadLine ());
int counter = 1;
if (answer == 6) {
Console.WriteLine ("Great! thats Correct! you've got it in the first try");
} else {
while (answer != 6) {
Console.WriteLine (" Wrong, please try again");
answer = int.Parse (Console.ReadLine ());
counter++;
if (answer == 6) {
Console.WriteLine ("Correct! Well done! you got it in {0} tries", counter);
}
}
}
Console.ReadLine ();
}
The aim of this program is to ask the user a question, check the answer and output a statement that says how many tries the user took to get the answer right.
If you could provide me suggestions.
If you're just wanting less code / a more concise option you could go for either of the following.
Note I've ignored the use of a slightly different error message for the first case and other cases. If this is important then you can of course have an if (counter == 1) statement.
This first example uses Do/While which will always execute the loop at least once and then check the exit condition (answer == 6) at the end of every loop.
static void Main(string[] args)
{
Console.WriteLine("What is 3+3?");
int answer;
int counter = 0;
do
{
answer = int.Parse(Console.ReadLine());
counter++;
if (answer == 6)
{
Console.WriteLine("Correct! Well done! you got it in {0} tries", counter);
}
else
{
Console.WriteLine(" Wrong, please try again");
}
}
while (answer != 6);
Console.ReadLine();
}
This second example uses a while loop that loops forever and the break keyword which breaks out of a loop once a certain condition is met. This prevents the need for extra if statements to get rid of pesky extra messages etc.
static void Main(string[] args)
{
Console.WriteLine("What is 3+3?");
int answer;
int counter = 0;
while (true)
{
answer = int.Parse(Console.ReadLine());
counter++;
if (answer == 6)
{
Console.WriteLine("Correct! Well done! you got it in {0} tries", counter);
break;
}
Console.WriteLine(" Wrong, please try again");
}
Console.ReadLine();
}
I don't know very much about this, but at least, in C++, when you fail, I invoked again the main method with Main();, adding the error message.
Hope this solves your problem.
Using do/while will be significantly shorter:
static void Main(string[] args)
{
int counter = 1;
boolean hasAnswer = false;
do {
Console.WriteLine("What is 3+3?");
int answer = int.Parse(Console.ReadLine());
if (answer == 6)
{
Console.WriteLine("Great! thats Correct! You've got it in " + counter + " attempt(s)");
hasAnswer = true
}
else
{
Console.WriteLine(" Wrong, please try again");
counter++;
}
} while(!hasAnswer);
}
I haven't rewritten C# in a while so the syntax might be off, but that is the gist of how to do it.
Hi i have been looking for where to put my console.clear because i have made a looping program but i would like to clear after use. Could any one tell me where to put a console.clear or give me a push in the right direction at least. Sorry i am very new to C# and have an assignment due in pretty soon and i am panicing that i havent got my Console.Clear command sorted yet. Here is my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assignment_test
{
class Program
{
static void Main(string[] args)
{
Console.Clear();
//when creating the variable i would of used byte however it wasn't picking it up so i had to use int which i know isnt effective use of memory
int sUserChoice = 0;
do
{
//this makes the text yellow
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Welcome to Hit ‘n’ Miss Ltd");
Console.WriteLine("Please select an option:");
Console.WriteLine("\n\n 1 for Welcoming to the system");
Console.WriteLine("\n 2 for the mean of grades of the class");
Console.WriteLine("\n 3 for what month it is");
Console.WriteLine("\n 4 for adds numbers between -10 and +10 and adds them together");
Console.WriteLine("0 is quit");
Console.Write("\n Please enter a number: ");
int.TryParse(Console.ReadLine(), out sUserChoice);
switch (sUserChoice)
{
case 1:
//here i say that to start talking about the parameter that i shall be using
WelcomeToTheSystem();
break;
case 2:
// here i call apon the parameter used
Grades();
break;
case 3:
// here i call apon the parameter used
Months();
break;
case 4:
// here i call apon the parameter used
AddingNegitiveAndPossitiveNumbers();
break;
// here i call apon the parameter used
case 0:
Quit();
break;
}
} while (sUserChoice != 0);
Console.ReadKey();
}
//start of prodecdures and funtions
private static int DataVaildation()
{
//variables
bool bUserInput;
int iNumber;
//below is a loop that runs at least once. the loop continues
//iterating while the condition evaluates to true, otherwise it ends
//and control goes to the statement immediately after it.
do
{
Console.Write("Please enter a number: ");
//converts string into int
bUserInput = Int32.TryParse(Console.ReadLine(), out iNumber);
//this will be true if the user input could not be converted for instance a word is used
if (!bUserInput)
{
Console.WriteLine("Input could not be converted into an integer number");
continue;
}
//the validation so if the inputted number from the user it will reject int and do the console.writeline.
if (iNumber < -11 || iNumber < 11)
{
//the error message
Console.WriteLine("Your are out of range please stay between -10 and +10");
bUserInput = false;
}
//the number is in range
else
{
Console.WriteLine("Vaild number!");
//if bUserInput is true then the loop can end.
bUserInput = true;
}
} while (!bUserInput);//while this evaluates to true, the loop continues.
return iNumber;
}
//option 4
private static void AddingNegitiveAndPossitiveNumbers()
{
Console.WriteLine("Please give me 2 number between -10 and +10 and ill add them together\n");
//calls apon the private static int above
int iNumber1 = DataVaildation();
int iNumber2 = DataVaildation();
//the adding will be done here
int iResult = iNumber1 + iNumber2;
Console.WriteLine("The sum of {0} + {1} is {2}", iNumber1, iNumber2, iResult);
}
//data validation
//option 3
private static void Months()
{
Console.WriteLine("so pick a number between 1 and 12. 1 is january and 12 december");
//here i declare that int is a variable
int iMonths = 0;
//i then will tryparse if someone inputs an invalid number
int.TryParse(Console.ReadLine(), out iMonths);
Console.ReadKey();
//i start a switch statement
switch (iMonths)
{
//if the user selects a number it will display the month this is done by using case to get the users input
case 1:
Console.WriteLine("It's January");
break;
case 2:
Console.WriteLine("It's Febuary");
break;
case 3:
Console.WriteLine("It's March");
break;
case 4:
Console.WriteLine("It's April");
break;
case 5:
Console.WriteLine("It's May");
break;
case 6:
Console.WriteLine("It's June");
break;
case 7:
Console.WriteLine("It's July");
break;
case 8:
Console.WriteLine("It's August");
break;
case 9:
Console.WriteLine("It's September");
break;
case 10:
Console.WriteLine("It's October");
break;
case 11:
Console.WriteLine("It's Novemeber");
break;
case 12:
Console.WriteLine("It's December");
break;
}
}
//0
private static void Quit()
{
//this bit exits the code if you press 0
System.Environment.Exit(0);
}
//1
private static void WelcomeToTheSystem()
{
Console.WriteLine("Please enter a name: ");
//used string here because its text
string sName =
Console.ReadLine();
Console.WriteLine("Welcome to the system: " + sName);
Console.ReadKey();
}
//2
private static void Grades()
{
int[] array1 = new int[15];
Console.WriteLine("please give me 15 numbers and i will give you the average of them");
for (int i = 0; i < array1.Length; i++)
{
while (int.TryParse(Console.ReadLine(), out array1[i]) == false)
{
Console.WriteLine("Please give me a number not text");
}
}
////here the averaging takes place it basscially averages the array that it has and adds + to every user input
Console.WriteLine("The average is {0} / 15 = {1}", string.Join("+", array1), array1.Average());
}
}
}
I would suggest place it at the beging of your cycle.
something like this:
do
{
...
//this makes the text yellow
Console.Clear();
Console.ForegroundColor = ConsoleColor.Yellow;
...
}
I would suggest writing a small method that asks if you want to continue. If so, Clear screen and then re-display everything
private static void WouldYouLikeToContinue()
{
Console.Write("Would you like to continue? [n to quit]: ");
string input = Console.ReadLine();
if (input.ToLower() == "n")
Quit();
Console.Clear(); // <--- This is where I would suggest adding the Clear.
}
you can use this method after the switch block
switch (sUserChoice)
{
case 1:
//here i say that to start talking about the parameter that i shall be using
userName = WelcomeToTheSystem();
break;
case 2:
// here i call apon the parameter used
Grades();
break;
case 3:
// here i call apon the parameter used
Months();
break;
case 4:
// here i call apon the parameter used
AddingNegitiveAndPossitiveNumbers();
break;
// here i call apon the parameter used
case 0:
Quit();
break;
}
WouldYouLikeToContinue(); // <----- HERE
} while (sUserChoice != 0);
NOTE: Your method to validate data... has a syntax error.
if (iNumber < -11 || iNumber > 11) // iNumber should be > 11 (not < 11)
Starting to learn about loops. It seems like these things go on forever because I am not telling it to stop. Problem is I don't know how to tell it to stop. I am assuming a statement such as != but I really do not know.
Anyone care to explain how loops stop?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication326
{
class Program
{
static void Main(string[] args)
{
bool triLoop = true;
while (triLoop)
{
Console.WriteLine("Please enter the first integer...");
int firstInt = int.Parse(Console.ReadLine());
Console.WriteLine("Please enter the second integer...");
int secondInt = int.Parse(Console.ReadLine());
Console.WriteLine("Please enter the third integer...");
int thirdInt = int.Parse(Console.ReadLine());
if ((firstInt + secondInt > thirdInt) && (secondInt + thirdInt > firstInt) && (firstInt + thirdInt > secondInt))
{
Console.WriteLine("The numbers {0}, {1}, and {2} CAN represent sides of the same triangle.", firstInt, secondInt, thirdInt);
}
else
{
Console.WriteLine("The numbers {0}, {1}, and {2} CANNOT represent the sides of the same triangle.", firstInt, secondInt, thirdInt);
}
}
}
}
}
The break statement will "break out" of a loop.
Alternatively, you can just set your boolean value (triLoop) to false.
Anyone care to explain how loops stop
While loop will run for as long as the condition within the loop is true. In order to break it you need to set the expression in the while loop to false.
it will stop when you set triLoop to false. You should read the documentation.
while(triLoop)
{
if(somecondition)
triLoop = false; //loop will not run after this
}
a basic example of this. This loop will run till 5.
int n = 1;
while (n < 6)
{
Console.WriteLine("Current value of n is {0}", n);
n++;
}
Set triLoop to false. Or use break;.
Other answers have explained how the condition works, but if you want to ask the user whether they want to continue, you could add this to the end of your loop:
Console.WriteLine("Would you like to continue? (Y/N)");
if(Console.ReadLine() == "Y")
triLoop = false;
Then the condition will evaluate to false if the user types "Y", and the loop will end.
There are multiple answers.
break; //exits the loop and continues with the code
return; //stops the loop and doesn't proceed with the rest of the code
In your case, you can also set triloop to false.
use this in loops to stop loops
break;
as you are using while loop
while (triLoop)
{
}
this loop runs while triLoop variable is true
you need to set it to false somewhere within while loop
like
while (triLoop)
{
//your code
// on some condition
triLoop = false;
}
or
while (triLoop)
{
//your code
// on some condition
break;
}
try this:
while (triLoop)
{
Console.WriteLine("Please enter the first integer...");
int firstInt = int.Parse(Console.ReadLine());
Console.WriteLine("Please enter the second integer...");
int secondInt = int.Parse(Console.ReadLine());
Console.WriteLine("Please enter the third integer...");
int thirdInt = int.Parse(Console.ReadLine());
if ((firstInt + secondInt > thirdInt) && (secondInt + thirdInt > firstInt) && (firstInt + thirdInt > secondInt))
{
Console.WriteLine("The numbers {0}, {1}, and {2} CAN represent sides of the same triangle.", firstInt, secondInt, thirdInt);
}
else
{
Console.WriteLine("The numbers {0}, {1}, and {2} CANNOT represent the sides of the same triangle.", firstInt, secondInt, thirdInt);
}
Console.WriteLine("press 0 if you want to continue...");
int flag = int.Parse(Console.ReadLine());
if(flag!=0) break;
}
I'm making a program that has little programs inside of it, and I've come to a dilemma. On my first mini-program which rearranges digits to find the greatest possible number from those digits, it asks if the user wants to quit. If they respond "Yes" then the function returns 0 which is evaluated in the main(string[] args) method. My problem is that whenever the user says "No", the mini-program still doesn't continue. Here's my source:
namespace ACSL_Competition
{
class Program
{
static int DigitRearranger()
{
string[] mainString = {};
Console.WriteLine("---------Welcome to the Digit Re-arranger!---------");
Console.WriteLine("I take a positive number up to 10000, and find the highest number that can be made out of its digits.");
Console.WriteLine("Instructions: Enter a number up to 10000, and see the results!");
drLabel:
Console.Write("Your Number: ");
string input = Console.ReadLine();
int inputNumber = 0;
try { inputNumber = int.Parse(input); }
catch (Exception ex) { Console.WriteLine("Error: {0}", ex.Message); goto drLabel; }
/*Placeholder code for the moment*/Console.WriteLine(inputNumber.ToString());
evaluate:
Console.Write("Do you want to exit? Yes/No: ");
if (Console.ReadLine().Equals("Yes"))
return 1;
else if (Console.ReadLine().Equals("No"))
{
goto drLabel;
}
else
{
return 1;
}
}
static void Main(string[] args)
{
Console.WriteLine("Welcome to the ACSL Competition Program. Choose a program to begin:");
Console.Write("\n\t");
Console.WriteLine("1\tDigit Re-arranger");
label:
Console.Write("\nProgram: ");
string input = Console.ReadLine();
int number = 0;
try { number = int.Parse(input); }
catch (Exception ex) { Console.WriteLine("Error: {0}", ex.Message); goto label; }
if (number == 1)
{
Console.WriteLine("\n");
if (DigitRearranger() == 1)
{
goto label;
}
else if (DigitRearranger() != 1)
{
DigitRearranger();
}
}
else if (!number.Equals(1))
{
Console.WriteLine("Not a valid program.");
goto label;
}
//----------------
Console.ReadLine();
}
}
}
The underlying problem is that you're calling readline twice. The first time it gets the entered value, i.e. Yes, the second time you call it there is no data to read so it returns "". If you need to reuse the same input store it in a variable, i.e.
string inputVal = Console.ReadLine();
I hate goto statements, maybe you could restructure your code in to a while loop, something like:
bool exit = false;
while(!exit)
{
Console.Write("Your Number: ");
//Your main code
Console.Write("Do you want to exit? Yes/No: ");
if(Console.ReadLine() != "No")
exit = true;
}
In fact, you could get rid of the exit variable, just do while(true) and return if the user enters anything other than no.
I have a few suggestions:
Write your code to be more modular to improve readability. The Main() method should only drive the outer UI loop, each module provides its own UI.
Never use goto statements.
Don't use Console.Readline() inside an if condition (when not "Yes", it was called twice).
Here is my refactored version of your code:
class Program {
static void DigitRearranger()
{
string response = "";
int num;
do
{
Console.Clear();
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("---------Welcome to the Digit Re-arranger!---------");
Console.WriteLine("I take a positive number up to 10000, and find the highest number that can be made out of its digits.");
Console.WriteLine("Instructions: Enter a number up to 10000, and see the results!");
Console.ResetColor();
Console.Write("Your Number: ");
if (!int.TryParse(Console.ReadLine(), out num))
{
Console.WriteLine("Not a number. Press any key to continue");
Console.ReadKey();
continue;
}
//todo: reaarrange the number & print results
/*Placeholder code for the moment*/
Console.WriteLine(num);
Console.Write("Do you want to exit? Yes/No: ");
response = Console.ReadLine();
} while (response.ToLower() != "yes");
}
//UI driver only in Main method:
static void Main(){
string response = "";
do
{
Console.Clear();
Console.WriteLine("Welcome to the ACSL Competition Program. Choose a program to begin:");
Console.WriteLine("\n\t1\tDigit Re-arranger");
Console.WriteLine("\tq\tQuit");
Console.Write("\nProgram: ");
response = Console.ReadLine();
switch(response)
{
case "1":
DigitRearranger();
break;
case "q":
break;
default:
Console.WriteLine("Not a valid program. Press any key to continue");
Console.ReadKey();
break;
}
} while (response.ToLower() != "q");
Console.ReadLine();
}}