Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a C# function that reads and displays a text file menu. *****************

ID: 3823810 • Letter: C

Question

Create a C# function that reads and displays a text file menu.

**********************************

* Welcome to Alonzo’s Coffee Shop! *

* What would you like to order? *

* 1. Coffe ($1.50) *

* 2. Latte ($2.00) *

* 3. Pastry ($1) *

* 4. Exit *

**********************************

Then create a function to gather the response of the user and validates it with if statements. Validate the user input with the if statement depending of the if statement we display a menu and gather the user input . Use switch statements inside of the if statements to gather response we validate the user response with a switch statement. If the user selects 1 Coffee we display a addon menu

* You selected Coffee *

* What would you like to add any items? *

* 1. Sugar *

* 2. Milk *

* 3. Creamer *

* 4. Return to the main menu *

If user selects 2

* You selected Latte *

* What would you like to add any items? *

* 1. Honey *

* 2. Caramel *

* 3. Return to the main menu *

If user selects 3

* You selected Pastry *

* What would you like to add any items? *

* 1. Donut *

* 2. Cake *

* 3. Pie *

* 4. Return to the main menu *

Repeat the code till the user chooses to exit on the main menu. Create a function to calculate the cost of the purchases and then display the receipt.

Explanation / Answer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace check1
{
class Program
{
static void Main(string[] args)
{
double bill = 0.0;
int i;
bool flag = true;
while(flag)
{
Console.Write("********************************** ");
Console.Write("* Welcome to Alonzos Coffee Shop! * * What would you like to order? * * 1. Coffe ($1.50) * * 2. Latte ($2.00) * * 3. Pastry ($1) * * 4. Exit * ");
  
Console.Write("********************************** ");
i = int.Parse(Console.ReadLine());
if (i==1)
{
bill = bill + 1.50;
Console.Write(" * You selected Coffee * * What would you like to add any items? * * 1. Sugar * * 2. Milk * * 3. Creamer * * 4. Return to the main menu * ");
int m;
m=int.Parse(Console.ReadLine());
switch(m)
{
case 1 : Console.Write("You added Sugar");
break;
case 2 : Console.Write("You added Milk");
break;
case 3 : Console.Write("You added Creamer");
break;
case 4 : flag=true;
break;
default : Console.Write("Choose Correct Option");
break;
}
}
else if(i==2)
{
bill = bill + 2.00;
Console.Write(" * You selected Latte * * What would you like to add any items? * * 1. Honey * * 2. Caramel * * 3. Return to the main menu * ");
int m;
m=int.Parse(Console.ReadLine());
switch(m)
{
case 1 : Console.Write("You added Honey");
break;
case 2 : Console.Write("You added Caramel");
break;
case 3 : flag=true;
break;
default : Console.Write("Choose Correct Option");
break;
}
}
else if(i==3)
{
bill = bill + 1.00;
Console.Write(" * You selected Pastry * * What would you like to add any items? * * 1. Donut * * 2. Cake * * 3. Pie * * 4. Return to the main menu * ");
int m;
m=int.Parse(Console.ReadLine());
switch(m)
{
case 1 : Console.Write("You added Donut");
break;
case 2 : Console.Write("You added Cake");
break;
case 3 : Console.Write("You added Pie");
break;
case 4 : flag=true;
break;
default : Console.Write("Choose Correct Option");
break;
}
}
else if(i==4)
{
flag=false;
break;
}
else
{
Console.Write("Invalid Choice..");
}
  
}
  
Console.Write("Total Bill Amount :$"+bill);
}
}
}

/*Kindly let me know if you face any issue in it.*/