Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. I need help with a program

I need help with a program

Scheduled Pinned Locked Moved C#
saleshelptutorial
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex501
    wrote on last edited by
    #1

    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(" ");

    C D 2 Replies Last reply
    0
    • A Alex501

      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(" ");

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      1 Reply Last reply
      0
      • A Alex501

        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(" ");

        D Offline
        D Offline
        DaveyM69
        wrote on last edited by
        #3

        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

        C 1 Reply Last reply
        0
        • D DaveyM69

          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

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          *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 )

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups