Car Rental Program

This is a discussion on Car Rental Program within the C Programming forums, part of the General Programming Boards category; I'm making a car retal program for a friends new business, heres the deal: He has 5 locations, 5 different ...

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    21

    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?

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

  3. #3
    Registered User
    Join Date
    May 2012
    Posts
    21
    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;}

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

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

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21