console.clear placement within a looping program - c#

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)

Related

How to accept the user response either as an int, or a char or a string. C#

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;
}
}

Allowing user to choose to display entire number in calculator or only 2 decimals

I'm making a basic calculator and I'm wondering how I would go on to make the user choose if he/she wants to display the full result or only the result with 2 decimals. For example, if user puts in first number 4.213 and second number 4.6321, method "+" then the console asks "Do you wish to display the entire result or round it to 2 decimals" at which the user can type in "Yes" or "No".
I'm not looking for the program to round up the decimals, just display 2 decimals or the entire number.
I'm guessing if and else statement would be the way to go here.
Code:
using System.Collections.Generic;
namespace ConsoleApp1
{
class Program
{
private static int runda;
static void Main(string[] args)
{
List<double> Numbers = new List<double>();
string Method = "";
while (true)
{
loop:
try
{
Numbers.Add(ConvStr(TakeUserInput("First Number:")));
}
catch
{
Console.Clear();
Console.WriteLine("Error, try again.");
Console.ReadLine();
goto loop;
}
Console.Clear();
looop:
try
{
Numbers.Add(ConvStr(TakeUserInput("Second Number:")));
}
catch
{
Console.Clear();
Console.WriteLine("Error, try again.");
Console.ReadLine();
goto looop;
}
Console.Clear();
do
{
Method = TakeUserInput("Choose method: ");
Console.Clear();
Console.WriteLine("Error (Endast Addition (+) Subtraktion (-) Multiplikation (*) samt division (/)");
}
while (!CheckMethod(Method));
Console.Clear();
**HERE IS WHERE I WOULD LIKE USER TO CHOOSE IF DISPLAY ENTIRE NUMBER OR ONLY 2 DECIMALS**
Console.WriteLine("Result:");
Console.WriteLine(Calc(Numbers, Method));
Console.WriteLine("If you wish to keep using this calculator press Enter.");
Console.ReadLine();
Numbers.Clear();
}
}
private static string TakeUserInput(string DisplayText)
{
Console.Write(DisplayText);
return Console.ReadLine();
}
private static bool CheckMethod(string method)
{
switch(method)
{
case "+":
break;
case "-":
break;
case "*":
break;
case "/":
break;
default:
return false;
}
return true;
}
private static double Calc(List<double> input, string method)
{
double Answer = 0;
switch (method)
{
case "+":
Answer = input[0] + input[1];
break;
case "-":
Answer = input[0] - input[1];
break;
case "*":
Answer = input[0] * input[1];
break;
case "/":
Answer = input[0] / input[1];
break;
}
return Answer;
}
private static double ConvStr(string input)
{
return Convert.ToDouble(input = input.Replace(".", ","));
}
}
}
Might be wrong but couldn’t you
1). Turn the integer(result) into a string
2). Use the .indexOf(“”) function on the string to get the location of the period
3). check the index+3 to be in range of the result in order to not give any errors (3 to skip the period as well)
4). Use the .remove(index) function to remove all other numbers at the new index
5). Use Convert.toInt32(string) to get its value back
Also there is a “Data.” something function which enables you to calculate the result of a string representation of the expression if that is of any help

using loops and methods together

Recently i made a simple calculator to test myself but it was clunky and cluttered because it used a large number of if statements so i used switches to clean it up. recently i learned how to use methods and tried to move each part of the code into a separate and relevant methods. But, some of my code uses loops to return to the start of the code to act as a reset function and now it doesn't work because it doesn't recognize that it is a part of a loop. i tried calling all the methods in a loop inside the main method but it still didn't work. how can i fix this?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace Calculator
{
class Class1
{
static int num1 = 0;
static int num2 = 0;
static int answer = 0;
static string sumType = " ";
static string consoleContinue = " ";
static void GetUserInput()
{
Console.WriteLine("please enter your first value");
num1 = int.Parse(Console.ReadLine());
Console.WriteLine("please enter your second value");
num2 = int.Parse(Console.ReadLine());
}
static void GetSumType()
{
Console.WriteLine("would you like to add, subtract, multiply or divide?");
Console.WriteLine("alternitavely type quit to exit the program");
sumType = Console.ReadLine();
switch (sumType.ToLower())
{
case "add":
answer = (num1 + num2);
Console.WriteLine("your answer is {0:0.00}", answer);
break;
case "subtract":
answer = (num1 - num2);
Console.WriteLine("your answer is {0:0.00}", answer);
break;
case "multiply":
answer = (num1 * num2);
Console.WriteLine("your answer is {0:0.00}", answer);
break;
case "divide":
answer = (num1 / num2);
Console.WriteLine("your answer is {0:0.00}", answer);
break;
case "quit":
Environment.Exit(-1);
break;
}
}
static void ConsoleContnue()
{
Console.WriteLine("do you wish to continue? type yes to continue and no to exit the program");
consoleContinue = Console.ReadLine();
switch (consoleContinue.ToLower())
{
case "yes":
continue;
break;
case "no":
Environment.Exit(-1);
break;
}
}
static void Main(string[] args)
{
while (true)
{
GetUserInput();
GetSumType();
ConsoleContnue();
}
Console.ReadLine();
}
}
}
In your "ConsoleContnue()" function -> in the switch statement for "yes" you can remove the "continue" so it looks like this:
switch (consoleContinue.ToLower())
{
case "yes":
break;
case "no":
Environment.Exit(-1);
break;
}
Then your code seems to run perfectly.
However, I would change it to a simple one liner since you only care about the "no" clause:
if (consoleContinue.ToLower() == "no") Environment.Exit(-1);

