//inches_conversion.cpp
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
int main()
{
int inches, cm; //inches & centimeters
char type, ans; //type of conversion & answer to continue/stop
ans='y';
while (ans=='y')
{
cout<<"\nType C to convert to Centimeters or I to convert to Inches: ";
cin>>type;
if (type=='c' | type=='C')
{
cout<<"\nEnter the number of inches to be coverted: ";
cin>>inches;
cout<<"\n"<<inches<<" inches converts to: "<< (inches*2.54)<<" centimeters.";
}
elseif (type=='i' | type== 'I')
{
cout<<"\nEnter the number of centimeters to be converted: ";
cin>>cm;
cout<<"\n"<<cm<<" centimeters converts to: "<< (cm/1)<<" inches."<<endl;
}
getch();
cout<<"\n\nDo you want to make another conversion? (y/n): ";
cin>>ans;
if (ans=='y' | 'Y')
{
(ans='y');
}
elseif (ans=='n' | 'N')
{
cout<<endl;
}
}
return 0;
}
These lines of code are what I'm specifically having problems & speaking about:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
getch();
cout<<"\n\nDo you want to make another conversion? (y/n): ";
cin>>ans;
if (ans=='y' | 'Y')
{
(ans='y');
}
elseif (ans=='n' | 'N')
{
(ans='n');
cout<<endl;
}
}
return 0;
}