Celebs car hire company has a range of cars for rent. Charges start at £20 a day for the cheapest to £70 a day for the most expensive. The company requires a program that gives customers printed details of charges. The program asks the user for a car make, model and daily rate1 then displays a table of daily charges for between one and fourteen days.
Here is the program:
static void Main(string[] args)
{
string carmake;
string model;
int dailyrate;
int dailycharges = 0;
Console.WriteLine("Enter car make:");
carmake = Console.ReadLine();
Console.WriteLine("Enter car model: ");
model = Console.ReadLine();
Console.WriteLine("Enter daily rate:");
dailyrate = Int32.Parse(Console.ReadLine());
if(dailyrate < 20 || dailyrate > 70)
{
Console.WriteLine("Error!The daily rate is too low or exceeds the price of the fare!");
}
else
{
for(int day = 1; day <= 14; day++ )
{
dailycharges += dailyrate;
Console.WriteLine("Car make - " + carmake);
Console.WriteLine("Car model - " + model);
Console.WriteLine("Day - " + day + " " + "Daily charges: " + dailycharges);
}
}
}
Comments
Leave a comment