import java.util.Scanner;
public class IdealWeight
{
public static void main (String[] args)
{
Scanner keyboard = new Scanner (System.in);
int heightFeet, heightInches, totalInches, leftoverInches;
System.out.print ("Are you a boy or a girl? ");
String gender = keyboard.nextLine ();
System.out.print ("What is your height in feet? ");
heightFeet = keyboard.nextInt ();
System.out.print ("Wow, how many inches tall are you? ");
heightInches = keyboard.nextInt ();
totalInches = (heightFeet * 12) + heightInches;
leftoverInches = totalInches - 60;
int girlWeight = 100 + (5 * leftoverInches);
int boyWeight = 106 + (6 * leftoverInches);
// .equals compares text, not numbers.
if ((!gender .equals ("boy")) && !gender .equals ("girl"))
{
System.out.println ("I question your gender as well. It's okay. *patpat*");
}
else if (gender .equals ("girl"))
{
System.out.println ("If you are a girl, you should weigh " +girlWeight);
}
else if (gender .equals ("boy"))
{
System.out.println ("If you are a boy, you should weigh " +boyWeight);
}
}
}
public class IdealWeight
{
public static void main (String[] args)
{
Scanner keyboard = new Scanner (System.in);
int heightFeet, heightInches, totalInches, leftoverInches;
System.out.print ("Are you a boy or a girl? ");
String gender = keyboard.nextLine ();
System.out.print ("What is your height in feet? ");
heightFeet = keyboard.nextInt ();
System.out.print ("Wow, how many inches tall are you? ");
heightInches = keyboard.nextInt ();
totalInches = (heightFeet * 12) + heightInches;
leftoverInches = totalInches - 60;
int girlWeight = 100 + (5 * leftoverInches);
int boyWeight = 106 + (6 * leftoverInches);
// .equals compares text, not numbers.
if ((!gender .equals ("boy")) && !gender .equals ("girl"))
{
System.out.println ("I question your gender as well. It's okay. *patpat*");
}
else if (gender .equals ("girl"))
{
System.out.println ("If you are a girl, you should weigh " +girlWeight);
}
else if (gender .equals ("boy"))
{
System.out.println ("If you are a boy, you should weigh " +boyWeight);
}
}
}
(0) Comments
Post a Comment