Question: #include //for printf, scanf, fprintf, fscanf, fopen, and fclose #include //for tolower function //function prototypes //Function from program 6 void Greeting(); //welcome the user to


#include //for printf, scanf, fprintf, fscanf, fopen, and fclose
#include //for tolower function
//function prototypes
//Function from program 6
void Greeting();
//welcome the user to the gas station app
//Function from program 6
void ViewAndGetSelection(char* selectionPtr);
//input: the user's selection (input/output parameter)
//display the program options and get the users selection
//use an input/output parameter for the selection
//Function from program 6
void ProcessSelection(char selection, double* balancePtr);
//input: the user's selection by copy (input parameter)
//input: the account balance (input/output parameter)
//display a message that the selection has been entered
//display the balance when the user enters 'b'
//allow the user to add money to the account when the user enters 'u'
//complete a purchase when the user enters 'p'
void DisplayGasPrices();
//display the gas choices and related item number
void GetGasChoice(int* itemPtr);
//input: users choice is set by the input/output parameter
void SetGallonPrice(int itemNumber, double* pricePtr);
//input: item number
//input: price is set by the input/output parameter
void CalculateTotal(double pricePerGallon, double* totalPtr);
//input price per gallon
//declare, ask and get the number of gallons
//calculate the total
//input/output parameter for the total
//Function from program 4
double AddMoney(double accountBalance);
//input: amount of money in the account
//displays the amount of money available in the account
//allows the user to add money to the account
//returns the updated balance after the money has been added
//Function from program 4
double CheckForEnoughMoney(double accountBalance, double total);
//input: amount of money in the account and the transaction total
//gets money from the user until the user has enough to make the purchase
//make the purchase and returns the remaining balance
int main()
{
char choiceInMain;
double balanceInMain = 0.00;
//inPtr to read from the file
FILE* inPtr;
//outPtr to write to the file
FILE *outPtr;
//connect to the file
inPtr = fopen("gasAccountBalance.txt", "r");
//get the account balance from the file
//use fscanf
//greet the user - call greeting funciton
//view and get the selection - function call
//change the selection to lower case
//make sure the user did not enter q to quit
while (choiceInMain != 'q')
{
//process the selection
//view and get the next selection
//change the selection to lower case
}
printf(" You have $%.2f left in your account for next time. ", balanceInMain);
printf(" saving the amount in the file . . . ");
outPtr = fopen("gasAccountBalance.txt","w");
fprintf(outPtr, "%f", balanceInMain);
//say goodbye to the user
//close the file pointers
fclose(inPtr);
fclose(outPtr);
// do not forget to return SUCCESS
}
//function definitions
void Greeting()
//welcome the user to the gas station app
{
printf("Welcome to the fuel app ");
printf("We offer convenient gas purchasing ");
}
void ViewAndGetSelection(char* selectionPtr)
//input: the user's selection (input/output parameter)
//display the program options and get the users selection
//use an input/output parameter for the selection
{
}
void ProcessSelection(char selection, double* balancePtr)
//input: the user's selection by copy (input parameter)
//input: the account balance (input/output parameter)
//display a message that the selection has been entered
//display the balance when the user enters 'b'
//allow the user to add money to the account when the user enters 'u'
//complete a purchase when the user enters 'p'
{
int itemNumber;
double price, total;
if (selection == 'g')
{
printf(" ---------------------------------- ");
printf("You selected %c ", selection);
printf("Here you will display the gas prices ");
printf("---------------------------------- ");
}
//add the rest of the conditions
}
void DisplayGasPrices()
//display the gas choices and related item number
{
printf("----------------------------------------- ");
printf("Here are the gas options ");
printf("1. Regular\t$2.35 per gallon ");
//add the rest of the prices
}
void GetGasChoice(int* itemPtr)
//input: users choice is set by the input/output parameter
{
printf(" select the fuel option by entering the item number: ");
scanf("%d", itemPtr);
}
void SetGallonPrice(int itemNumber, double* pricePtr)
//input: item number
//input: price is set by the input/output parameter
{
if (itemNumber == 1)*pricePtr = 2.35;
else if (itemNumber == 2)*pricePtr = 2.69;
//add the other item numbers
else
{
printf(" you did not enter a 1,2,3,4, or 5");
*pricePtr = 0.00;
}
}
void CalculateTotal(double pricePerGallon, double* totalPtr)
//input price per gallon
//declare, ask and get the number of gallons
//calculate the total
//input/output parameter for the total
{
//declare, ask and get the number of gallons
//calculate the total
}
double AddMoney(double accountBalance)
//input: amount of money in the account
//displays the amount of money available in the account
//allows the user to add money to the account
//returns the updated balance after the money has been added
{
//declare, ask and get the amount to add
//add it to the account balance
return accountBalance;
}
double CheckForEnoughMoney(double accountBalance, double total)
//input: amount of money in the account and the transaction total
//gets money from the user until the user has enough to make the purchase
//make the purchase and returns the remaining balance
{
while (accountBalance
{
accountBalance = AddMoney(accountBalance);
printf(" -------------------------------------------------------");
printf(" The total is $%.2f and you have $%.2f in your account ", total, accountBalance);
}
//make the transaction
//return the accountBalance
}
Use the following programmer defined functions. DO NOT modify the Functions: Intro to Programming in C program 7 (larger program) //function prototypes Assignment purpose: To compile, build, and execute an interactive program using functions from stdio.h (printf //Function from program 6 and scanf), ctype.h, simple math in C, conditions, a simple while loop, file input and output programmer void Greeting(); //welcome the user to the gas station app defined functions with pass by copy (input) parameters and pass reference (input/output) parameters. // Function from program 6 void ViewAndGetSelection(char* selectionPtr); #define _CRT_SECURE_NO_WARNINGS //for Visual studio compiler //input: the user's selection (input/output parameter) #pragma warning(disable:6031) //ignore scanf warnings 7/display the program options and get the users selection //use an input/output parameter for the selection #include //for printf and scanf //Function from program 6 #include //for tolower function void ProcessSelection (char selection, double* balanceptr); //input: the user's selection by copy (input parameter) Instructions: //input: the account balance (input/output parameter) //display a message that the selection has been entered //display the balance when the user enters 'b' This program uses many of the features of program 3, 4, 5, and 6 7/allow the user to add money to the account when the user enters 'u' // complete a purchase when the user enters 'p' For this assignment you will be implementing a program that simulates an online gas purchasing app. void DisplayGasPrices(); The program will welcome the user with a friendly message and instructions. //display the gas choices and related item number Initialize the balance in the account by reading the balance from an input file "gasAccountBalance.txt void GetGasChoice(Int* itemptr); The user will be presented with a list of options //input: users choice is set by the input/output parameter The user will select from the options below: void SetGallonPrice(int itemNumber, double* priceptr); //input: item number printf("'G' to view the gas prices "); //input: price is set by the input/output parameter printf("'p to make a purchase "); void CalculateTotal (double priceperGallon, double* totalptr); printf("'B' to view your account balance "); //input price per gallon printf("'U' to add money to your account "); //declare, ask and get the number of gallons printf("'Q' to Quit "); // calculate the total //input/output parameter for the total The user may continue to select the options until entering 'Q' to quit (you may use tolower function from ctype.h) //Function from program 4 double AddMoney (double accountBalance); For this assignment you will implement all the features of the menu //input: amount of money in the account The items to be purchased (based on the item number) are the same as previous programs: //displays the amount of money available in the account //allows the user to add money to the account //returns the updated balance after the money has been added printf("Here are the gas options "); printf("1. Regular\t$2.35 per gallon "); //Function from program 4 printf("2. Midgrade t$2.69 per gallon "); double checkForEnoughMoney (double accountBalance, double total); printf("3. Premium\t$2.99 per gallon "); //input: amount of money in the account and the transaction total printf("4. Diesel\t$2.60 per gallon "); //gets money from the user until the user has enough to make the purchase printf("5. E85\t\t$2.89 per gallon "); //make the purchase and returns the remaining balance . . Additional information: . There are 2 ways for the user to add money to the account: 1. By entering U 2. By making a purchase and like previous program the user will be forced to enter enough money for the purchase 3. When the user quits the remaining balance will be displayed and also saved to a the file "gasAccountBalance.txt" You can assume the user will enter an integer for the number selection You can assume the user will enter all appropriate data types You can assume the user will reload the account with a reasonable amount Sample Output: select the fuel option by entering the item number: 1 How many gallons of gas do you need? 12 What would you like to do? Please select from the following options: Welcome to the fuel app We offer convenient gas purchasing The total is $28.20 and you have $13.44 in your account What would you like to do? Please select from the following options: 'G' to view the gas prices 'P' to make a purchase 'B' to view your account balance 'U' to add money to your account 'O' to Quit Enter your selection: p Enter the amount to add: 45.00 'G' to view the gas prices 'P' to make a purchase 'B' to view your account balance 'U' to add money to your account 'O' to Quit Enter your selection: b You selected b Your current account balance is $25.00 The total is $28.20 and you have $58.44 in your account You selected p Your current account balance is $45.00 Here you will make a purchase You are now purchasing the gasoline ... Your current account balance is $30.24 Here are the gas options 1. Regular $2.35 per gallon 2. Midgrade $2.69 per gallon 3. Premium $2.99 per gallon What would you like to do? 4. Diesel $2.60 per gallon Please select from the following options: 5. E85 $2.09 per gallon 'G' to view the gas prices select the fuel option by entering the item number: 3 'P' to make a purchase 'B' to view your account balance How many gallons of gas do you need? 44 'U' to add money to your account "O to Quit The total is $131.56 and you have $45.00 in your account Enter your selection: 9 You have $30.24 left in your account for next time. Enter the amount to add: 100.00 saving the amount in the file What would you like to do? Please select from the following options: 'G' to view the gas prices 'P' to make a purchase 'B' to view your account balance 'U' to add money to your account 'O' to Quit Enter your selection: u You selected u Your current account balance is $25.00 Have a great day! The total is $131.56 and you have $145.00 in your account Enter the amount to add: 20.00 You are now purchasing the gasoline ... Your current account balance is $13.44 what would you like to do? Please select from the following options: What would you like to do? Please select from the following options: 'G' to view the gas prices 'P to make a purchase 'B to view your account balance 'U' to add money to your account 'O' to Quit Enter your selection: g 'G' to view the gas prices p' to make a purchase 'B' to view your account balance 'U' to add money to your account 'O' to Quit Enter your selection: P You selected g Here are the gas prices: You selected p Your current account balance is $13.44 Here you will make a purchase Here are the gas options 1. Regular $2.35 per gallon 2. Midgrade $2.69 per gallon 3. Premium $2.99 per gallon 4. Diesel $2.60 per gallon 5. E85 $2.09 per gallon Here are the gas options 1. 2.35 per gallon 2. Midgrade $2.69 per gallon 3. Premium $2.99 per gallon 4. Diesel $2.60 per gallon 5. E85 $2.09 per gallon Use the following programmer defined functions. DO NOT modify the Functions: Intro to Programming in C program 7 (larger program) //function prototypes Assignment purpose: To compile, build, and execute an interactive program using functions from stdio.h (printf //Function from program 6 and scanf), ctype.h, simple math in C, conditions, a simple while loop, file input and output programmer void Greeting(); //welcome the user to the gas station app defined functions with pass by copy (input) parameters and pass reference (input/output) parameters. // Function from program 6 void ViewAndGetSelection(char* selectionPtr); #define _CRT_SECURE_NO_WARNINGS //for Visual studio compiler //input: the user's selection (input/output parameter) #pragma warning(disable:6031) //ignore scanf warnings 7/display the program options and get the users selection //use an input/output parameter for the selection #include //for printf and scanf //Function from program 6 #include //for tolower function void ProcessSelection (char selection, double* balanceptr); //input: the user's selection by copy (input parameter) Instructions: //input: the account balance (input/output parameter) //display a message that the selection has been entered //display the balance when the user enters 'b' This program uses many of the features of program 3, 4, 5, and 6 7/allow the user to add money to the account when the user enters 'u' // complete a purchase when the user enters 'p' For this assignment you will be implementing a program that simulates an online gas purchasing app. void DisplayGasPrices(); The program will welcome the user with a friendly message and instructions. //display the gas choices and related item number Initialize the balance in the account by reading the balance from an input file "gasAccountBalance.txt void GetGasChoice(Int* itemptr); The user will be presented with a list of options //input: users choice is set by the input/output parameter The user will select from the options below: void SetGallonPrice(int itemNumber, double* priceptr); //input: item number printf("'G' to view the gas prices "); //input: price is set by the input/output parameter printf("'p to make a purchase "); void CalculateTotal (double priceperGallon, double* totalptr); printf("'B' to view your account balance "); //input price per gallon printf("'U' to add money to your account "); //declare, ask and get the number of gallons printf("'Q' to Quit "); // calculate the total //input/output parameter for the total The user may continue to select the options until entering 'Q' to quit (you may use tolower function from ctype.h) //Function from program 4 double AddMoney (double accountBalance); For this assignment you will implement all the features of the menu //input: amount of money in the account The items to be purchased (based on the item number) are the same as previous programs: //displays the amount of money available in the account //allows the user to add money to the account //returns the updated balance after the money has been added printf("Here are the gas options "); printf("1. Regular\t$2.35 per gallon "); //Function from program 4 printf("2. Midgrade t$2.69 per gallon "); double checkForEnoughMoney (double accountBalance, double total); printf("3. Premium\t$2.99 per gallon "); //input: amount of money in the account and the transaction total printf("4. Diesel\t$2.60 per gallon "); //gets money from the user until the user has enough to make the purchase printf("5. E85\t\t$2.89 per gallon "); //make the purchase and returns the remaining balance . . Additional information: . There are 2 ways for the user to add money to the account: 1. By entering U 2. By making a purchase and like previous program the user will be forced to enter enough money for the purchase 3. When the user quits the remaining balance will be displayed and also saved to a the file "gasAccountBalance.txt" You can assume the user will enter an integer for the number selection You can assume the user will enter all appropriate data types You can assume the user will reload the account with a reasonable amount Sample Output: select the fuel option by entering the item number: 1 How many gallons of gas do you need? 12 What would you like to do? Please select from the following options: Welcome to the fuel app We offer convenient gas purchasing The total is $28.20 and you have $13.44 in your account What would you like to do? Please select from the following options: 'G' to view the gas prices 'P' to make a purchase 'B' to view your account balance 'U' to add money to your account 'O' to Quit Enter your selection: p Enter the amount to add: 45.00 'G' to view the gas prices 'P' to make a purchase 'B' to view your account balance 'U' to add money to your account 'O' to Quit Enter your selection: b You selected b Your current account balance is $25.00 The total is $28.20 and you have $58.44 in your account You selected p Your current account balance is $45.00 Here you will make a purchase You are now purchasing the gasoline ... Your current account balance is $30.24 Here are the gas options 1. Regular $2.35 per gallon 2. Midgrade $2.69 per gallon 3. Premium $2.99 per gallon What would you like to do? 4. Diesel $2.60 per gallon Please select from the following options: 5. E85 $2.09 per gallon 'G' to view the gas prices select the fuel option by entering the item number: 3 'P' to make a purchase 'B' to view your account balance How many gallons of gas do you need? 44 'U' to add money to your account "O to Quit The total is $131.56 and you have $45.00 in your account Enter your selection: 9 You have $30.24 left in your account for next time. Enter the amount to add: 100.00 saving the amount in the file What would you like to do? Please select from the following options: 'G' to view the gas prices 'P' to make a purchase 'B' to view your account balance 'U' to add money to your account 'O' to Quit Enter your selection: u You selected u Your current account balance is $25.00 Have a great day! The total is $131.56 and you have $145.00 in your account Enter the amount to add: 20.00 You are now purchasing the gasoline ... Your current account balance is $13.44 what would you like to do? Please select from the following options: What would you like to do? Please select from the following options: 'G' to view the gas prices 'P to make a purchase 'B to view your account balance 'U' to add money to your account 'O' to Quit Enter your selection: g 'G' to view the gas prices p' to make a purchase 'B' to view your account balance 'U' to add money to your account 'O' to Quit Enter your selection: P You selected g Here are the gas prices: You selected p Your current account balance is $13.44 Here you will make a purchase Here are the gas options 1. Regular $2.35 per gallon 2. Midgrade $2.69 per gallon 3. Premium $2.99 per gallon 4. Diesel $2.60 per gallon 5. E85 $2.09 per gallon Here are the gas options 1. 2.35 per gallon 2. Midgrade $2.69 per gallon 3. Premium $2.99 per gallon 4. Diesel $2.60 per gallon 5. E85 $2.09 per gallon