NEEDED IN C# A restaurant has 4 lunch combos for customers to choose: Combo 1: F
ID: 3664953 • Letter: N
Question
NEEDED IN C#
A restaurant has 4 lunch combos for customers to choose:
Combo 1: Fried chicken with slaw [price: 4.25]
Combo 2: roast beef with mashed potato [price: 5.75]
Combo 3: Fish and chips [price:5.25]
Combo 4: soup and salad [price: 3.75]
Write a program to ask which lunch combo the customer orders. Use a switch statement to determine and display the amount of money the customer needs to pay. Display “Invalid input” if the customer ordered something not on the menu. Do not use any if…else statements.
Explanation / Answer
using System;
public class Test
{
public static void Main()
{
int choice;
double bill=0;
char more;
Console.WriteLine("---------MENU---------");
Console.WriteLine("Combo 1: Fried chicken with slaw [price: 4.25]");
Console.WriteLine("Combo 2: roast beef with mashed potato [price: 5.75]");
Console.WriteLine("Combo 3: Fish and chips [price:5.25]");
Console.WriteLine("Combo 4: soup and salad [price: 3.75]");
Console.WriteLine(" Enter Choice : ");
choice=int.Parse(Console.ReadLine());
switch (choice)
{
case 1: bill=bill+4.25; break;
case 2: bill=bill+5.75; break;
case 3: bill=bill+5.25; break;
case 4: bill=bill+3.75; break;
default: Console.WriteLine("Invalid input"); break;
}
Console.WriteLine(" Final Bill : "+bill);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.