I'm trying to write a program that adds two money amounts in old-style British currency---pounds, shillings, pence---and asks if the user wants to continue. It also adds a pound every 20 shillings, and adds a shilling every 12 pence. (it's an exercise in my book).
Code:
#include <iostream>
using namespace std;
int main()
{
int pnd, shl, pnc;
int pnd2, shl2, pnc2;
int totp, tots, totpn;
char c;
char ch;
while (ch != 'n')
{
cout << "Enter two amounts in pounds, shillings, and pence: ";
cin >> pnd >> c >> shl >> c >> pnc;
cout << endl;
cout << "Enter second amount: ";
cin >> pnd2 >> c >> shl2 >> c >> pnc2;
cout << endl;
totp = pnd + pnd2;
tots = shl + shl2;
totpn = pnc + pnc2;
while (!(tots % 20))
{
totp += 1;
tots -= 20;
}
while (!(totpn % 12))
}
tots += 1;
totpn -= 12;
}
cout << "Total is " << totp << "." << tots
<< "." << totpn << endl << endl;
cout << "Continue (y/n)?";
cin >> ch;
}
return 0;
}
The problem is it brings up seventeen errors, most of them pertaining to a (or several) missing semicolon. I've looked over the code and I don't see any syntax mistakes. What is wrong with the code?
By the way, I know I might have made a few calculating mistakes (to display the correct result), but I'm going to fix any stuff like that once I rid of these errors.