Enter amount, dollars.cents : 22.2222 You entered $44.22 Enter amount, dollars.cents : 61.1111 You entered $72.11 Enter amount, dollars.cents : 10.3333 You entered $43.33 Testing: logical operators $44.22 < $44.22: false $44.22 <= $44.22: true $44.22 > $44.22: false $44.22 >= $44.22: true $44.22 == $44.22: true $44.22 != $44.22: false $44.22 < $72.11: true $44.22 <= $72.11: true $44.22 > $72.11: false $44.22 >= $72.11: false $44.22 == $72.11: false $44.22 != $72.11: true $44.22 < $43.33: false $44.22 <= $43.33: false $44.22 > $43.33: true $44.22 >= $43.33: true $44.22 == $43.33: false $44.22 != $43.33: true Testing: DC1 + DC2 = DC3 $44.22 + $44.22 = $88.44 $44.22 + $72.11 = $116.33 $44.22 + $43.33 = $87.55 Testing: DC1 - DC2 = DC3 $72.11 - $44.22 = $27.89 $44.22 - $43.33 = $0.89 Testing: DC1 * int = DC2 $44.22 * 2 = $44.44 $72.11 * 2 = $72.22 $72.11 * 3 = $72.33 $43.33 * 3 = $43.99 Testing: DC1 / int = DC2 $44.22 / 2 = $22.11 $72.11 / 2 = $36.05 $72.11 / 3 = $24.03 $43.33 / 3 = $14.44 Testing: DC1 = DC1 + DC2 $44.22 += $44.22 -- after assignment: DC1=$88.44 $44.22 += $72.11 -- after assignment: DC1=$116.33 $44.22 += $43.33 -- after assignment: DC1=$87.55 Testing: DC1 = DC1 - DC2 $72.11 -= $44.22 -- after assignment: DC1=$27.89 $44.22 -= $43.33 -- after assignment: DC1=$0.89 Testing: DC1 = DC1 * int $44.22 *= 2 -- after assignment: DC1= $88.44 $72.11 *= 2 -- after assignment: DC1= $144.22 $43.33 *= 2 -- after assignment: DC1= $86.66 $44.22 *= 3 -- after assignment: DC1= $132.66 $72.11 *= 3 -- after assignment: DC1= $216.33 $43.33 *= 3 -- after assignment: DC1= $129.99 Testing: DC1 = DC1 / int $44.22 /= 2 -- after assignment: DC1= $22.11 $72.11 /= 2 -- after assignment: DC1= $36.05 $43.33 /= 2 -- after assignment: DC1= $21.66 $44.22 /= 3 -- after assignment: DC1= $14.74 $72.11 /= 3 -- after assignment: DC1= $24.03 $43.33 /= 3 -- after assignment: DC1= $14.44 |
Enter amount, dollars.cents : 22.2222 You entered $22.2222 Enter amount, dollars.cents : 61.1111 You entered $61.1111 Enter amount, dollars.cents : 10.3333 You entered $10.3333 Testing: logical operators $22.2222 < $22.2222: false $22.2222 <= $22.2222: true $22.2222 > $22.2222: false $22.2222 >= $22.2222: true $22.2222 == $22.2222: true $22.2222 != $22.2222: false $22.2222 < $61.1111: true $22.2222 <= $61.1111: true $22.2222 > $61.1111: false $22.2222 >= $61.1111: false $22.2222 == $61.1111: false $22.2222 != $61.1111: true $22.2222 < $10.3333: false $22.2222 <= $10.3333: false $22.2222 > $10.3333: true $22.2222 >= $10.3333: true $22.2222 == $10.3333: false $22.2222 != $10.3333: true Testing: DC1 + DC2 = DC3 $22.2222 + $22.2222 = $88.44 $22.2222 + $61.1111 = $116.33 $22.2222 + $10.3333 = $87.55 Testing: DC1 - DC2 = DC3 $61.1111 - $22.2222 = $39.-1111 $22.2222 - $10.3333 = $12.-1111 Testing: DC1 * int = DC2 $22.2222 * 2 = $-858993460.-858993460 $61.1111 * 2 = $-858993460.-858993460 $61.1111 * 3 = $-858993460.-858993460 $10.3333 * 3 = $-858993460.-858993460 Testing: DC1 / int = DC2 $22.2222 / 2 = $-858993460.-858993460 $61.1111 / 2 = $-858993460.-858993460 $61.1111 / 3 = $-858993460.-858993460 $10.3333 / 3 = $-858993460.-858993460 Testing: DC1 = DC1 + DC2 $22.2222 += $22.2222 -- after assignment: DC1=$88.44 $22.2222 += $61.1111 -- after assignment: DC1=$116.33 $22.2222 += $10.3333 -- after assignment: DC1=$87.55 Testing: DC1 = DC1 - DC2 $61.1111 -= $22.2222 -- after assignment: DC1=$44.22 $22.2222 -= $10.3333 -- after assignment: DC1=$43.33 Testing: DC1 = DC1 * int $22.2222 *= 2 -- after assignment: DC1= $88.44 $61.1111 *= 2 -- after assignment: DC1= $144.22 $10.3333 *= 2 -- after assignment: DC1= $86.66 $22.2222 *= 3 -- after assignment: DC1= $132.66 $61.1111 *= 3 -- after assignment: DC1= $216.33 $10.3333 *= 3 -- after assignment: DC1= $129.99 Testing: DC1 = DC1 / int $22.2222 /= 2 -- after assignment: DC1= $22.11 $61.1111 /= 2 -- after assignment: DC1= $35.55 $10.3333 /= 2 -- after assignment: DC1= $21.66 $22.2222 /= 3 -- after assignment: DC1= $14.40 $61.1111 /= 3 -- after assignment: DC1= $23.70 $10.3333 /= 3 -- after assignment: DC1= $14.11 |
|
|
|
|
|
|
|
|
DollarsCents (int numDollars, int numCents);
in the definition it tells me that error C2512: 'DollarsCents' : no appropriate default constructor available
DollarsCents (int numDollars=0, int numCents=0); // declaration
|
|
Testing: DC1 / int = DC2 $22.2222 / 2 = $22.11 $61.1111 / 2 = $36.5 $61.1111 / 3 = $24.3 $10.3333 / 3 = $14.44 <snip> Testing: DC1 = DC1 / int $22.2222 /= 2 -- after assignment: DC1= $22.11 $61.1111 /= 2 -- after assignment: DC1= $35.55 $10.3333 /= 2 -- after assignment: DC1= $21.66 $22.2222 /= 3 -- after assignment: DC1= $14.40 $61.1111 /= 3 -- after assignment: DC1= $23.70 $10.3333 /= 3 -- after assignment: DC1= $14.11 |
Halamaker wrote: |
---|
it doesn't change 22.2222 to 44.22, 61.1111 to 72.11, or 10.3333 to 43.33 |
Enter amount, dollars.cents : 22.2222 You entered $44.22 Enter amount, dollars.cents : 61.1111 You entered $72.11 Enter amount, dollars.cents : 10.3333 You entered $43.33 |
Testing: DC1 / int = DC2 $44.22 / 2 = $22.11 $72.11 / 2 = $36.05 $72.11 / 3 = $24.03 $43.33 / 3 = $14.44 <skip> Testing: DC1 = DC1 / int $44.22 /= 2 -- after assignment: DC1= $22.11 $72.11 /= 2 -- after assignment: DC1= $36.05 $43.33 /= 2 -- after assignment: DC1= $21.66 $44.22 /= 3 -- after assignment: DC1= $14.74 $72.11 /= 3 -- after assignment: DC1= $24.03 $43.33 /= 3 -- after assignment: DC1= $14.44 |
simplify();
in a friend function, do I have to do something special? I'mm getting this error error C3861: 'simplify': identifier not found |
DollarsCents& simplify();
but it doesn't seem to do anything...
$72.11 / 2 = $36.5 $72.11 / 3 = $24.3 |
out << "$" << money.dollars << "." << std::setfill('0') << std::setw(2) << money.cents;
|
|
|
|
halamaker wrote: |
---|
In order to call simplify(); in a friend function, do I have to do something special? |
money.simplify();