Answer to Question #64445 in C# for ceazer

Question #64445
We want to put at the disposal of a small cheese dairy an algorithm that allows it to calculate the total invoice of a customer, proposing a menu in which all the prices of the products that it owns will be displayed in a menu.
The list of products and the price of each package is shown below:
White cheese: 7000 LL Goat's cheese: 9000 LL
 Cheese with herbs: 12000 LL  Mixed cheese: 13000 LL

Each type of cheese is represented by a letter: ˈWˈ for white cheese, ˈGˈ for Goat’s cheese, ˈHˈ for cheese with herbs and ˈMˈ for the mixed cheese.

Write an algorithm that calculates the total invoice of packages purchased by a customer, using a menu containing the different types of cheese. A customer can purchase multiple packages of the same type or different types. The end of the invoice is indicated by the letter ˈEˈ.
1
Expert's answer
2017-01-10T09:34:12-0500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cheese
{
class Program
{
static void Main(string[] args)
{
string choice;
int sum = 0;
do
{
DisplayMenu();
choice = Console.ReadLine();
switch (choice.ToUpper())
{
case "W":
sum += 7000;
break;
case "G":
sum += 9000;
break;
case "H":
sum += 12000;
break;
case "M":
sum += 13000;
break;
}
} while (choice.ToUpper() != "E");

Console.WriteLine("Total invoice: " + sum);
Console.ReadLine();

}

static void DisplayMenu()
{
Console.WriteLine();
Console.WriteLine("W - White cheese: 7000 LL");
Console.WriteLine("G - Goat's cheese: 9000 LL");
Console.WriteLine("H - Cheese with herbs: 12000 LL");
Console.WriteLine("M - Mixed cheese: 13000 LL");
Console.WriteLine("E - Count invoice");
Console.WriteLine("Type letter according to cheese you want:");
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS