Showing Page:
1/3
Write a fortan program that takes a certain amount of
money as input and out puts how many of each type of
American coins it would take to make up that amount of
money.PLEASE INCLUDE IF STATEMENTS FOR THIS
PROGRAM. (Example: $1.68 is the input, 6 quarters, 1
dime, 1 nickel, and 3 pennies is the output.) thanks in
advance.
Solution
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#define pennies 1
#define dime 10
#define quarter 25
#define nickel 5
int main()
{
const int PENNY = 1;
const int NICKEL = 5;
const int DIME = 10;
const int QUARTER = 25;
Showing Page:
2/3
int money;
int p = pennies;
int d = dime;
int q = quarter;
int n = nickel;
int c;
int amount;
cout << \"Please enter in a dollar amount to convert it to
change\";
cin >> money; // <-- Reminder: Input is not validated.
system(\"pause\"); <-- Not needed
cout << \"To determine how many penny\'s, nickels, dimes
or quarters, enter\ \";
cout << \"pennies or nickel or dime or quarter\ \";
cin >> c;
cout << ( m * 100 / c ) << endl;
if ( money < 1 ) // Changed this line ( if m is less than 1)
return -1; // Return a non-zero to indicate failure
if ( c == pennies )
return ( amount = m * 100 / c );
else if ( c == nickel )
return ( amount = m * 100 / c );
else if ( c == dime )
return ( amount = m * 100 / c );
else if ( c == quarter ) return ( amount = m * 100 / c );
Showing Page:
3/3
}
cout << \"Number of pennies: \" << ((money * 100) /
PENNY);
cout << \"Number of nickels: \" << ((money * 100) /
NICKEL);
cout << \"Number of dimes: \" << ((money * 100) / DIME);
cout << \"Number of quarters: \" << ((money * 100) /
QUARTER);
cout << \"The result is:\" << amount <<\"\'s in\" << c <<
endl;
system(\"pause\");
return 0; // Return zero, indicating a successful run.
}

Unformatted Attachment Preview

Write a fortan program that takes a certain amount of money as input and out puts how many of each type of American coins it would take to make up that amount of money.PLEASE INCLUDE IF STATEMENTS FOR THIS PROGRAM. (Example: $1.68 is the input, 6 quarters, 1 dime, 1 nickel, and 3 pennies is the output.) thanks in advance. Solution #include using std::cout; using std::cin; using std::endl; #define pennies 1 #define dime 10 #define quarter 25 #define nickel 5 int main() { const int PENNY = 1; const int NICKEL = 5; const int DIME = 10; const int QUARTER = 25; int money; int p = pennies; int d = dime; int q = quarter; int n = nickel; int c; int amount; cout << \"Please enter in a dollar amount to convert it to change\"; cin >> money; // <-- Reminder: Input is not validated. system(\"pause\"); <-- Not needed cout << \"To determine how many penny\'s, nickels, dimes or quarters, enter\ \"; cout << \"pennies or nickel or dime or quarter \ \"; cin >> c; cout << ( m * 100 / c ) << endl; if ( money < 1 ) // Changed this line ( if m is less than 1) return -1; // Return a non-zero to indicate failure if ( c == pennies ) return ( amount = m * 100 / c ); else if ( c == nickel ) return ( amount = m * 100 / c ); else if ( c == dime ) return ( amount = m * 100 / c ); else if ( c == quarter ) return ( amount = m * 100 / c ); } cout << \"Number of pennies: \" << ((money * 100) / PENNY); cout << \"Number of nickels: \" << ((money * 100) / NICKEL); cout << \"Number of dimes: \" << ((money * 100) / DIME); cout << \"Number of quarters: \" << ((money * 100) / QUARTER); cout << \"The result is:\" << amount <<\"\'s in\" << c << endl; system(\"pause\"); return 0; // Return zero, indicating a successful run. } Name: Description: ...
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4