- 3

# If & else

A variety store give a 15% discount on sales totalling \$300 or more. Write a C# program to request the cost of 3 items and print the amount the customer must pay.

7th Feb 2019, 4:55 AM
Glody Bokungu
+ 3
First, this is not a question. Secondly, you have answered it yourself. Please remove it. https://www.sololearn.com/discuss/1316935/?ref=app
7th Feb 2019, 6:57 AM
Rowsej
+ 1
The message in console.write should be updated as second and third
7th Feb 2019, 1:11 PM
Gordon
+ 1
Because your multiply 0.15 so the finalPrice may have four decimal places. Convert to double again before displaying the final result.
7th Feb 2019, 1:14 PM
Gordon
0
static void Main(string[] args) { double item1Price, item2Price, item3Price; double totalPrice,finalPrice; //Input Console.Write("Please enter the price of the first item:"); item1Price = Convert.ToDouble(Console.ReadLine()); Console.Write("Please enter the price of the first item:"); item2Price = Convert.ToDouble(Console.ReadLine()); Console.Write("Please enter the price of the first item:"); item3Price = Convert.ToDouble(Console.ReadLine()); //Processing totalPrice = item1Price + item2Price + item3Price; if (totalPrice >= 300) { finalPrice =totalPrice - (0.15 * totalPrice); } else { finalPrice = totalPrice; } //OutPut Console.WriteLine("Final Price:{0:c}", finalPrice); Console.ReadKey(); }
7th Feb 2019, 4:56 AM
Glody Bokungu
Hot today
HELP ME