Thread: project .... help plz plz plz

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    9

    project .... help plz plz plz

    I'm in college and I have to do a project and i couldn't do it.

    Create a program which deals with Car Rental Services. You can base your program on the following menu

    Code:
    *******************************************************
    
    WELCOME TO MYCAR RENTAL SYSTEM
    
    *******************************************************
    
    [A] ADD CAR RENTAL INFORMATION
    
    [D] DELETE CAR RENTAL INFORMATION
    
    [V] VIEW CAR RENTAL INFORMATION
    
    [I] INCREASE RENTING RATE
    
    [P] VIEW RENTAL SERVICE RECEIPT
    
    [Q] QUIT RENTAL SYSTEM
    
    *******************************************************
    Could someone help me please

  2. #2
    Registered User Swarvy's Avatar
    Join Date
    Apr 2008
    Location
    United Kingdom
    Posts
    195
    Show us what code you have written so far for this program.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Welcome to the forum, Hitchhik3R!

    Maybe call a menu() function from main, print the menu choices, and have a switch statement to handle each choice. menu function has everything in a big do while(choice != 0) loop, so it keeps coming back to the menu for another choice for the user.

    Post up some code, and show us you're serious.

  4. #4
    Registered User
    Join Date
    Oct 2010
    Posts
    9
    Adak
    trust me im serious ... if i couldnt find how to do it i will loss 20%

    Swarvy

    I didn't writ anything at all coz in the whole semester we didn't study anything like that

    and the lecturer said we will not find the way in the notes so we have to search in the internet

    I will show u what did we study

    examples:

    1
    Code:
    #include<stdio.h>
    main ( )
    {
    int age=44,workexp=5;
    float salary=1800.00;
    char gender='M';
    
    printf("Ali's age is %d\n",age);
    printf("He has %d years working experience\n",workexp);
    printf("He is earning RM %.2f this month\n",salary);
    printf("His gender code is %c",gender);
    
    return 0;
    }
    2
    Code:
    #include<stdio.h>
    main()
    {
    int x=-4443;
    float y=554.21;
    char c='M';
    
    printf("The value of integer variable x is %d",x);
    printf("\nThe value of float variable y is %f",y);
    printf("\nThe value of character variable c is %c",c);
    return 0;
    }
    3
    Code:
    #include<stdio.h>
    main()
    {
    int x=-4443;
    float y=554.21;
    
    
    printf("x is %d and y is %f",x,y);
    printf("\n==> c is M Thank you");
    
    return 0;
    }
    4
    Code:
    #include<stdio.h>
    main()
    {
    char n[10];
    char p[20];
    char m[11];
    int s;
    float g;
    
    printf("Enter your name           :");
    scanf("%s",&n);
    printf("Enter your matric no      :");
    scanf("%s",&m);
    printf("Enter your semester       :");
    scanf("%d",s);
    printf("Enter your program        :");
    scanf("%s",&p);
    printf("\nEnter your subject 1 grade point      :");
    printf("\nEnter your subject 1 credit           :");
    printf("\nEnter your subject 2 grade point      :");
    printf("\nEnter your subject 2 credit           :");
    printf("\nEnter your subject 3 grade point      :");
    printf("\nEnter your subject 3 credit           :");
    printf("\nEnter your subject 4 grade point      :");
    printf("\nEnter your subject 4 credit           :");
    printf("\nEnter your subject 5 grade point      :");
    printf("\nEnter your subject 5 credit           :");
    printf("\nEnter your subject 6 grade point      :");
    printf("\nEnter your subject 6 credit           :");
    printf("\nEnter your subject 7 grade point      :");
    printf("\nEnter your subject 7 credit           :");
    
    printf("\n**************************************************");
    printf("\n\t\tExam Result Slip");
    printf("\n\t\t    Semester");
    printf("\n\t  Diploma In Civil Engineering");
    printf("\n--------------------------------------------------");
    printf("\nA");
    printf("\n--------------------------------------------------");
    printf("\nTotal credits   :");
    printf("\nGPA             :");
    printf("\n**************************************************");
    
    
    return 0;
    }
    5
    Code:
    #include<stdio.h>
    main()
    {
    float a;
    printf("Monthly Salary    :RM");
    scanf("%f",&a);
    printf("Your Bonus for Year 2005 is RM%.2f",0.75*a);
    return 0;
    }
    6
    Code:
    #include<stdio.h>
    main()
    {
    int s;
    printf("Enter a number:  ");
    scanf("%d",&s);
    printf("\n1 x %d = %d\n",s,1*s);
    printf("2 x %d = %d\n",s,2*s);
    printf("3 x %d = %d\n",s,3*s);
    printf("4 x %d = %d\n",s,4*s);
    printf("5 x %d = %d\n",s,5*s);
    printf("6 x %d = %d\n",s,6*s);
    printf("7 x %d = %d\n",s,7*s);
    printf("8 x %d = %d\n",s,8*s);
    printf("9 x %d = %d\n",s,9*s);
    printf("10 x %d = %d\n",s,10*s);
    printf("11 x %d = %d\n",s,11*s);
    printf("12 x %d = %d",s,12*s);
    return 0;
    }
    7
    Code:
    #include<stdio.h>
    main()
    {
    float a,b;
    printf("**Kentucky Restaurant**");
    printf("\n\nTotal Amount    :RM");
    scanf("%f",&a);
    printf("Paid Amount     :RM");
    scanf("%f",&b);
    printf("Balance         :RM%.2f\n",b-a);
    printf("\n   **Thank you**");
    printf("\n   Welcome Again");
    return 0;
    }
    8
    Code:
    #include<stdio.h>
    main()
    {
    char z,d[12];
    int n,r;
    float f;
    printf("Enter unite letter          :");
    scanf("%c",&z);
    printf("Enter item number           :");
    scanf("%d",&n);
    printf("Enter item price            :");
    scanf("%f",&f);
    printf("Enter number of units sold  :");
    scanf("%d",&r);
    printf("Enter purchase date         :");
    scanf("%s",d);
    printf("\nUnit     Itme    Total Purchase   Purchase Date");
    printf("\n----     ----    --------------   -------------");
    printf("\n%c",z);
    printf("\t  %d",n);
    printf("\t     $%.2f",f*r);
    printf("\t   %s",d);
    return 0;
    }
    9
    Code:
    #include<stdio.h>
    main()
    {
    int a[15],b,c,d,h;
    float e,f,g;
    char z;
    printf("*PUAS SDN BHD*\n");
    
    printf("\nMonth          :");
    scanf("%s",&a);
    printf("\nMeter Reading  :-");
    printf("\nPrevious       :");
    scanf("%d",&c);
    printf("\nCurrent        :");
    scanf("%d",&d-c);
    printf("\nMonthly Bill Charge for July 2005 :RM%.2f");
    scanf("%f",&e);
    printf("Previous Bill  :RM%.2f");
    scanf("%f",&f);
    printf("\nTotal Charge:RM");
    scanf("%f",&g);
    
    return 0;

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    OK, well - hint, hint, << read between the lines a bit >>

    Maybe call a menu() function from main, print the menu choices, and have a switch statement to handle each choice. menu function has everything in a big do while(choice != 0) loop, so it keeps coming back to the menu for another choice for the user.

    Post up some code, and show us you're serious.
    Remove the "maybe" and post up THAT code, for starters.

    Oh crap, you don't have any function calls in your classwork yet?

  6. #6
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    So you haven't learnt decision making(if else ) ,loop, function,array?!

  7. #7
    Registered User Swarvy's Avatar
    Join Date
    Apr 2008
    Location
    United Kingdom
    Posts
    195
    There is a fair bit of code there given the scope of the problem.

    Btw, Hitchhik3R, when I made my previous post about posting code I didn't intend any offense. If you took offense then I apologise.

    Anyway, now you have posted code time to get to work. By looking at your code you have learnt how to print things to screen and take in user input but you need to learn about loops, if statements (and switch statements), and functions in order to complete this assignment.

    There are three types of loops, 'while' loops, 'for' loops and 'do-while' loops. You can read up on them here. The 'do-while' loop would probably be the thing you would put your menu function and selection code in since you will definitely be executing this at least once.

    Your basic menu selection could (there is more than one way to skin a cat) look something like this:

    Code:
    int main()
    {
            /* Starting code, maybe do some command line stuff, who knows */
    
           do
           {
                   PrintMenu();
    
                   /* Take user input and assess what to do with it */
            } while( !quit );
           return 0;
    }
    
    void PrintMenu()
    {
             /* Clear the screen */
            /* Put all your printf statements here for printing out the main menu */
    }
    I'll let someone else explain some of the other basics, although I am surprised your lecturer would set such an assignment without giving you the proper tuition. That definitely raises a few questions.

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Ok, so in main() you want to:

    call a function:menu();
    Code:
    void menu(void) {
      char choice;
      double rate;   //what's the starting rate?
    
      do  loop
        which prints your menu choices
        gets your choice.
        scanf("%c", &choice);
        getchar();  //remove the newline char from the keyboard buffer
        takes action based on your choice (including quit the program)
    
        if(choice=='A') {
           //logic to handle choice A, in here    
        }
        else if(choice=='V') {
          logic for choice V
    
    
        }
      //etc. for all the choices on the menu
    
      }while (choice != 'Q')

  9. #9
    Registered User
    Join Date
    Oct 2010
    Posts
    9
    thanx guys for ur help .... i have final exam tomorrow so i will be back after the exam to see ur posts

  10. #10
    Registered User
    Join Date
    Oct 2010
    Posts
    9
    hi guys... sorry i was busy with my final exams... and still have to submit my project

    someone helped me for my project ... but still errors

    this s what i have written so far

    Code:
    #include<stdio.h>
    void addcar(),deletecar(),viewcar(),rate(),viewrental(),quit();
    char name,address,model,plate,licence,date1,date2;
    int ic,contact,day;
    float price;
    
    main()
    {
    char select;
    
    x:
    printf("**********************************************\n");
    printf("\n\tWELCOME TO MYCAR RENTAL SYSTEM\n\n");
    printf("**********************************************\n");
    printf("\n[A] ADD CAR RENTAL INFORMATION ");
    printf("\n[D] DELETE CAR RENTAL INFORMATION ");
    printf("\n[V] VIEW CAR RENTAL INFORMATION ");
    printf("\n[I] INCREASE RENTING RATE");
    printf("\n[P] VIEW RENTAL SYSTEM RECEIPT ");
    printf("\n[Q] QUIT RENTAL SYSTEM \n\n");
    printf("*********************************************\n");
    printf("Select a menu: ");
    scanf("%s",&select);
    
    if(select=='A'||select=='a')
    addcar();
    else
    if(select=='D'||select=='d')
    deletecar();
    if(select=='V'||select=='v')
    viewcar();
    else
    if(select=='I'||select=='i')
    rate();
    else
    if(select=='P'||select=='p')
    viewrental();
    else
    if(select=='Q'||select=='q')
    quit();
    else
    if(select!='Q'||select!='q')
    goto x;
    
    return 0;
    }
    
    void addcar()
    {
    
    printf("Name : ");
    scanf(" %[^\n]",&name);
    printf("IC no: ");
    scanf("%d",&ic);
    printf("Contact no: ");
    scanf("%d",&contact);
    printf("Address no: ");
    scanf(" %[^\n]",&address);
    printf("Car Model : ");
    scanf(" %[^\n]",&model);
    printf("car plate  no: ");
    scanf(" %[^\n]",&plate);
    printf("Licence: ");
    scanf(" %[^\n]",&licence);
    printf("Rental price: ");
    scanf("%f",&price);
    printf("Date rented: ");
    scanf(" %[^\n]",&date1);
    printf("Date reterned  : ");
    scanf(" %[^\n]",&date2);
    
    }
    void deletecar()
    {
    printf("testing");
    }
    void viewcar()
    {
    
    printf("Name : %s\n",name);
    printf("IC no : %d\n",ic);
    printf("Contact no : %d\n",contact);
    printf("Address  : %s\n",address);
    printf("Car model : %s\n",model);
    printf("Car plate no: %s\n",plate);
    printf("Licence no : %s\n",licence);
    printf("Rental price : %.2f\n",price);
    printf("Date rented : %s\n",date1);
    printf("Date returned : %s\n",date2);
    }
    void rate()
    {
    printf("Extra %10 from the rental price will be charged for evey extra rental day\n");
    printf("How many extra day(s): ");
    scanf("%d",&day);
    printf("The total charge is %.2f+ %.2f =%.2f",price,price*0.1,price+(price*0.1));
    
    }
    void viewrental()
    {
    printf("**********************************************\n");
    printf("MYCAR RENTAL\n");
    printf("**********************************************\n");
    printf("Name  : %s\n ",name);
    printf("IC no : %d\n ",ic);
    printf("Contact no : %d\n",contact);
    printf("Address  : %s\n",address);
    printf("Car model : %s\n",model);
    printf("Car plate no: %s\n",plate);
    printf("Licence no : %s\n",licence);
    printf("Rental price : %.2f\n",price);
    printf("Date rented : %s\n",date1);
    printf("Date returned : %s\n",date2);
    printf("Thabnk You!\n");
    printf("Please come again. :)");
    
    }
    void quit()
    {
    printf("testing");
    }
    can someone fix the errors plz?

  11. #11
    Registered User
    Join Date
    Oct 2010
    Posts
    9
    actually there is no errors but when i add the car rental information i cant view them and show me error message

  12. #12
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Oh my goodness... so many problems!
    First off: INDENT. Don't do ANYTHING else until you've indented.

    >>void addcar(),deletecar(),viewcar(),rate(),viewrental() ,quit();
    What is this?

    >>main()
    Where is the return type for main?

    >>char select;
    >>scanf("%s",&select);
    Why do you think this works?

    Why are you using goto?

    And choose a better thread title next time!
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  13. #13
    Registered User
    Join Date
    Oct 2010
    Posts
    9
    Quote Originally Posted by Elysia View Post
    Oh my goodness... so many problems!
    First off: INDENT. Don't do ANYTHING else until you've indented.

    >>void addcar(),deletecar(),viewcar(),rate(),viewrental() ,quit();
    What is this?

    >>main()
    Where is the return type for main?

    >>char select;
    >>scanf("%s",&select);
    Why do you think this works?

    Why are you using goto?

    And choose a better thread title next time!
    i really dont know much... im not the one who did that ... i asked someone to do it and he gave me this code to continue doing the code but i couldnt..

  14. #14
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Then you shouldn't be using the code.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. plz give an idea about this project
    By vpshastry in forum C Programming
    Replies: 1
    Last Post: 11-10-2009, 07:57 AM
  2. I need help with this project plz
    By ice_jr in forum C Programming
    Replies: 1
    Last Post: 11-10-2009, 12:34 AM
  3. Problem Displaying a Struct
    By rockstarpirate in forum C++ Programming
    Replies: 16
    Last Post: 05-05-2008, 09:05 AM
  4. Project - Help Plz
    By Shadow2552 in forum Windows Programming
    Replies: 11
    Last Post: 02-22-2004, 06:22 PM