Print message when invalid data entered in console application using switch C#

Im trying to write a basic calculator with a main menu and sub menu.
The code is working fine when a valid entry is inputted, but I want an error message to be displayed and then return the user to the main menu when invalid data is entered.
This is what I have done so far. Can someone tell me what am I doing wrong?
static void Main(string[] args)
{
// Main method (only to be used for mainmenu() execution)
MainMenu();
}
// Main Menu method
static void MainMenu()
{
// Declaring variables
// Selection variable, used in user's input to get to the desired operation
int sel;
char letter;
// Main menu styling
Console.WriteLine("Calculator");
Console.WriteLine("********************");
Console.WriteLine("1- Calculator");
Console.WriteLine("2- Exit Calculator");
Console.Write("Please enter your option here: ");
// Converting user's input to sel's type (byte)
sel = int.Parse(Console.ReadLine());
// Processing sel
switch (sel)
{
case 1:
// Execute Addition()
SecondMenu();
break;
case 2:
Console.ReadLine();
break;
default:
Console.WriteLine("Sorry that is not correct format! Please restart!"); //Catch
break;
}
}
static void SecondMenu()
{
char sel2; // Selection variable, used in user's input to get to the desired operation
// Display Menu Options
Console.WriteLine("");
Console.WriteLine("********************");
Console.WriteLine("A. Addition");
Console.WriteLine("S. Substraction");
Console.WriteLine("D. Division");
Console.WriteLine("********************");
Console.Write("Please enter your option here: ");
// Converting user's input to sel's type (byte)
sel2 = Convert.ToChar(Console.ReadLine());
// Processing sel
switch (sel2)
{
case 'a':
// Execute Addition()
Addition();
break;
case 's':
// Execute Substraction()
Substraction();
break;
case 'd':
// Execute Division()
Division();
break;
}
}
// Addition Method
static void Addition()
{
// Declaring variables
double num1, num2, res;
Console.Write("Please enter the first number: ");
// Getting user's input and converting it
num1 = Convert.ToDouble(Console.ReadLine());
Console.Write("Please enter the second number: ");
// Getting user's input and converting it
num2 = Convert.ToDouble(Console.ReadLine());
// Processing numbers into one variable
res = num1 + num2;
// Printing out the result
Console.WriteLine("RESULT: " +res);
Console.WriteLine("");
Console.ReadKey(true);
MainMenu();
}
// Substraction Method
static void Substraction()
{
// Declaring variables
double num1, num2, res;
Console.Write("Please enter the first number: ");
// Getting user's input and converting it
num1 = Convert.ToDouble(Console.ReadLine());
Console.Write("Please enter the second number: ");
// Getting user's input and converting it
num2 = Convert.ToDouble(Console.ReadLine());
// Processing numbers into one variable
res = num1 - num2;
// Printing out the result
Console.WriteLine("RESULT: " + res);
Console.ReadKey(true);
MainMenu();
}
// Division
static void Division()
{
// Declaring variables
double num1, num2, res;
Console.Write("Please enter the first number: ");
// Getting user's input and converting it
num1 = Convert.ToDouble(Console.ReadLine());
Console.Write("Please enter the second number: ");
// Getting user's input and converting it
num2 = Convert.ToDouble(Console.ReadLine());
// Processing numbers into one variable
res = num1 / num2;
// Printing out the result
Console.WriteLine("RESULT: " + res);
Console.WriteLine("");
Console.ReadKey(true);
MainMenu();
}
You can call the MainMenu() method in the default part of the switch in it.
switch (sel)
{
case 1:
// Execute Addition()
SecondMenu();
break;
case 2:
Console.ReadLine();
break;
default:
Console.WriteLine("Sorry that is not correct format!");
MainMenu();
//Catch
break;
}
It is also recommended to have a condition to exit the program (like a maximum number of invalid inputs).
Something like this works, but you'll have to adjust accordingly to fit your requirements:
int sel;
char letter;
bool valid = false;
do
{
Console.WriteLine("Calculator");
Console.WriteLine("********************");
Console.WriteLine("1- Calculator");
Console.WriteLine("2- Exit Calculator");
Console.Write("Please enter your option here: ");
sel = int.Parse(Console.ReadLine());
switch (sel)
{
case 1:
SecondMenu();
break;
case 2:
Environment.Exit(0);
break;
default:
Console.WriteLine("Sorry that is not correct format! Please restart!");
break;
}
}
while (valid != true);
You could just do it like this
static void SecondMenu()
{
char sel2; // Selection variable, used in user's input to get to the desired operation
// Display Menu Options
Console.WriteLine("");
Console.WriteLine("********************");
Console.WriteLine("A. Addition");
Console.WriteLine("S. Substraction");
Console.WriteLine("D. Division");
Console.WriteLine("********************");
Console.Write("Please enter your option here: ");
sel2 = Convert.ToChar(Console.ReadLine());
switch (sel2)
{
case 'a':
Calc(1);
break;
case 's':
Calc(2);
break;
case 'd':
Calc(3);
break;
default:
Console.WriteLine("Wrong entry! Try again");
MainMenu();
return;
}
}
static void Calc(int f)
{
double num1, num2, res;
try
{
Console.Write("Please enter the first number: ");
num1 = Convert.ToDouble(Console.ReadLine());
Console.Write("Please enter the second number: ");
num2 = Convert.ToDouble(Console.ReadLine());
switch (f)
{
case 1:
res = num1 + num2;
break;
case 2:
res = num1 - num2;
break;
case 3:
res = num1 / num2;
break;
default:
Console.WriteLine("Wrong entry! Try again");
MainMenu();
return;
}
Console.WriteLine("RESULT: " + res);
Console.WriteLine("");
Console.ReadKey(true);
MainMenu();
}
catch
{
Console.WriteLine("Wrong entry! Try again");
MainMenu();
}
}
EDIT: To make sure the first menu wont crash, sorround it with a try catch block
try
{
sel = int.Parse(Console.ReadLine());
switch (sel)
{
case 1:
SecondMenu();
break;
case 2:
Console.ReadLine();
break;
default:
Console.WriteLine("Sorry that is not correct format! Please restart!");
MainMenu();
break;
}
}
catch
{
Console.WriteLine("Sorry that is not correct format! Please restart!");
MainMenu();
}
Your problem was, that it tried to parse a char into an int, what is not possible.
You can either write the switch case in another method and call the main method at the default case after printing the error message,
OR
Use a do-while loop,
Inside do, write the switch cases and put a condition at while to exit the calculator.
For example: 'Enter -1 to exit the calculator' and condition in while x!=-1
Try having a play with this:
static void Main(string[] args)
{
MainMenu();
}
static void MainMenu()
{
int sel = -1;
while (sel != 2)
{
Console.WriteLine("Calculator");
Console.WriteLine("********************");
Console.WriteLine("1- Calculator");
Console.WriteLine("2- Exit Calculator");
Console.Write("Please enter your option here: ");
sel = int.Parse(Console.ReadLine());
if (sel == 1)
{
SecondMenu();
}
else if (sel != 2)
{
Console.WriteLine("Sorry that is not correct format! Please restart!"); //Catch
}
}
}
static void SecondMenu()
{
var options = new Dictionary<char, Func<double, double, double>>()
{
{ 'a', (x, y) => x + y },
{ 's', (x, y) => x - y },
{ 'd', (x, y) => x / y },
};
while (true)
{
Console.WriteLine("");
Console.WriteLine("********************");
Console.WriteLine("A. Addition");
Console.WriteLine("S. Substraction");
Console.WriteLine("D. Division");
Console.WriteLine("********************");
Console.Write("Please enter your option here: ");
char sel = Convert.ToChar(Console.ReadLine());
if (options.ContainsKey(sel))
{
Calculate(options[sel]);
break;
}
}
}
static void Calculate(Func<double, double, double> operation)
{
Console.WriteLine("Please enter the first number: ");
double num1 = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Please enter the second number: ");
double num2 = Convert.ToDouble(Console.ReadLine());
double res = operation(num1, num2);
Console.WriteLine("RESULT: " + res);
Console.WriteLine("");
Console.ReadLine();
}

