Write a C++ program using If/Else 1. ask the user for the number of meters 2. re
ID: 3531953 • Letter: W
Question
Write a C++ program using If/Else
1. ask the user for the number of meters
2. read in the number of meters
3. ask the user for a character code
4. read in the character code
5. if the code is an upper case or lower case
'y' convert the meters to yards
'f' convert the meters to feet
'm' convert the meters to miles
'k' convert the meters to kilometers
'n' convert the meters to nauticsal miles
'l' convert the meters to league
'r' convert the meters to rods
'b' convert the meters to biblical cubit
's' convert the meters to biblicsl span
output should look like:
????? in meters is
????? in yards
????? in feet
????? in miles
????? in kilometers
????? in nauticsal miles
????? in leagues
????? in rods
????? in biblical cubit
????? in biblical span
Explanation / Answer
please rate - thanks
#include<iostream>
using namespace std;
int main()
{char c;
double meter;
cout<<"Enter the number of meters: ";
cin>>meter;
cout<<"Enter a character code: ";
cin>>c;
cout<<meter<<" in meters is ";
if(c=='y'||c=='Y')
cout<<1.09361*meter<<" in yards "<<endl;
else if(c=='F'||c=='F')
cout<<3.28084*meter<<" in feet ";
else if(c=='m'||c=='M')
cout<<0.000621371*meter<<" in miles ";
else if(c=='k'||c=='K')
cout<<0.001*meter<<" in kilometers ";
else if(c=='n'||c=='N')
cout<<0.000539957*meter<<" in natical miles ";
else if(c=='l'||c=='L')
cout<<0.000179985601*meter<<" in leagues ";
else if(c=='r'||c=='R')
cout<<0.198838782*meter<<" in rods ";
else if(c=='b'||c=='B')
cout<<2.1872266*meter<<" in biblical cubits ";
else if(c=='s'||c=='S')
cout<< 4.37445319*meter<<" in biblical spans ";
else
cout<<"Invalid entry ";
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.