Skip to content

Instantly share code, notes, and snippets.

@imryan
Last active December 24, 2015 12:19
Show Gist options
  • Save imryan/6797299 to your computer and use it in GitHub Desktop.
Save imryan/6797299 to your computer and use it in GitHub Desktop.
Calculates ideal weight for males and females.
import java.lang.*;
import java.util.Scanner;
public class Program
{
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
// Declare variables
double feet = 0.0, inches = 0.0;
double girl = 0.0, girlPercentage = 0.0;
double man = 0.0, manPercentage = 0.0;
double height = 0.0;
// Get input
feet = sc.nextDouble();
inches = sc.nextDouble();
// Calculations
height = ((feet * 12) + inches) - 60;
System.out.println(height);
// Female results
girl = (100 + (height * 5));
girlPercentage = (0.15 * girl);
System.out.println("\nFemale ideal weight: " + (girl - girlPercentage) + " to " + (girl + girlPercentage));
// Male results
man = (106 + (height * 6));
manPercentage = (0.15 * man);
System.out.println("\nFemale ideal weight: " + (man - manPercentage) + " to " + (man + manPercentage));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment