Thread: Car Rental Program

  1. #1
    Registered User
    Join Date
    May 2012

    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,

    #include <stdio.h>
        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?

  2. #2
    Registered User
    Join Date
    Jun 2011
    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:

    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.

  3. #3
    Registered User
    Join Date
    May 2012
    Great thanks for the tip.

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

                    if (vehicle==1 && peak==1){
                    if (vehicle==1 && peak==0){

  4. #4
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Under the moon
    price needs to go on the left side.

  5. #5
    Registered User
    Join Date
    May 2012
    Quote Originally Posted by camel-man View Post
    price needs to go on the left side.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help - Car Rite Rental (extra credit)
    By mmourot in forum C++ Programming
    Replies: 5
    Last Post: 10-13-2011, 07:00 AM
  2. Replies: 13
    Last Post: 11-03-2010, 12:45 PM
  3. Replies: 1
    Last Post: 03-03-2009, 03:47 PM
  4. Replies: 5
    Last Post: 08-16-2007, 11:43 PM
  5. Replies: 18
    Last Post: 11-13-2006, 12:11 PM
Website Security Test