plz help me

Problem Statement: Rent A CAR

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 for Car display it on the screen.




Sample Output



Please provide customer Name: Ahsan

Please provide Car Model Description.

Enter ‘A’ for Model 2009.
Enter ‘B’ for Model 2010.
Enter ‘C’ for Model 2011



Please provide following information:

Car No. : LWQ234
Number of day’s: 3


Final output should be like this:

-----------------------------------------------------------------
Customer Name: Ahsan
Car Model : 2009
Car No. : LWQ234
Number of days: 03
Your Rental Amount is: 15000
-----------------------------------------------------------------



plz plz plz how to code it in c++
pplz helpppppppppp
thanks
is this code is ok
#include <cstdlib>
#include <iostream>


main()
{
printf("A For 2009,B For 2010,C For 2011")<<'\n';
int Number;
int Days;
int Totaldays;
int A,B,C;
A=100;
B=200;
C=300;
std::cout<<"plz input car Modal Number";
std::cin>>Number;
std::cout<<"how many days u need to rent it";
std::cin>>Days;
Totaldays=(Number*Days);
std::cout<<"the rent is: "<<Totaldays;



system("PAUSE");

}
@haseebsarware42: No, no it's not. That code might bring in a 'C-' (no pun) even in a beginner class.

@ OP: What do you have so far?
i m new to c++ but plz help me to sol this problem
The first thing that is wrong is your entry point (main(...)), it should always return an integer to the OS. So it should be declared as int main(...) the elipse is a stand in for an argument if you want.

Mixing "printf(...)" and "std::cout" in the same program might annoy some teachers but there is nothing technically wrong with that. EDIT: This might give the impression that you don't "understand the code". Wiether that's true or not is irrelavent, I've found that very few teachers are willing to change a grade just because you prove them wrong.

You didn't prompt for the users name, or declare a string to hold that data.

The "Number" variable for Model Number of the car should be a string, this is because we are not using it for any math and it contains letters as well as numbers.

"Number" * "Days" will not give you the "Rental_Amount".

The program asks you to check the year of the car to get the amount that it costs per day. This should probably be done in a switch case statement.

That should be a good start. Repost when you have something.
Last edited on
hi now see this pro it is ok but the total amount become wrong

#include <cstdlib>
#include <iostream>


int main()
{
printf("A For 2009,B For 2010,C For 2011")<<'\n';
char Type;
int Days;
int Totaldays;
char A,B,C;
A=100;
B=200;
C=300;
std::cout<<"plz input car Modal Type";
std::cin>>Type;
std::cout<<"how many days u need to rent it";
std::cin>>Days;
Totaldays=(Type*Days);
std::cout<<"the rent is: "<<Totaldays;



system("PAUSE");

}
now every thing is ok except when
1)i write Customer Name like (khan) its jumps to end but if i write Customer Name as (a) it ask me what is car number
2) after all i want to display it like this plz write me the full code
Customer Name: Ahsan
Car Model : 2009
Car No. : LWQ234
Number of days: 03
Your Rental Amount is: 15000
want the last output 2mro is last day
Last edited on
Ok here is the solution for ur problem.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*Author : Toshitaka*/
#include <iostream>
#include <cstdlib>
using namespace std;

int main()
{
    string custname,carmodel,carnum;
    int days=0,rentalfee=0;

    cout << "Please provide customer Name: ";
    cin >> custname;
    cout<<endl;

    do{
    cout << "Please provide Car Model Description"<<endl;
    cout<<"Enter ‘A’ for Model 2009."<<endl;
    cout<<"Enter ‘B’ for Model 2010."<<endl;
    cout<<"Enter ‘C’ 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 Description. Please Re-enter!"<<endl;
    }while(carmodel !="A" && carmodel !="B" &&  carmodel !="C" );

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

    //Calculation Here
    if(carmodel == "A") //2009 $5000 per day
    rentalfee=days*5000;
    if(carmodel == "B")//2010  $8000 per day
    rentalfee=days*8000;
    if(carmodel == "C")//2011  $10000 per day
    rentalfee=days*10000;

    //Clear the Screen :)
    system("CLS");

    cout << "-----------------------------------------------------------------"<<endl;
    cout << "Customer Name: "+custname<<endl;
    cout << "Car Model : "+carmodel<<endl;
    cout << "Car No. : "+carnum<<endl;
    cout << "Number of days: "<< days<<endl;
    cout << "Your Rental Amount is: "<<rentalfee<<endl;
    cout << "-----------------------------------------------------------------"<<endl;



    return 0;
}

Cheers,
Toshitaka
Topic archived. No new replies allowed.