Trouble with program
I’m new to C and seem to be having some problem with my subtracting in “void process” can someone please give me some help?
The problem I have been given to solve is –
“A car hire company calculates the charges for the hire of a car using a standard rate for each mile travelled together with a “wear & tear” surcharge for each complete 1000 miles travelled. Provide a solution which accepts as input the milometer readings at the start and finish of a hire and calculates the total charge for the hire.
Standard rate per mile = £00.42
Surcharge per complete 1000 miles = £10.84”
I’ve attached a picture of the results I get when I run the program also.
Your help would be much appreciated
Chris
Code:
//Car hire
//Chris Chalmers
//19/01/2009
#include<conio.h>
#include<stdio.h>
int miles_before,miles_after;
float rate_per_mile,surcharge,total;
void input()
{
printf("please enter the miles on the clock AFTER rental.");
scanf("%i",&miles_after);
printf("Please enter the miles on the clock BEFORE rental.");
scanf("%i",&miles_before);
}
void process()
{
total=miles_after - miles_before*0.42;
if (rate_per_mile>1000);
{
total+10.84;
}
}
void output()
{
printf("\nThe total charge for your rental is %.2f",total);
}
int main()
{
//clrscr();
input();
process();
output();
getch();
return 0;
}