# Car Rental Program

• 06-18-2012
iamtazb
Car Rental Program
I'm making a car retal program for a friends new business, heres the deal:

He has 5 locations, 5 different type of cars in each, different pricing on all, and different price depending if rented during weekend.

So the program will look like:

Which location 1-5:
Which type of car:
Which weekday:
How many KM driven:

Then the out the following:

Rental Charge: 15.00
Extra Kms Charge: 70.00
Total Charge: 85.00
- Deposit 500.00
Refund: \$415.00

---

So far I'm here,

Code:

```#include <stdio.h> main() {     int location, veh_type, weekday, km, insurance, prev;             printf("Enter Location:");         scanf("%d", &location);         printf("Enter Vehicle Type:");         scanf("%d", &veh_type);         printf("Enter Weekday:");         scanf("%d", &weekday);         printf("Enter Amount of KM Driven:");         scanf("%d", &km);         printf("Enter insurance (1-Yes/0-No):");         scanf("%d", &insurance);         printf("Have you previously rented with US? (1-Yes/0-No):");         scanf("%d", &prev);                                                                    }```
Getting all the information now I don't know where to go from here, case statements, if statements, switch?
• 06-18-2012
Matticus
For starters, create variables for the results.

Then calculate the results based on the user inputs.

If you just want to do this over and over, put the entire thing in a "while()" (or "do-while()") loop, with provisions for the user to exit program (leave the loop).

---

The proper form of the "main()" function should be:

Code:

```int main(void) {     // code     return 0; }```
---

"scanf()" has some nuances that might cause you problems, but I'll leave that as an exercise for later.
• 06-18-2012
iamtazb
Great thanks for the tip.

I have one little compiling error: What is wrong with this statement:

Code:

```                 if (vehicle==1 && peak==1){                 0.50*km+15=price;}                 if (vehicle==1 && peak==0){                 0.50*km+12.50=price;}```
• 06-18-2012
camel-man
price needs to go on the left side.
• 06-18-2012
iamtazb
Quote:

Originally Posted by camel-man
price needs to go on the left side.

perfect!