1.Roman numeral Converter write a program that ask the user to enter a number wi
ID: 3545345 • Letter: 1
Question
1.Roman numeral Converter
write a program that ask the user to enter a number within the range 1 through 10. use a switch statement to display the roman numeral version of that number.
Input Validation- do not accept a number less than 1 or greater than 10
2.Body mass index
WRITE A PROGRAM that calculates and displays a persons body mass index (bmi). the BMI is often used to determine whether a person ith a sedentary lifestyle is overweight or underweight for his or her height. A persons BMI is calculated with the following formula bmi= weight x 703 height^2
where weight is measured in pounds and height is measured in inches. the program should display a message indicting whether the person has optimal weight, is underweight or is overweight. A sedentary persons weight is considered to be optimal if their weight is 18.5 - 25. if the BMI is less than 18.5, the person is considered to be underweight. if the BMI is greater than 25, the person is considered to be overweight. Create a user defined function to calculate the BMI of a person.
thank you
Explanation / Answer
1)#include <iostream>
using namespace std;
int main()
{
int arabicNumeral=0;
cout << "Enter a number (1 - 10): ";
cin >> arabicNumeral;
if (arabicNumeral>0 && arabicNumeral <=10)
{
cout << " The Roman numeral version of " << arabicNumeral << " is ";
switch (arabicNumeral)
{
case 1:
cout << "I.";
break;
case 2:
cout << "II.";
break;
case 3:
cout << "III.";
break;
case 4:
cout << "IV.";
break;
case 5:
cout << "V.";
break;
case 6:
cout << "VI.";
break;
case 7:
cout << "VII.";
break;
case 8:
cout << "VIII.";
break;
case 9:
cout << "IX.";
break;
case 10:
cout << "X.";
break;
}
}
return 0;
}
2)
#include<iostream>
using namespace std;
int main ()
{
double height = 0.0;
double weight = 0.0;
double bmi = 0.0;
cout << "Enter your height (in inches): ";
cin >> height;
cout << "Enter your weight (in pounds): ";
cin >> weight;
bmi = 703 * weight / (height * height);
if (bmi < 18.5)
{
cout << "Your body weight category is underweight." << endl;
}
else if (bmi < 25)
{
cout << "Your body weight category is normal." << endl;
}
else if (bmi < 30)
{
cout << "Your body weight category is overweight." << endl;
}
else
{
cout << "Your body weight category is obese." << endl;
}
system ("pause");
return 0;
}
Or else ::
Sounds like a pretty simple program. Ask user to enter weight and height, read user input into float (decimal) type variables height and weight. Calculate BMI. Use a couple of IF statements to determine if the person is underweight or overweight.
Basic programming logic:
FLOAT height, weight, bmi
PUT "Please enter height and weight"
GET height, weight
bmi = weight*703/height
IF bmi < 18.5
PUT "You are underweight"
ELSE IF bmi >= 18.5 && bmi <= 25
PUT "Congrats! You are at your optimal weight!"
ELSE
PUT "Sorry, you are overweight."
END IF
now just adapt this to whatever language you need it in.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.