Hi Please help me write the following program in C I will be
Hi!!
Please help me write the following program in C. I will be comparing my program with that what is posted, so please include comments and descriptions of the important parts of the program. Thank you!
Code a program to calculate internet streaming charges according with a bandwidth rate schedule.
The rate schedule is as follows:
$0.15 per GB for the first 30 GB
$0.16 per GB for the next 30 GB (up to 60 GB)
$0.13 per GB for the next 40 GB (up to 100 GB)
$0.11 per GB for all bandwidth over 100 GB
Requirements
1) Your code must use these three functions (in addition to main):
a) get_data – This function prompts the user for an account number (integer) and a GB value (integer). It passes these values back to the calling module via two output parameters.
b) compute_charge – This function computes the charge based on the above rate schedule. It uses one input parameter (GB value as an integer) and a return value (amount of the charge, which may include decimals).
c) print_results – This function displays the output (the account number, the GB value, and the total charge). The output is passed to the function via three input parameters. The total charge must display with two decimal places.
2) You must use a conditional loop that prompts the user to enter a Y or an N to indicate if they wish to continue adding more input. When the loop ends, print the totals as displayed in the sample run. Your code must be able to handle a lowercase or uppercase Y or N
Solution
#include <stdio.h> // standard input output
int get_data();
int compute_charge();
//void print_results();
main(){
get_data();
compute_charge();
print_results();
getchar();
getchar();
}
int get_data(){
int account_number,GB_value;
printf(\"Enter Account number:\");
scanf(\"%d\",&account_number);
printf(\"Enter GB_Value:\");
scanf(\"%d\",&GB_value);
return account_number,GB_value;
}
int compute_charge(){
int GB_value;
float charge;
printf(\"Enter GB_Value:\");
scanf(\"%d\",&GB_value);
if(GB_value>=100){
charge=GB_value*0.11;
//printf(\"amount of the charge $%.2f\",charge);
}else if(GB_value>60 && GB_value<100){
//printf(\"less than 100 greater than 60\ \");
charge=GB_value*0.13;
//printf(\"amount of the charge $%.2f\",charge);
}
else if(GB_value>30 && GB_value<60){
//printf(\"less than 60 greater than 30\ \");
charge=GB_value*0.16;
//printf(\"amount of the charge $%.2f\",charge);
}
else if (GB_value<=30){
//printf(\"less than or equal30\ \");
charge=GB_value*0.15;
// printf(\"amount of the charge $%.2f\",charge);
}
return charge;
}
void print_results(){
get_data();
}

