Now I have done the first two parts but I am stuck on the last 3 parts of the problem. Here is the description of this problem Among many measurement systems two of them seem to be the most widespread: metric and imperial. To make the story simpler we
assume that the first one uses "meter" as an only unit (expressed as a real number) while the second uses "foot" (always integer) and
"inch" (real number).
Your task is to write a simple "measurements converter". We want it to perform the following actions:
first, it should ask the user which system she/he uses to input data; we assume that 0 means "metric" and 1 means "imperial"
depending on a user's answer, the program should ask either for meters or feet and inches
next, the program should output the distance in proper (different) units: either in feet and inches or in meters
result outputted as metric should look like 123.4m
result printed as imperial should look like 12'3.5" Need help on those last 3 thank you.
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
|
#include "stdafx.h"
#include <iostream>
using namespace std;
int main(void)
{
int sys;
float m, ft, in;
// Insert your code here
cout << "Enter 0 for metric or enter 1 for imperial." << endl;
cin >> sys;
if (sys == 0)
{
cout << "You have selected the metric system put meters: " << endl;
cin >> m;
}
else if (sys == 1)
{
cout << "You have selected the imperial system " << endl;
cout << "First put foot: " << endl;
cin >> ft;
cout << "Next put in integer: " << endl;
cin >> in;
}
return 0;
}
|