Page 3 of 5 FirstFirst 12345 LastLast
Results 21 to 30 of 49
  1. #21

    Default Re: (Help) Parking Lot C Programming.


    Code:
    //copyright emailroy2002!  FTW!
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <math.h>
    
    char vtype;
    int ehour;
    int emin;
    
    int xhour;
    int xmin;
    
    void getData(void);
    
    int calculate_charges(int *eh, int *em, int *xh, int *xm);
    int get_parking_rates(char vtype, double total_hrs, double totalmins);
    
    int main(void){    
        getData();             
        calculate_charges(&ehour, &emin, &xhour, &xmin);
        getch();
    }
     
    void getData(){
        printf("Enter C for car, B for bus, T for truck: ");
        scanf("%c", &vtype);             
        
        printf("\nHour vehicle entered 0-24: ");    
        scanf("%d", &ehour);
        
        printf("\bMin vehicle entered: ");
        scanf("%d", &emin);         
    
        printf("\nHour vehicle left 0-24: ");
        scanf("%d", &xhour);
        printf("\bMinuite vehicle left: ");
        scanf("%d", &xmin);     
        
    
    }
    
    int calculate_charges(int *eh, int *em, int *xh, int *xm) {
        int start, end, totaltime;    
        double totalmins, total_hrs;
    
        start = (*eh * 60) + (*em);
        end = (*xh * 60) + (*xm);
    
        totaltime = (end - start);
        
        total_hrs =    (totaltime / 60);
        totalmins = ( totaltime % 60 );
        
        if (*eh > 24 || *xh > 24) {
               printf ("\nYour Automobile has been towed away!");      
        } else {
            get_parking_rates(vtype, total_hrs, totalmins);
            }
    }
    
    
    int get_parking_rates(char vtype, double total_hrs, double totalmins) {  
    
          double parking_rate, total_parking_fee;   
          
          //self explainatory (add more calculation for parking here
          if (vtype == 'c') {  parking_rate = 10.50; }  else { parking_rate = 25.50; }
                    
          
          printf ("\nAutomobile type %c  Entered At  %d : %d : Exited at %d : %d \n", vtype, ehour, emin, xhour, xmin);                       
          printf("\n\n\bTotal Parking Time : %f  hours and %f minutes " , total_hrs, totalmins  );
          
          total_parking_fee =  total_hrs * parking_rate;
          
          printf("\n\n\bTotal Parking charge %f" ,  total_parking_fee);
    }
    
    
    
    
    //copyright emailroy2002!

    kung nahan dyud ka e pointer2x butangan ra ing ani hehe, pa char2x
    butangi lang na sa mga rates bai.


    ikaw na sad bahala sa parking rates wa nako gi tanaw imong rates.
    Last edited by emailroy2002; 02-08-2012 at 01:31 AM.

  2. #22

    Default Re: (Help) Parking Lot C Programming.

    Code:
    //copyright emailroy2002!  FTW!
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <math.h>
    
    void getData(char &vtype, int &ehour, int &emin, int &xhour, int &xmin);
    void calculate_charges(int &eh, int &em, int &xh, int &xm);
    void get_parking_rates(char vtype, double total_hrs, double totalmins);
    
    int main(void)
    {    
        char vtype;
    
        int ehour;
        int emin;
        int xhour;
        int xmin;
    
        getData(vtype, ehour, emin, xhour, xmin);             
        calculate_charges(ehour, emin, xhour, xmin);
        getch();
    
        return 0;
    }
     
    void getData(char &vtype, int &ehour, int &emin, int &xhour, int &xmin) 
    {
        printf("Enter C for car, B for bus, T for truck: ");
        scanf("%c", &vtype);             
        
        printf("\nHour vehicle entered 0-24: ");    
        scanf("%d", &ehour);
        
        printf("\bMin vehicle entered: ");
        scanf("%d", &emin);         
    
        printf("\nHour vehicle left 0-24: ");
        scanf("%d", &xhour);
    
        printf("\bMinuite vehicle left: ");
        scanf("%d", &xmin);     
    }
    
    void calculate_charges(int &eh, int &em, int &xh, int &xm) 
    {
        int start;
        int end; 
        int totaltime;    
        double totalmins;
        double total_hrs;
    
        start = (eh * 60) + em;
        end = (xh * 60) + xm;
    
        totaltime = (end - start);
        
        total_hrs =    (totaltime / 60);
        totalmins = ( totaltime % 60 );
        
        if (eh > 24 || xh > 24) {
               printf ("\nYour Automobile has been towed away!");      
        } else {
            get_parking_rates(vtype, total_hrs, totalmins);
            }
    }
    
    
    void get_parking_rates(char vtype, double total_hrs, double totalmins) {  
    
          double parking_rate;
         double total_parking_fee;   
          
          //self explainatory (add more calculation for parking here
          if (vtype == 'c') {  
               parking_rate = 10.50; 
          }  else { 
               parking_rate = 25.50; 
          }
                    
          printf ("\nAutomobile type %c  Entered At  %d : %d : Exited at %d : %d \n", vtype, ehour, emin, xhour, xmin);                       
          printf("\n\n\bTotal Parking Time : %f  hours and %f minutes " , total_hrs, totalmins  );
          
          total_parking_fee =  total_hrs * parking_rate;
          
          printf("\n\n\bTotal Parking charge %f" ,  total_parking_fee);
    }
    
    
    
    
    //copyright emailroy2002!
    pwede sad ing.ani para ma-eliminate nimo ang katong '*' para sa pointers. btw, kinupya ra nako na gikan ni emailroy. Dili na nimo needed mag sige ug butang ug '*' if magtawag ka sulod sa function. then inig pass nimo dili na sad needed ang '&' nga sign.

  3. #23

    Default Re: (Help) Parking Lot C Programming.

    ^ sakto mas sayon pud kang moodsey211, wa nay global variables.


    naa koy gi edit gamay pud sa iyahang code, mao ning outcome sa ubos. rates nalang kuwang ani.



    Code:
    //copyright emailroy2002!  FTW!
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <math.h>
    
    void getData(char &vtype, int &ehour, int &emin, int &xhour, int &xmin);
    void calculate_charges(char &vtype, int &eh, int &em, int &xh, int &xm);
    void get_parking_rates(char vtype, double total_hrs, double totalmins);
    
    int main(void)
    {    
        char vtype;
    
        int ehour;
        int emin;
        int xhour;
        int xmin;
    
        getData(vtype, ehour, emin, xhour, xmin);             
        calculate_charges(vtype, ehour, emin, xhour, xmin);
        getch();
    
        return 0;
    }
     
    void getData(char &vtype, int &ehour, int &emin, int &xhour, int &xmin) 
    {
        printf("Enter C for car, B for bus, T for truck: ");
        scanf("%c", &vtype);             
        
        printf("\nHour vehicle entered 0-24: ");    
        scanf("%d", &ehour);
        
        printf("\bMin vehicle entered: ");
        scanf("%d", &emin);         
    
        printf("\nHour vehicle left 0-24: ");
        scanf("%d", &xhour);
    
        printf("\bMinuite vehicle left: ");
        scanf("%d", &xmin);     
    }
    
    void calculate_charges(char &vtype, int &eh, int &em, int &xh, int &xm) 
    {
        int start;
        int end; 
        int totaltime;    
        double totalmins;
        double total_hrs;
    
        start = (eh * 60) + em;
        end = (xh * 60) + xm;
    
        totaltime = (end - start);
        
        total_hrs =    (totaltime / 60);
        totalmins = ( totaltime % 60 );
        
        if (eh > 24 || xh > 24) {
               printf ("\nYour Automobile has been towed away!");      
        } else {
            printf ("\nAutomobile type %c  Entered At  %d : %d : Exited at %d : %d \n", vtype, eh, em, xh, xm);                    
            get_parking_rates(vtype, total_hrs, totalmins);
        }
            
    
    }
    
    
    void get_parking_rates(char vtype, double total_hrs, double totalmins) {  
    
          double parking_rate;
         double total_parking_fee;   
          
          //self explainatory (add more calculation for parking here
          if (vtype == 'c') {  
               parking_rate = 10.50; 
          }  else { 
               parking_rate = 25.50; 
          }
                    
          //printf ("\nAutomobile type %c  Entered At  %d : %d : Exited at %d : %d \n", vtype, ehour, emin, xhour, xmin);                       
          printf("\n\n\bTotal Parking Time : %f  hours and %f minutes " , total_hrs, totalmins  );
          
          total_parking_fee =  total_hrs * parking_rate;
          
          printf("\n\n\bTotal Parking charge %f" ,  total_parking_fee);
    }
    Last edited by emailroy2002; 02-08-2012 at 02:27 PM.

  4. #24

    Default Re: (Help) Parking Lot C Programming.

    the program design itself needs no pointers..

    pointers design or more applicable for database programming..

  5. #25

    Default Re: (Help) Parking Lot C Programming.

    But lets hear it from TS if it is ok not to use pointers. Because, what if that is a school exercise and they are required to use a pointer?

  6. #26

    Default Re: (Help) Parking Lot C Programming.

    sori TS..

    bitaw, kng need gyud ug pointers ky mao ang exercise sa scul, i thnk da problem nimu sa imo giingun is ang value communication/assignments nimu..

    try assign value manually, then check if sakto ba ang output..basin sa declaring of variables raka nsayop..

    additional advice(same sa previous post): organize ur program(sa bisaya pa ibalay2x TS arun mkita nimu unsa problem dayun).

  7. #27

    Default Re: (Help) Parking Lot C Programming.

    Mga master salamat kaayo sa inyong tabang..... Baguhan pa jud ko ini nga programming kay 1st year pako sa UC wala jud koy alamag...ining C programming once again salamat sa inyong presensya....tiguwang nako ni iskwela ug programming.....

  8. #28

    Default Re: (Help) Parking Lot C Programming.

    ang kini nga problem mga master dipindi ra sa estudyante kung unsaon niya pag sulbad ang exercise kamo mga master kung kamo ang pa solvon unsa mga mga coding inyo gamiton.. nga ing ini ang output:

    Type of Vehicle: Car or Bus or Truck

    TIME-IN xxx A/P/N/M (Ang A - am, P - pm, N - Noon ug ang M - Midnight)
    TIME-OUT xxx

    PARKING TIME XX:XX
    ROUNDED TOTAL XX:XX (kung ang minute naay value e round off na niya ngadto sa oras bali e add na siya).


    TOTAL CHARGE Php XX.XX


    Compiler Gamit: DL: http://www.mediafire.com/?3ezxc741z8ya8cf
    password: power

    Thanks............

  9. #29

    Default Re: (Help) Parking Lot C Programming.

    Quote Originally Posted by emailroy2002 View Post
    ^ sakto mas sayon pud kang moodsey211, wa nay global variables.


    naa koy gi edit gamay pud sa iyahang code, mao ning outcome sa ubos. rates nalang kuwang ani.



    Code:
    //copyright emailroy2002!  FTW!
    
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <math.h>
    
    void getData(char &vtype, int &ehour, int &emin, int &xhour, int &xmin);
    void calculate_charges(char &vtype, int &eh, int &em, int &xh, int &xm);
    void get_parking_rates(char vtype, double total_hrs, double totalmins);
    
    int main(void)
    {    
        char vtype;
    
        int ehour;
        int emin;
        int xhour;
        int xmin;
    
        getData(vtype, ehour, emin, xhour, xmin);             
        calculate_charges(vtype, ehour, emin, xhour, xmin);
        getch();
    
        return 0;
    }
     
    void getData(char &vtype, int &ehour, int &emin, int &xhour, int &xmin) 
    {
        printf("Enter C for car, B for bus, T for truck: ");
        scanf("%c", &vtype);             
        
        printf("\nHour vehicle entered 0-24: ");    
        scanf("%d", &ehour);
        
        printf("\bMin vehicle entered: ");
        scanf("%d", &emin);         
    
        printf("\nHour vehicle left 0-24: ");
        scanf("%d", &xhour);
    
        printf("\bMinuite vehicle left: ");
        scanf("%d", &xmin);     
    }
    
    void calculate_charges(char &vtype, int &eh, int &em, int &xh, int &xm) 
    {
        int start;
        int end; 
        int totaltime;    
        double totalmins;
        double total_hrs;
    
        start = (eh * 60) + em;
        end = (xh * 60) + xm;
    
        totaltime = (end - start);
        
        total_hrs =    (totaltime / 60);
        totalmins = ( totaltime % 60 );
        
        if (eh > 24 || xh > 24) {
               printf ("\nYour Automobile has been towed away!");      
        } else {
            printf ("\nAutomobile type %c  Entered At  %d : %d : Exited at %d : %d \n", vtype, eh, em, xh, xm);                    
            get_parking_rates(vtype, total_hrs, totalmins);
        }
            
    
    }
    
    
    void get_parking_rates(char vtype, double total_hrs, double totalmins) {  
    
          double parking_rate;
         double total_parking_fee;   
          
          //self explainatory (add more calculation for parking here
          if (vtype == 'c') {  
               parking_rate = 10.50; 
          }  else { 
               parking_rate = 25.50; 
          }
                    
          //printf ("\nAutomobile type %c  Entered At  %d : %d : Exited at %d : %d \n", vtype, ehour, emin, xhour, xmin);                       
          printf("\n\n\bTotal Parking Time : %f  hours and %f minutes " , total_hrs, totalmins  );
          
          total_parking_fee =  total_hrs * parking_rate;
          
          printf("\n\n\bTotal Parking charge %f" ,  total_parking_fee);
    }
    Deceleration Syntax Error......... Siya master pag compile nako......

  10. #30

    Default Re: (Help) Parking Lot C Programming.

    Quote Originally Posted by Maikeru View Post
    But lets hear it from TS if it is ok not to use pointers. Because, what if that is a school exercise and they are required to use a pointer?
    Ok ra master bisan unsa man nga paagi ang pwede gamiton ining among exercise..... Thanks sa imo pangutana...

  11.    Advertisement

Page 3 of 5 FirstFirst 12345 LastLast

Similar Threads

 
  1. C/C++ i need help in making a program
    By mE_bytes in forum Programming
    Replies: 54
    Last Post: 07-30-2008, 05:41 PM
  2. Need help in Installing Java programs in my Samsung D880
    By Soj in forum Software & Games (Old)
    Replies: 0
    Last Post: 04-24-2008, 06:34 PM
  3. Replies: 12
    Last Post: 04-17-2008, 04:48 PM
  4. Replies: 10
    Last Post: 03-06-2008, 05:26 AM
  5. NEED HELP ON ACCESS-based programming
    By recanada in forum Programming
    Replies: 1
    Last Post: 04-26-2006, 05:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top