TS: Basta magpraktis gani ka ug programming, dapat naa jud comments imo mga code para makasabot ka sa dagan sa mga panghitabo sa imo program. That's the best approach para dali raka makasabot. Code indention is also a must.
TS: Basta magpraktis gani ka ug programming, dapat naa jud comments imo mga code para makasabot ka sa dagan sa mga panghitabo sa imo program. That's the best approach para dali raka makasabot. Code indention is also a must.
can be done best by C..much better gani turbo C lng LOL...i would suggest you would go lower down your language from visual to turbo...lesser compilation...daghan ka mdiscover sa lower level lng..
i used turbo C sa una for interface(softwaare manipulated hardware)..
but suggestion lng na ako, if mao lng na ang resources sa inyo skul, ok ra sad..
and i congratulate you for that.. that is the key for ur success..ur r newbie n programming but determined..
another suggestion: dont rely on help mostly..troubleshoot ur prog as far as you could, dats a part of the programmer and 1 thing is the most knowledgeable person sa program is the programmer itself,bsan pa cguro ngkasak2x sinagul na u program, mksabot ghapun ka, bcoz you already had built the algorithm of the program(and i assume gi-intrroduce na ni sa imo teacher/profesor dha sa nu sckul)...
then f wa na gyud ka mhimo, dghan experts dri sa istorya willing to help as ur last resort..![]()
I see, if this is the case, pili lang unsa imo gamitong nga solution. I suggest that you use the solutions given by the other posters (ka2 wala nagGamit og pointers) ky simple ra. Pointers are quite difficult to use especially kung nagkatOn paka.
Anyway, if gusto nimo gamit og pointers see my comment about sa imong first code sa page 2.
Dili mao ang out put sa Time in ug Time out..
coding mao ni
Ang rounded total mahimo nang 3....rounded na cya...#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>
char vtype;
int ehour;
int emin;
int time_hrs, time_min;
int xhour;
int xmin;
int round;
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(){
clrscr();
printf(" Enter Type of Vehicle \n\n C for car \n B for bus \n T for truck\n\n Enter Here: ");
scanf("%c", &vtype);
printf("\n Hour vehicle entered 0-24: ");
scanf("%d",&ehour);
printf(" Min vehicle entered: ");
scanf("%d",&emin);
printf("\n Hour vehicle left 0-24: ");
scanf("%d",&xhour);
printf(" Minuite 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;
if (vtype == 'c' || vtype == 'C')
{
parking_rate = 0.00;
}
else
{
parking_rate = 25.50;
}
if (vtype == 'b' || vtype == 'B')
{
parking_rate = 1.00;
}
else
{
parking_rate = 35.75;
}
if (vtype == 't' || vtype == 'T')
{
parking_rate = 25.00;
}
else
{
parking_rate = 43.40;
}
clrscr();
printf ("\n Vehicle Type: Car or Bus or Truck \n\n TIME-IN: %d:%d \n TIME-OUT: %d:%d \n", vtype, ehour, emin, xhour, xmin);
time_hrs = xhour - ehour;
time_min = emin + xmin;
printf("\n Parking Time: %d:%d",time_hrs,time_min);
if(time_min > 1)
{
printf("\n Rounded Total: %d",round,(time_hrs+1));
}
total_parking_fee = total_hrs * parking_rate;
printf("\n\n\b Total Charge: %.2f",total_parking_fee);
}
pls refer to my last post TS..my suggestions for you..
try debug until mkuha nimu..
based on the example you gave,
murag ni time in ka og 98:10
og ni time out ka og 20:20
then ang parking time nimo 2:50?
tip TS: e test imong program og sakto na inputs, para imong ma calculate kung sakto ba ka, then formulate a solution.
Unsay paagi ini mga master kung gamitan lang ug simple nga walay pointers nga mga methods....
Similar Threads |
|