Question: In C++ please **Important note** the instructor asked specifically that I follow the following code and not change functions: the code starter: //Task #7 //NAME:
In C++ please
**Important note** the instructor asked specifically that I follow the following code and not change functions:
the code starter:
//Task #7 //NAME:
#include
int GetCodeNumber() //Function welcomes the user, then asks for the code number (1 - 7) and returns this value { return -1; }
double DetermineRate_IF (int code) //Function uses an if-statement to determine the rate, based on the code (1 - 7) //The rate is returned to the caller. 0 is returned for the rate if the code is invalid { return -1; }
double DetermineRate_SWITCH (int code) //Function uses a switch-statement to determine the rate, based on the code (1 - 7) //The rate is returned to the caller. 0 is returned for the rate if the code is invalid
{ return -1; }
void DisplayValues (int code, double rate) //Output the code number entered and the resulting rate...or the code number and an error message //Don't forget cout
}
int main() { //DO NOT CHANGE ANY CODE IN THIS FUNCTION int codeNumber = -1; //User enters this number in function GetCodeNumber double rate = -1.0; //User's rate is assigned by the codeNumber in two functions
codeNumber = GetCodeNumber(); cout
rate = DetermineRate_IF(codeNumber); cout
rate = DetermineRate_SWITCH(codeNumber); cout
DisplayValues (codeNumber, rate); cout
return 0; }

Task 7-Same Selection Two Ways AND Writing Functions I have started a program asks a user for a codeliumber (a number from 1-7) and assigns variable rate a value based on this code. It then (simply) outputs their codelumber and the value in rate (to two decimal places). However, it they enter a number other than 1-7, it should output the codelumber and an error message. codeNumber 02 0S 15 Error mess Other I have included a starter cpp with this Task. It includes a finished main() function (which you are NOT allowed to change in any way) and function outlines for 4 functions that will do the work of the program. YOUR JOB is to CODE the missing function code. The comments with each function explains what they do: int GetcodeNumber() //Function welcomes the user, then asks for the code number (1 7) and returns this value double DetermineRate IF (int code) //Function uses an if-statement to determine the rate, based on the code (1 7) //The rate is returned to the caller. is returned for the rate if the code is invalid double DetermineRate SWITCH (int code) //Function uses a switch-statenent to determine the rate, based on the code (1 7) //The rate is returned to the caller. is returned for the rate if the code is invalid void DisplayValues (int code, double rate) //output the code number entered and the resulting rate...or the code number and an error nessage //Don't forget cout
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