How to call a function in a case statement?

Hello I am new at this and I Would like to call the function menu in the other case statement so that when i press 1 it directly goes to the case which is labelled groceries.Hopefully I have explained myself thoroughly.
static void menu()
{
Console.WriteLine("Select a category to view");
Console.WriteLine("");
Console.WriteLine("1.Groceries");
Console.WriteLine("2.Electronics & Appliances");
Console.WriteLine("3.Exit");
Console.ReadKey();
int response = int.Parse(Console.ReadLine());
switch (response)
{
case 1:
Console.WriteLine("...........Groceries...............");
break;
case 2:
Console.WriteLine("..............Electronics & Appliances............");
break;
case 3:
Console.WriteLine("...........Exit...............");
break;
}
}
static void Main(string[] args)
{
menu();
Console.WriteLine(#" Choose items being purchased from Groceries /n
1:stove = 3000 \n 2: potcollection = 2000 \n
3:lemonsqeezer = 1000 \n 4:oven = 10000 \n 5:blender = 6000");
double stove = 3000;
double lemonsqeezer = 1000;
double oven = 10000;
double blender = 6000;
double potcollection = 2000;
Console.WriteLine("Enter a number from the above groceries list");
int response = int.Parse(Console.ReadLine());
if (response == 1)
switch (response)
{
case 1:
Console.WriteLine("The total is{0}",);
break;
case 2:
Console.WriteLine("The total is {0}",);
break;
}
}
You always process option 1, because you have an if statement wrapping your switch.
if (response == 1) // no other response other than 1 will get processed.
switch (response)
{
case 1:
Console.WriteLine("The total is{0}",);
break;
case 2:
Console.WriteLine("The total is {0}",);
break;
}
}
Remove the if and the other case statements will get executed.
You're already doing it.
switch (response)
{
case 1:
Console.WriteLine("...........Groceries...............");
You're calling Console.WriteLine from your case. You can call another method or function the same way.
I modified you code:
static void menu()
{
double[] groceries = new double[] { 3000, 1000, 10000, 6000, 2000 }; // By creating an array, you can easily get the price of an item by the index.
// double[] groceries = new double[] { stove, lemonsqeezer, oven, blender, potcollection };
// double[] electronics_and_appliances = new double[] { ... };
Console.WriteLine("Select a category to view");
Console.WriteLine("");
Console.WriteLine("1.Groceries");
Console.WriteLine("2.Electronics & Appliances");
Console.WriteLine("3.Exit");
int response = int.Parse(Console.ReadLine());
switch (response)
{
case 1:
Console.WriteLine("...........Groceries...............");
Console.WriteLine("");
Console.WriteLine(#" Choose items being purchased from Groceries /n
1:stove = 3000 \n 2: potcollection = 2000 \n
3:lemonsqeezer = 1000 \n 4:oven = 10000 \n 5:blender = 6000");
Console.WriteLine("");
Console.WriteLine("Enter a number from the above groceries list");
// This prevents IndexOutOfRangeException.
try
{
Console.WriteLine("The total is {0}", groceries[int.Parse(Console.ReadLine()) - 1]); // Minus one becuase index's start from 0.
}
catch
{
Console.WriteLine("That item doesn't exist");
}
break;
case 2:
Console.WriteLine("..............Electronics & Appliances............");
/*
Console.WriteLine("");
Console.WriteLine(#"Choose items being purchased from Electronics & Appliances/n ...");
Console.WriteLine("");
Console.WriteLine("Enter a number from the above Electronics & Appliances list");
try
{
Console.WriteLine("The total is {0}", electronics_and_appliances[int.Parse(Console.ReadLine()) - 1]);
}
catch
{
Console.WriteLine("That item doesn't exist");
}
*/
break;
case 3:
Console.WriteLine("...........Exit...............");
break;
}
}
static void Main(string[] args)
{
menu();
}

Categories

Resources