-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lab2Part1.c
33 lines (27 loc) · 1022 Bytes
/
Lab2Part1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//Name : Guozhen Ding (1005760749)
/*
* Lab Submission for APS105H1
* Input : The daily rate and the rental period
* Output : The total charge and days of free by using the given charge method
* Assumption : All the input from the user is vaild
*/
#include <stdio.h>
#define TAX 1.13
#define freeRate 4
int main(int argc, char const *argv[]){
//init the variables
double dailyRate, totalCharge;
int rentDays, paidCircles;
//Get input from the user
printf("Enter the daily rate: ");
scanf("%lf",&dailyRate);
printf("Enter the rental period (in days): \n");
scanf("%d",&rentDays);
//Do the calculations
paidCircles = rentDays / freeRate;
totalCharge = TAX*(paidCircles * (freeRate-1) * dailyRate + ( rentDays % freeRate ) * dailyRate);
//Output the result
printf("Your total free day(s) in this rental is: %d\n",paidCircles);
printf("The total charge including taxes is: %.2lf\n",totalCharge);
return 0;
}