Cpa Lab 2 1 5 (3) - B
Cpa Lab 2 1 5 (3) - B
Scenario
Among the many measurement systems available, two seem to be the most widespread: metric and imperial. To make things simpler, we
assume that the first one uses the "meter" as its only unit (expressed as a real number), while the second uses the "foot" (always an
integer) and the "inch" (a real number).
Your task is to write a simple "measurement converter". We want it to perform the following actions:
ask the user which system she/he uses to input data; we assume that 0 means "metric" and 1 means "imperial";
depending on the user's answer, ask either for meters or feet and inches;
output the distance in proper (different) units: either in feet and inches or in meters;
a result outputted as metric should look like 123.4m;
a result outputted as imperial should look like 12'3.5".
Look at the code below – it's only a template. Use it to implement the whole converter.
#include <iostream>
int main(void) {
int sys;
float m, ft, in;
return 0;
}
Example input
0
1
Example output
3'3.37008"
Example input
1
3
3.37008
© 2017 C++ Institute. All rights reserved. Last updated: March 07, 2017 | www.cppinstitute.org Page 1 of 2
Lab 2.1.3 Some actual evaluations - converting measurement systems
Example output
1m
Example input
0
0.0254
Example output
0'1"
Example input
1
0
1
Example output
0.0254m
© 2017 C++ Institute. All rights reserved. Last updated: March 07, 2017 | www.cppinstitute.org Page 2 of 2