Question
PLEASE USE THE FOLLOWING PROGRAM DEFINE FUNCTIONS. DO NOT MODIFY THE FUNCTIONS. USE 2019 VISUAL STUDIOS PROGRAMMING IN C. THANK YOU. #define _CRT_SECURE_NO_WARNINGS //for Visual
PLEASE USE THE FOLLOWING PROGRAM DEFINE FUNCTIONS. DO NOT MODIFY THE FUNCTIONS.
USE 2019 VISUAL STUDIOS PROGRAMMING IN C.
THANK YOU.
#define _CRT_SECURE_NO_WARNINGS //for Visual Studio compiler #pragma warning(disable:6031) //ignore scanf warnings
#include
//function prototypes
void Greeting(); //welcome the user to the gas station app
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'
int main() { char choiceInMain; double balanceInMain = 0.00;
//call the greeting function
//view and get the selection - function call //change the selection to lower or upper 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 or upper case }
//say goodbye to the user // do not forget to return SUCCESS }
//function definitions
void Greeting() //welcome the user to the coffee shop { 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' { if (selection == 'g') { printf(" ---------------------------------- "); printf("You selected %c ", selection); printf("Here you will display the gas prices "); printf("---------------------------------- "); } //add the rest of the conditions }
Sample Output: Welcome to the fuel app We offer convenient gas purchasing ******************************************************** What would you like to do? Please select from the following options: 'G' to view the gas prices 'P' to purchase gas 'B' to view your account balance 'U' to add money to your account 'Q' to Quit Enter your selection: g ---------------------------------- You selected g Here you will display the gas prices ---------------------------------- ******************************************************** What would you like to do? Please select from the following options: 'G' to view the gas prices 'P' to purchase gas 'B' to view your account balance 'U' to add money to your account 'Q' to Quit Enter your selection: p ---------------------------------- You selected p Here you will make a purchase ---------------------------------- ******************************************************** What would you like to do? Please select from the following options: 'G' to view the gas prices 'P' to purchase gas 'B' to view your account balance 'U' to add money to your account 'Q' to Quit Enter your selection: b ---------------------------------- You selected b Your current account balance is $0.00 ---------------------------------- ******************************************************** What would you like to do? Please select from the following options: 'G' to view the gas prices 'P' to purchase gas 'B' to view your account balance 'U' to add money to your account 'Q' to Quit Enter your selection: u ---------------------------------- You selected u How much do you want to add? 50.00 ---------------------------------- ******************************************************** What would you like to do? Please select from the following options: 'G' to view the gas prices 'P' to purchase gas 'B' to view your account balance 'U' to add money to your account 'Q' to Quit Enter your selection: b ---------------------------------- You selected b Your current account balance is $50.00 ---------------------------------- ******************************************************** What would you like to do? Please select from the following options: 'G' to view the gas prices 'P' to purchase gas 'B' to view your account balance 'U' to add money to your account 'Q' to Quit Enter your selection: x ---------------------------------- You selected x That is not a valid option ---------------------------------- ******************************************************** What would you like to do? Please select from the following options: 'G' to view the gas prices 'P' to purchase gas 'B' to view your account balance 'U' to add money to your account 'Q' to Quit Enter your selection: q Have a great day!
Assignment purpose: To compile, build, and execute an interactive program using functions from stdio.h (printf and scanf), simple math in C, conditions, a simple loop, and programmer defined functions, with pass by copy input parameters and with input/output parameters. #define _CRT_SECURE_NO_WARNINGS //for Visual studio compiler #pragma warning(disable:6031) //ignore scanf warnings #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started