algorithm i have to use..
// Start
// Declarations
// num dollars
// output "Please enter the a whole dollar amount (no cents!). Input 0 to terminate: "
// input dollars
// while ( dollars <> 0)
// displayBills(dollars)
// output "Please enter the a whole dollar amount (no cents!). Input 0 to terminate: "
// input dollars
// endwhile
// Stop
//
//
//
// displayBills(num dollars)
// Declarations
// num ones
// num fives
// num tens
// num twenties
// num temp
// twenties = dollars / 20
// temp = dollars % 20
// tens = temp / 10
// temp = temp % 10
// fives = temp / 5
// ones = temp % 5
// output "The dollar amount of ", dollars, " can be represented by the following monetary denominations"
// output " Twenties: ", twenties
// output " Tens: ", tens
// output " Fives: ", fives
// output " Ones: ", ones
// return
// my code with 3 errors on my compiler below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
#include <iostream>
using namespace std;
int main()
{
int dollars;
cout<<"Please enter the a whole dollar amount (no cents!). Input 0 to terminate: ";
cin>>dollars;
while(dollars!=0){
cout<<dollars;
cout<<"Please enter the a whole dollar amount (no cents!). Input 0 to terminate: ";
cin>>dollars;
}
system("pause");
return 0;
#include <iostream>
using namespace std;
int main()
{
int dollars;
cout<<"Please enter the a whole dollar amount (no cents!). Input 0 to terminate: ";
cin>>dollars;
while(dollars!=0){
cout<<dollars;
cout<<"\nPlease enter the a whole dollar amount (no cents!). Input 0 to terminate: ";
cin>>dollars;
system("pause");
return 0;
using namespace std;
int main()
{
int dollar, bills;
while(true)
{
cout << "Please type in the dollar amount, without cents, that you would like to convert to bills." << endl;
cin >> dollar;
if(dollar == 0)
break;
bills = (dollar-(dollar%20))/20;
cout << endl << "The number of denominational bills for " << dollar << " dollars is:";//basic statement
cout << bills;
if (bills == 1)
cout << " twenty, ";
else
cout << " twenties, ";
dollar -= (bills*20);
bills = (dollar-(dollar%10))/10;
cout << bills;
if (bills == 1)
cout << " ten, ";
else
cout << " tens, ";
dollar -= (bills*10);
bills = (dollar-(dollar%5))/5;
cout << bills;
if (bills == 1)
cout << " five, ";
else
cout << " fives, ";
dollar -= (bills*5);
cout << "and " << dollar;
if (dollar == 1)
cout << " one.";
else
cout << " ones.";
cout << endl;
}
return 0;
}
|
says i have 3 errors and im not sure if my int mains are the issue or where there placed this algorithm is complex for me to figure out.