C++ Programming Code for Rent a Car System

Asked By 20 points N/A Posted on -
qa-featured

You are required to write a program for RENT A CAR SYSTEM. The basic idea is that user will provide customer information, Car Model, and number of days. Upon this information your program will calculate the Amount for the Car.

Rent Amount will be calculated on the Basis of Type of Model he / she is going to take on Rent and of Days on Rent. There are Types of Models available “2009”, “2010” and “2011”. For Model 2009 Minimum Rent per day is Rs. 5000/- for Model “2010” Amount is Rs. 8000/- and for “2011” Amount is Rs. 10,000/- Per Day.

Detailed Description:

1. The program should display

Please provide customer Name:

Please provide Car Model.

Enter ‘A’ for Model 2009.

Enter ‘B’ for Model 2010.

Enter ‘C’ for Model 2011.

Then your program should take these inputs,

2. Depending upon the choices that user has entered, your program will further display the prompt

3. If user has entered Car Model, then your program should prompt the user to enter the Car Number and No. of Days for which car is required.

—————————————————————–

Model Name :

Number of Days:

—————————————————————–

4. After getting all this information, now write a function which will calculate rental/charged amount on the basis of this information.

To calculate rental/charged amount we will use this formula:

Rental Amount = charged amount * number of days

Charged amount will be different for different Car Models as described above.

After calculating Rent Amount forCar display it on the screen.

SHARE
Best Answer by James20
Best Answer
Best Answer
Answered By 5 points N/A #95961

C++ Programming Code for Rent a Car System

qa-featured

usingnamespace std;
#include<iostream>


main()

{
     
      int days;
      int Rent_amount;
      char carNo[10]; // chracter sting
      char cust_name[20];  // chracter string
     
char model;  // to be used for car model selection choice


      int calc_rent(char, int); // Rent Amount calculation Function

      cout<<"Please provide cumstomer Namet";
      cin>>cust_name;
      cout<<"nPlease provide Car Model"<<endl;
      cout<<"tEnter 'A' for Model 2009.nt Eenter 'B' for Model 2010nt Enter 'C' for Model 2011n";
      cin>>model;
     
      cout<<"Please enter car Number = t";
      cin>>carNo;
      cout<<"Please enter Number of days = t";
      cin >> days;


      // Switch structure for options selection
      switch(model)
      {
           case 'A':
           case 'a':
                      cout<<"nntCustomer Name:" <<cust_name;
                      cout<<"ntCar Model:2009";
                      cout<<"ntCar No:"<<carNo;
                      cout<<"ntNumber of days:"<<days;
                      Rent_amount = calc_rent(model, days);
                      cout << "ntYour Rental Amaount is:"<<Rent_amount<< endl;
           break;

           case 'B':
           case 'b':
                      cout<<"nntCustomer Name:" <<cust_name;
                      cout<<"ntCar Model:2010";
                      cout<<"ntCar No:"<<carNo;
                      cout<<"ntNumber of days:"<<days;
                      Rent_amount = calc_rent(model, days);
                      cout << "ntYour Rental Amaount is:"<<Rent_amount<< endl;
           break;
          
           case 'C':
           case 'c':
                      cout<<"nntCustomer Name:" <<cust_name;
                      cout<<"ntCar Model:2011";
                      cout<<"ntCar No:"<<carNo;
                      cout<<"ntNumber of days:"<<days;
                      Rent_amount = calc_rent(model, days);
                      cout << "ntYour Rental Amaount is:"<<Rent_amount<< endl;
           break;
          
           default:
                   cout<<"Please Enter Correct Model Name using A to C n";
           }

      system("pause"); // causes the prompt to pause
      }
    
int calc_rent(char model, int days) // Rent Calculation Function 
{
    if(model == 'A' || model == 'a')
    return (5000 * days);
   
    else if(model == 'B' || model == 'b')
    return (8000 * days);
       
    else if(model == 'C' || model == 'c')
    return (10000 * days);
    }
 

Answered By 10 points N/A #95962

C++ Programming Code for Rent a Car System

qa-featured

#include<conio.h>
#include<stdio.h>
#include <iostream.h>
#include <cstdlib.h>

void main(void)
{
        string customername;
    string carmodel;
    string carnumber;
    
    int days=0,rentalfee=0;
cout<<"============================================================"<<endl;
cout<<"nttttWELCOME RENT A CAR SYSTEM n";
cout<<"============================================================"<<endl;

    cout << "nPlease provide customer Name: ";
    cin >> customername;
    cout<<endl;

    do
    {
        cout << "nPlease provide Car Model Description"<<endl;
        cout<<"Enter ‘1’ for Model 2009."<<endl;
        cout<<"Enter ‘2’ for Model 2010."<<endl;
        cout<<"Enter ‘3’ for Model 2011."<<endl;
        cout<<endl;
        cout<<"Car Model Description: ";
        cin >>carmodel;
        cout<<endl;
    

if(carmodel !="A" && carmodel !="B" &&  carmodel !="B" )
     
      cout<<"Invaild Car Model. Please try again!"<<endl;
        }

while(carmodel !="A" && carmodel !="B" &&  carmodel !="C" );

    cout << "Please provide following information: "<<endl;
    cout <<"=============================="<<endl;
    cout<<"Car No. : ";
    cin >> carnumber;
    cout<<"Number of day’s : ";
    cin >> days;
    cout<<endl;

    
    if(carmodel == "A"||carmodel=="a")
    rentalfee=days*5000;
    if(carmodel == "B" ||carmodel=="b")
    rentalfee=days*8000;
    if(carmodel == "C" ||carmodel=="c")
    rentalfee=days*10000;

clrscr();    

    cout << "=============================================="<<endl;
    cout<<"nttttRANT A CAR SYSTEM                         "<<endl;
    cout << "Customer Name: "+customername<<endl;
    cout << "Car Model : "+carmodel<<endl;
    cout << "Car No. : "+carnumber<<endl;
    cout << "Number of days: "<< days<<endl;
    cout << "Your Rental Amount is: "<<rentalfee<<endl;
    cout << "============================================="<<endl;

getch();

}

Related Questions