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");
Comments
Leave a comment