In: Computer Science
reate a C# program.
-Create 5 variables as decimals: Count, pricce, subtotal, tax, and
total
-Use a do while loop. If the price is not -1, the loop
continues.
Show count number (ie: Item 1, Item 2, Item 3...)
Enter price
Get subtotal
Increase count
-Calculate tax(0.035%) and total
Show total count, subtotal, tax,and total
Output:
Item1: $2.00
Item2:: $3.00
Item3: $1.00
Item4: $-2 (Note: A negative number will not be substracted. It will only be ignored)
There are 3 Items in this order (This is the total count)
Subtotal: $6.00
Tax 0.035: $0.21
Total: $6.21
using System.IO;using System;
class Program
{
static void Main(string[] args)
{
int a=-1; double count=0;double price=-1; double subtotal=0; double
tax=0;double total=0;
do
{
if(price >0){
Console.WriteLine("value of a: {0:R}", price);
count=count+1;total=total+1;
}
string temp;int temp2;
Console.WriteLine("Enter item {0:R}", count+1);;
temp = System.Console.ReadLine();
if (double.TryParse(temp, out price))
price = price;
}
while (price > -1);
Console.WriteLine("Total items {0:R}", count);
Console.WriteLine("Total price of items {0:R}", total);
tax=total*10;
Console.WriteLine("Tax of all items(10% assumed) {0:R}",tax
);
subtotal=total+tax;
Console.WriteLine("Sub total of all items {0:R}", subtotal);
}
}