InternetLite Corporation is an Internet Service Provider tha
InternetLite Corporation is an Internet Service Provider that charges customers a flat rate of $7.99 for up to 10 hours of connection time. Additional hours or partial hours are charged at $1.99 each.
a. Write a second function named round_money that takes a real number as an input argument and returns as the function value the number rounded to two decimal places after the decimal point.
b. Write a function named charges that computes the total charge for a customer based on the number of hours of connection time used in a month. The function also calculates the average cost per hour of the time used (round to the nearest cent). You must use two output parameters to send back these two results. These two results must be rounded to two decimal places after the decimal point using the function round_money that you define.
c. Write a main function that prompts the user to enter the customer usage data as a sequence of customer id and hours-used, reads those data, calculates the charges of each customer, and prints each customer’s id, hours used, total charge, and average cost per hour. Use a sentinel value to terminate the input of customer usage data. The output must be printed like a table format.
Sample run:
Please enter each customer’s id, and hours used. Enter -1 when you are done.
15362 4.2
42768 11.1
11111 9.9
-1
Here are the customer usage charges:
Customer Hours Used Total Charge Average Cost Per Hour
15362 4.2 7.99 1.90
42768 11.1 11.97 1.08
11111 9.9 7.99 0.81
Please use C program code to solve the problem only.
Solution
#include <stdio.h>
int main(void)
{
while (1)
{
int a;
float b;
//Please insert the customer ID and Hours used
scanf( \"%i %f\", &a, &b);
if (a == -1){
printf(\"-1\");
break;
}
else{
//if less than 10
if (b <= 10) {
printf(\"You entered: %i %.2f %.2f %.2f\ \", a, b , 7.99 , 7.99/b);
}
//if more than 10
else{
float cost = 7.99 + (b-10)*1.99;
printf(\"You entered: %i %.2f %.2f %.2f\ \", a, b , cost , cost/b);
}
}
printf(\"You entered: %i %.2f\ \", a, b);
// return 0;
}
}

