I need help with a program
-
Hello, I need to write a program that has an output: : 1. The total cost of all the items 2. The total sales tax, which is 8% of the total cost The gratuity (tip). Most people tip either at the 15%, 20%, or 25% level, so tell the user what the 15% tip is, the 20% tip is, and the 25% tip is I wrote everything but I do not know how to add a tip as a 15, 20 and 25 percent, so could someone help me out. class Program { static void Main(string[] args) { // Price of items const decimal PriceOnePizza = 0.95M; const decimal PriceAPairOfHamburger = 2.95M; const decimal PriceOneHotDog = 4.55M; const decimal TaxRate = 0.08M; // 5.75% // Customer personal infoirmation // Unsigned numbers to represent cleaning items uint NumberOfPizza, NumberOfHamburger, NumberOfHotDog; // Each of these sub totals will be used for cleaning items // Values used to process an order decimal TotalOrder, TaxAmount, SalesTotal; Console.WriteLine("-/- Arbys Restaurant -/-"); // Request customer information from the user // Request the quantity of each category of items Console.Write("Number of Pizza: "); string strPizza = Console.ReadLine(); NumberOfPizza = uint.Parse(strPizza); Console.Write("Number of Hamburger: "); string strHamburger = Console.ReadLine(); NumberOfHamburger = uint.Parse(strHamburger); Console.Write("Number of Dresses: "); string strHotDog = Console.ReadLine(); NumberOfHotDog = uint.Parse(strHotDog); // Perform the necessary calculations // Calculate the "temporary" total of the order // Calculate the tax amount using a constant rate TaxAmount = TotalOrder * TaxRate; // Add the tax amount to the total order SalesTotal = TotalOrder + TaxAmount; // Communicate the total to the user... Console.Write("\nThe Total order is: "); Console.WriteLine(SalesTotal); // and request money for the order // Display the receipt Console.WriteLine("===================================="); Console.WriteLine("-/- Arbys Restaurant -/-"); Console.WriteLine("===================================="); Console.Write("Customer: "); Console.WriteLine("------------------------------------"); Console.WriteLine("Item Type Qty Unit/Price Sub-Total"); Console.WriteLine("------------------------------------"); Console.Write("Shirts "); Console.Write(NumberOfPizza); Console.Write(" "); Console.Write(PriceOnePizza); Console.Write(" "); Console.Write(NumberOfHamburger); Console.Write(" ");
-
Hello, I need to write a program that has an output: : 1. The total cost of all the items 2. The total sales tax, which is 8% of the total cost The gratuity (tip). Most people tip either at the 15%, 20%, or 25% level, so tell the user what the 15% tip is, the 20% tip is, and the 25% tip is I wrote everything but I do not know how to add a tip as a 15, 20 and 25 percent, so could someone help me out. class Program { static void Main(string[] args) { // Price of items const decimal PriceOnePizza = 0.95M; const decimal PriceAPairOfHamburger = 2.95M; const decimal PriceOneHotDog = 4.55M; const decimal TaxRate = 0.08M; // 5.75% // Customer personal infoirmation // Unsigned numbers to represent cleaning items uint NumberOfPizza, NumberOfHamburger, NumberOfHotDog; // Each of these sub totals will be used for cleaning items // Values used to process an order decimal TotalOrder, TaxAmount, SalesTotal; Console.WriteLine("-/- Arbys Restaurant -/-"); // Request customer information from the user // Request the quantity of each category of items Console.Write("Number of Pizza: "); string strPizza = Console.ReadLine(); NumberOfPizza = uint.Parse(strPizza); Console.Write("Number of Hamburger: "); string strHamburger = Console.ReadLine(); NumberOfHamburger = uint.Parse(strHamburger); Console.Write("Number of Dresses: "); string strHotDog = Console.ReadLine(); NumberOfHotDog = uint.Parse(strHotDog); // Perform the necessary calculations // Calculate the "temporary" total of the order // Calculate the tax amount using a constant rate TaxAmount = TotalOrder * TaxRate; // Add the tax amount to the total order SalesTotal = TotalOrder + TaxAmount; // Communicate the total to the user... Console.Write("\nThe Total order is: "); Console.WriteLine(SalesTotal); // and request money for the order // Display the receipt Console.WriteLine("===================================="); Console.WriteLine("-/- Arbys Restaurant -/-"); Console.WriteLine("===================================="); Console.Write("Customer: "); Console.WriteLine("------------------------------------"); Console.WriteLine("Item Type Qty Unit/Price Sub-Total"); Console.WriteLine("------------------------------------"); Console.Write("Shirts "); Console.Write(NumberOfPizza); Console.Write(" "); Console.Write(PriceOnePizza); Console.Write(" "); Console.Write(NumberOfHamburger); Console.Write(" ");
It's pretty straightforward. What do you do to calculate 25% ? You have the total, you just need to do the math to work out what 25 % is.
Alex501 wrote:
const decimal TaxRate = 0.08M; // 5.75%
.08 is 8%, not 5.75% - the comment is wrong. You calculate the tip exactly the same way that you calculated the tax.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
Hello, I need to write a program that has an output: : 1. The total cost of all the items 2. The total sales tax, which is 8% of the total cost The gratuity (tip). Most people tip either at the 15%, 20%, or 25% level, so tell the user what the 15% tip is, the 20% tip is, and the 25% tip is I wrote everything but I do not know how to add a tip as a 15, 20 and 25 percent, so could someone help me out. class Program { static void Main(string[] args) { // Price of items const decimal PriceOnePizza = 0.95M; const decimal PriceAPairOfHamburger = 2.95M; const decimal PriceOneHotDog = 4.55M; const decimal TaxRate = 0.08M; // 5.75% // Customer personal infoirmation // Unsigned numbers to represent cleaning items uint NumberOfPizza, NumberOfHamburger, NumberOfHotDog; // Each of these sub totals will be used for cleaning items // Values used to process an order decimal TotalOrder, TaxAmount, SalesTotal; Console.WriteLine("-/- Arbys Restaurant -/-"); // Request customer information from the user // Request the quantity of each category of items Console.Write("Number of Pizza: "); string strPizza = Console.ReadLine(); NumberOfPizza = uint.Parse(strPizza); Console.Write("Number of Hamburger: "); string strHamburger = Console.ReadLine(); NumberOfHamburger = uint.Parse(strHamburger); Console.Write("Number of Dresses: "); string strHotDog = Console.ReadLine(); NumberOfHotDog = uint.Parse(strHotDog); // Perform the necessary calculations // Calculate the "temporary" total of the order // Calculate the tax amount using a constant rate TaxAmount = TotalOrder * TaxRate; // Add the tax amount to the total order SalesTotal = TotalOrder + TaxAmount; // Communicate the total to the user... Console.Write("\nThe Total order is: "); Console.WriteLine(SalesTotal); // and request money for the order // Display the receipt Console.WriteLine("===================================="); Console.WriteLine("-/- Arbys Restaurant -/-"); Console.WriteLine("===================================="); Console.Write("Customer: "); Console.WriteLine("------------------------------------"); Console.WriteLine("Item Type Qty Unit/Price Sub-Total"); Console.WriteLine("------------------------------------"); Console.Write("Shirts "); Console.Write(NumberOfPizza); Console.Write(" "); Console.Write(PriceOnePizza); Console.Write(" "); Console.Write(NumberOfHamburger); Console.Write(" ");
-
You already got
Alex501 wrote:
TaxAmount = TotalOrder * TaxRate;
so obviously you need to do the same but with the various tip percentages you mentioned Edit: Sorry Christian - only saw your reply after posting
*grin* that happens to me all the time.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )