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.
#include "stdafx.h"
#include <iostream>
usingnamespace 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;
}
elseif (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;
}
Should I put them separately inside the else if loop for else if (sys==1) ? and how do I exactly output them combine them as strings ? Thus the output should be the following for any of them result outputted as metric should look like 123.4m
result printed as imperial should look like 12'3.5"
I am following the program its based on a lab that's how they give it to me its already made. If you are familiar with the C++ institute program of course that's how they give it to me
Also how to you implement this * Dividing total inches as integer (or just drop the fractional part) gets you the feet part. Modulo (or fmod) gets you the remaining inches. Like do I just put it inside the loop ? I will try to figure it out
x = a %(int)d; the remainder when a is divided by d.
fmod is almost the same as % for floats. Read this one online.
13%12 = 1
13/12 = 1
1 foot, 1 inch...
All the variables are floats I have to do the second uses "foot" (always integer) and
"inch" (real number). What you put as a anwser does not make any sense and makes it more confusing then clearing it up.