|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
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: 89: 90: 91: 92: 93: 94: 95: 96: 97: |
**************
**************
Original Code:
#include <iostream>
using namespace std;
int main()
{
double itemPrice;
double cashTendered;
double change;
int dollars ;
int quarters ;
int dimes ;
cout << " What was the price of the item purchased ?" ;
cin >> itemPrice;
cout << " How much did you hand the cashier ?" ;
cin >> cashTendered;
change = cashTendered - itemPrice;
dollars = change ;
quarters = (change - dollars) / .25;
dimes = (change - dollars) / .10 ;
cout << " Your change should be :$" << change << endl ;
cout << dollars << "Dollar(s)" << endl;
cout << quarters << "Quarter(s)" << endl;
cout << dimes << " Dime(s)" << endl ;
return 0;
}
************
************
Expert Code (not compilable and without doubles):
float itemPrice;
float cashTendered;
float change;
int dollars ;
int quarters ;
int dimes ;
int nickels;
int pennies;
int temp;
dollars = quarters = dimes = nickels = pennies = 0;
cout << " What was the price of the item purchased ?" ;
cin >> itemPrice;
cout << " How much did you hand the cashier ?" ;
cin >> cashTendered;
/* change = cashTendered - itemPrice;
dollars = change ;
temp = change-dollars;
quarters = (change - dollars) / 0.25;
dimes = (temp - quarters*0.25) / 0.10 ;
temp = temp - (dimes*0.10)- (quarters*0.25);
nickels = temp/0.05;
temp = temp - (nickels*0.05) ;
pennies = temp/0.01;*/
change = cashTendered - itemPrice;
dollars = change ;
temp = (change-dollars)*100;
//temp = temp*100;
quarters = (temp - (temp % 25 ))/25;
temp = temp - (25 * quarters);
dimes = (temp - (temp % 10))/10;
temp = temp - (10 * dimes);
nickels = (temp - (temp % 5))/5;
pennies = temp - (5 * nickels);
cout << " Your change should be :$" << change << endl ;
cout << dollars << " Dollar(s)" << endl;
cout << quarters << " Quarter(s)" << endl;
cout << dimes << " Dime(s)" << endl ;
cout << nickels << " nickel(s)" << endl ;
cout << pennies << " pennie(s)" << endl ;
|
Advertisement
| Hall of Fame |