//********************************************************************
// IdealWeight.java Author: Saiful Islam
//
// Finds the ideal weight of a male or a femail based on their height
//********************************************************************
import java.util.*;
public class IdealWeight
{
public static void main( String[] args )
{
//Object Reference Variable Declarations
String gender;
int feet, inches, totalHeight;
double maleIdealWeight, femaleIdealWeight;
double maleLowIdealWeight, maleHighIdealWeight;
double femaleLowIdealWeight, femaleHighIdealWeight;
//Creates a new Scanner object
Scanner input = new Scanner(System.in);
//Displays the user to input the feet in the height for males
System.out.println ("Enter the number of feet in your height: ");
feet = input.nextInt();
//Displays the user to input the inches in the height for males
System.out.println ("Enter the number of inches in your height: ");
inches = input.nextInt();
totalHeight = (feet * 12) + inches;
System.out.println ("Are you a male or a female? ");
gender = input.nextLine();
//Creates an if statement
if (gender.matches("Male")) /*If the answer to the question is male
it does the following*/
{
maleIdealWeight = (4 * totalHeight) - 128;
//Equation to find the weight range for the height for males
maleLowIdealWeight = maleIdealWeight - (.15 * maleIdealWeight);
maleHighIdealWeight = maleIdealWeight + (.15 * maleIdealWeight);
//Displays the ideal weight for males
System.out.println ("Your ideal weight is " + maleIdealWeight);
//Displays the weight range for the height for males
System.out.println ("The weight range for your height is between "
+ maleLowIdealWeight + " and " + maleHighIdealWeight);
}
if (gender.matches("Female")) /*If the answer to the question is female
it does the following*/
{
femaleIdealWeight = (3.5 * totalHeight) - 108;
//Equation to find the weight range for the height for females
femaleLowIdealWeight = femaleIdealWeight - (.15 * femaleIdealWeight);
femaleHighIdealWeight = femaleIdealWeight + (.15 * femaleIdealWeight);
//Displays the ideal weight for females
System.out.println ("Your ideal weight is " + femaleIdealWeight);
//Displays the weight range for the height for females
System.out.println ("The weight range for your height is between "
+ femaleLowIdealWeight + " and " + femaleHighIdealWeight);
}
}
}