Hello, i need help with this C++ Program Regarding Function Call Basically i hav
ID: 3638259 • Letter: H
Question
Hello, i need help with this C++ Program Regarding Function CallBasically i have this menu with 4 options, option A, B , C, D and X. I need to make the program do function calls depending on which option the user prompts.
Option A Basically Prints out a little Computer Science is fun banner im supposed to print.
I need to make option C do this:
Basically turn it into a register like the ones at the stores. Where the program tells the user what coins or dollar bills to give out with any amount of change.
Basically:
>> Input the number of change: 20.30
<< Output:
You should give: 1 $20 Dollar bill, 1 quarter, 1 nickel.
For a total of 20.30 Dollars
I do not know how to approach this using 1 single function as function call. Here is what i have so far, the menu system and all options work perfectly. It compiles very smoothly too.
#include <iostream>
using namespace std;
char upcase(char);
void ProgramA();
int main()
{
char menuChoice;
bool userNotDone = true;
while (userNotDone)
{
// We can use these to check values of letters
// cout << int('a');
// cout << int('A');
system("cls");
cout << " ******* Menu ******* ";
cout << " A. Choice A ";
cout << " B. Choice B ";
cout << " C. Choice C ";
cout << " X. Choice X ";
cout << " Enter Menu Choice ==> ";
cin >> menuChoice;
switch (upcase(menuChoice))
{
case 'A': ProgramA();
system ("pause");
break;
case 'B': cout << "Picked B ";
system ("pause");
break;
case 'C': cout << "Picked C ";
system ("pause");
break;
case 'X': cout << "Exit";
userNotDone = false;
break;
default: cout << "Error Message "; // Function Call
}
}
return 0;
}
char upcase(char inComing)
{
if(inComing >= 'a' && inComing <= 'z') // lowercase starts at 65, uppercase at 97
inComing -= 32; // Prefered Syntax -= than -.
return inComing;
}
// This is Option A
void ProgramA()
{
cout << " ****************************************** ";
cout << " C C C S S S S !! ";
cout << " C C S !! ";
cout << " C S !! ";
cout << " C S !! ";
cout << " C S S S S !! ";
cout << " C S !! ";
cout << " C S !! ";
cout << " C C S S ";
cout << " C C C S S S S OO ";
cout << " ";
cout << "***************************************** ";
cout << " Computer Science is Cool Stuff!!!! ";
cout << endl;
}
Explanation / Answer
Hi, my friend here is how to make the change calculation f need more help message me please rate double mon=20.30; int q,d,n,p; int money=(int)mon; q=mon/25; mon=mon-(25*q); d=mon/10; mon=mon-(10*d); n=mon/5; mon=mon-(5*n); p=mon/1; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.