【发布时间】:2017-01-30 09:59:40
【问题描述】:
当你输入你的身高时,我已经编码了男性和女性的理想体重。
import java.util.Scanner;
public class height
{
public static void main (String []args)
{
int Feet, Inches, Totalinches, Maleweight, Femaleweight;
Scanner scan = new Scanner (System.in);
System.out.println ("Please enter your height in feet and inches...");
System.out.println ("Feet: ");
Feet = scan.nextInt();
System.out.println ("Inches: ");
Inches = scan.nextInt();
Totalinches = Feet*12 + Inches;
Maleweight = 106 + (Totalinches - 60)*6;
Femaleweight = 100 + (Totalinches - 60)*5;
System.out.println ("The ideal weight for a " + Feet + " foot " + Inches + " male is " + Maleweight + " pounds.");
System.out.println ("A weight in the range to is okay.");
System.out.println ("The ideal weight for a " + Feet + " foot " + Inches + " female is " + Femaleweight + " pounds.");
System.out.println ("A weight in the range and is okay.");
}
}
上面写着“范围内的重量...”我需要输入包含计算理想重量范围的公式的代码。在这里可以找到一张图表,说明与身高相对应的所有理想体重范围:
感谢大家的帮助,非常感谢
【问题讨论】: