Using C++, change the formatting in this code by using set precision and set width. The decimals should line up.
#include
using namespace std;
int main()
{
int start, end;
int ch=1;
do{
cout<<"Enter starting and ending range";
cin>>start;
cin>>end;
if(end36)
{
cout<<"Invalid range\n";
continue;
}
cout<<"Inches\tCentimeters\n";
cout<<"******\t***********\n";
for(int i=start;i<=end;i=i+6){
cout< }
cout<<"Do you want to continue -1 to quit";
cin>>ch;
}while(ch!=-1);
return 0;
}
#include <iostream> #include <iomanip> using namespace std; int main() { int start, end; int ch = 1; do { cout << "Enter starting and ending range"; cin >> start; cin >> end; if (end < start) { cout << "Invalid range\n"; continue; } cout << "Inches\tCentimeters\n"; cout << "******\t***********\n"; for (int i = start; i <= end; i = i + 6) { cout << setw(10) << setprecision(2) << fixed << left << i << setprecision(2) << fixed << 2.54*i << endl; } cout << "Do you want to continue -1 to quit"; cin >> ch; } while (ch != -1); return 0; }
Get Answers For Free
Most questions answered within 1 hours.