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:
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);
}
}
}
Comments
Leave a comment