I can't figure out how to assign the value of the item to a variable and store it to be used later, So i can add it to the other items to give the total of the order.
Please Help!
Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ex6_2 { class Program { static void Main(string[] args) { string userin; char sandwichch; char friesch; char drinkch; int sandwich = 0, fries = 0, drink = 0; double total = 0.0; Console.WriteLine("(a) Big Mac - $3.99 (b) McChicken - $3.99"); Console.WriteLine("(c) Filet-O-Fish - $3.00 (d) No Sandwich"); Console.WriteLine("Please select sandwich: "); userin = Console.ReadLine(); sandwichch = userin[0]; switch (sandwichch) { case 'a': //bigmac sandwich = 3.49; sandwich = Convert.ToInt32(Console.ReadLine()); break; case 'b': //mcchicken sandwich = 3.49; sandwich = Convert.ToInt32(Console.ReadLine()); break; case 'c': //filetofish sandwich = 3.00; sandwich = Convert.ToInt32(Console.ReadLine()); break; case 'd': //nosandwich sandwich = 0.00; sandwich = Convert.ToInt32(Console.ReadLine()); break; default: total = 0.0; Console.WriteLine("Invalid Input"); break; } Console.WriteLine("(a) Large - $2.25 (b) Medium - $1.75 (c) Small - $1.75 (d) No Fries"); Console.WriteLine("Please select fries size: "); userin = Console.ReadLine(); fries = userin[0]; switch (friesch) { case 'a': //large fries = 2.25; fries = Convert.ToInt32(Console.ReadLine()); break; case 'b': //medium fries = 1.75; fries = Convert.ToInt32(Console.ReadLine()); break; case 'c': //small fries = 1.25; fries = Convert.ToInt32(Console.ReadLine()); break; case 'd': //no fries = 0.00; fries = Convert.ToInt32(Console.ReadLine()); break; default: total = 0.0; Console.WriteLine("Invalid Input"); break; } Console.WriteLine("(a) Large - $1.75 (b) Medium - $1.60 (c) Small - $1.30 (d) No Drink"); Console.WriteLine("Please select drink size: "); userin = Console.ReadLine(); drink = userin[0]; switch (drinkch) { case 'a': //large drink = 1.75; drink = Convert.ToInt32(Console.ReadLine()); break; case 'b': //medium drink = 1.60; drink = Convert.ToInt32(Console.ReadLine()); break; case 'c': //small drink = 1.30; drink = Convert.ToInt32(Console.ReadLine()); break; case 'd': //no drink = 0.00; drink = Convert.ToInt32(Console.ReadLine()); break; default: total = 0.0; Console.WriteLine("Invalid Input"); break; } if (sandwich >= 3.00 && fries >= 1.25 && drink >=1.30) { total = sandwich + fries + drink - 0.75; } else { } Console.WriteLine("Your total is: {0:0.0}", total); } } }



LinkBack URL
About LinkBacks


