-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q1Ass3.cpp
50 lines (37 loc) · 1.27 KB
/
Q1Ass3.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
Question1:
Write a C++ program to convert meters to feet. The program should request the starting meter value,
the number of conversions to be made, 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 10, have your program substitute a default increment of 10. Use the
relationship that 1 meter = 3.281 feet.
*/
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float meters, feets;
int increment, iteration;
cout<<"Enter starting meter value:"; cin>>meters;
cout<<endl;
cout<<"Enter the number of conversions you want to be made: "; cin>>iteration;
cout<<endl;
cout<<"Enter the increment you want in meteric value: "; cin>>increment;
cout<<endl;
if (iteration>10)
{
iteration=10;
cout<<"Iteration is alloted default value."<<endl;
cout<<"Iteration can not be greater than 10..."<<endl;
}
cout<<setw(10) <<"Meters"<< setw(20) <<"Feets" <<endl;
cout<<"-----------------------------------"<<endl;
for(int i=0; i<iteration; i++)
{
feets= 3.281*meters;
cout<<setw(10) <<meters<< setw(20) << feets <<endl;
meters+=increment;
}
return 0;
}