Part 2 Write the following programs: Print source code and output and turn in fo
ID: 3816819 • Letter: P
Question
Part 2 Write the following programs: Print source code and output and turn in for grading Write the following programs. Print source code and output and turn in for grading. 1) Use if else if lse type of construct to write a program called "Height weight Ratio" The program assigns one double value height inches and one weight in pounds. Divide the weight by the height to find the ratio. Use the ratio to make a statement about their fitness if the ratio is less than 2.1 tell the user "his weight height ratio is normal" if the ratio is less than 2.3 tell the user they are slightly above average if the ratio is less than 2.5, tell the user they need to lose 5% percent of their weight"Explanation / Answer
WeightAndHeightRatio.java
import java.util.Scanner;
public class WeightAndHeightRatio {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter the weight in pounds: ");
double weight = scan.nextDouble();
System.out.println("Enter the height in inches: ");
double height = scan.nextDouble();
double ratio = weight / height;
if(ratio < 2.1){
System.out.println("Weight and Height ratio is normal");
}
else if(ratio >= 2.1 && ratio <2.3){
System.out.println("Weight and Height ratio is slightly above average");
}
else if(ratio >= 2.3 && ratio <2.5){
System.out.println("Need to lost 5% percent of weight");
}
else{
System.out.println("Need to lost more than 5% percent of weight");
}
}
}
Output:
Enter the weight in pounds:
145
Enter the height in inches:
72
Weight and Height ratio is normal
Enter the weight in pounds:
165
Enter the height in inches:
68
Need to lost 5% percent of weight
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.