Answer to Question #304716 in C# for kun

Question #304716

Create a new project, and name it P2T1 Write a program that requests from a user the number of pies (at R18.50 per pie) and the number of hamburgers (at R35.00 per hamburger), and then calculates the total for the order. Now extend this program to request the amount paid by the user, before calculating and displaying the change that needs to be paid out. Ensure that your monetary amounts are displayed with the R currency sign. Your running program could resemble the following:


1
Expert's answer
2022-03-02T03:04:57-0500
using System;

namespace P2T1
{
    class Program
    {
        public static void Main(string[] args)
        {
            double costpies, costhamb, sumcost, pout;
            costpies = 18.50;
            costhamb = 35.00;
            Console.Write("Enter number of pies: ");
            int pies = Convert.ToInt32(Console.ReadLine());
            Console.Write("Enter number of hamburgers: ");
            int hamb = Convert.ToInt32(Console.ReadLine());
            sumcost = (pies * costpies) + (hamb * costhamb);
            Console.WriteLine();
            Console.WriteLine("Amount paid: R{0:f2}", sumcost);
            Console.Write("Enter money R: ");
            double money = Convert.ToDouble(Console.ReadLine());
            pout = money - sumcost;
            Console.WriteLine();
            Console.WriteLine("Amount paid: R{0:f2}", sumcost);
            Console.WriteLine("Paid out: R{0:f2}", pout);
            Console.WriteLine();
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS