Write a C++ program, using while statement, to convert meters to feet. The program should request the starting meter value, the ending meter value, and the increment between metric values. The display should have appropriate headings and list the meters and the corresponding feet value. If the number of iterations is greater than 20, have your program substitute a default increment of (ending value - starting value) / 19. Use the relationship that 1 meter = 3.28 feet.
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
float startingValue , endingValue, step;
cout<<"Enter starting meter value: ";
cin>>startingValue;
cout<<"Enter ending meter value: ";
cin>>endingValue;
cout<<" the increment between metric values:
";
cin>>step;
if((endingValue - startingValue)/step >19)
step = (endingValue -
startingValue)/19;
cout<<endl;
cout<<left<<setw(8)<<"meter"<<setw(8)<<"Feet\n";
while(startingValue <= endingValue){
cout<<left<<setw(8)<<setprecision(3)<<fixed<<startingValue<<setw(8)<<startingValue*3.28<<endl;
startingValue += step;
}
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.