Answer to Question #309319 in C# for Jade

Question #309319

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. 


1
Expert's answer
2022-03-10T18:07:21-0500

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);
                }
            }
        }

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