Problem Statement
Write a program that repeatedly asks the user to enter two money amounts expressed in
old-style British currency: pounds, shillings, and pence. (See Exercises 10 and 12 in
Chapter 2, “C++ Programming Basics.”) The program should then add the two amounts
and display the answer, again in pounds, shillings, and pence. Use a do loop that asks the
user whether the program should be terminated. Typical interaction might be
Enter first amount: £5.10.6
Enter second amount: £3.2.6
Total is £8.13.0
Do you wish to continue (y/n)?
To add the two amounts, you’ll need to carry 1 shilling when the pence value is greater
than 11, and carry 1 pound when there are more than 19 shillings.
Hi Everyone.
i am having a problem with the output of a code . i got a code from a website which shows the correct output .
i changed just the variable names and the output has changed too.
Please tell me why that is happening
CODE FROM THE WEBSITE
#include<iostream>
using namespace std;
void main(void)
{ int m[2][3]; char A,sep; //m (money), sep (char_separator).
do{
cout<<"Enter first amount : \x9c";
cin >>m[0][0]>>sep>>m[0][1]>>sep>>m[0][2];
cout<<"Enter second amount: \x9c";
cin >>m[1][0]>>sep>>m[1][1]>>sep>>m[1][2];
m[0][0] += m[1][0]; m[0][1] += m[1][1]; m[0][2] += m[1][2];
if(m[0][2]>11){m[0][1] += static_cast<int>(m[0][2]/12); m[0][2] %= 12;}
if(m[0][1]>19){m[0][0] += static_cast<int>(m[0][1]/20); m[0][1] %= 20;}
cout<<"Total is : \x9c"<<m[0][0]<<sep<<m[0][1]<<sep<<m[0][2];
cout<<"\n\n !Press c to continue or any key to exit."<<endl<<endl;
}
while(A=='c');
system("pause");
}
CODE WHICH I WROTE AFTER CHANGING VARIABLE NAMES
#include<iostream>
using namespace std;
void main()
{
int pound,shling,panny,pound2,shling2,panny2;
char x,sep;
do
{
cout<<"Enter 1st Amount \x9c";