/* Height.java * Asks the user for height in inches and calculates feet and inches * Key concepts: Scanner class for input and % for division remainder * CS230 Lab 1 * Written by: CS230 * Modified by: * Modified date:sept 2019 */ import java.util.Scanner; public class Height{ public static void main (String [] args) { Scanner scan = new Scanner(System.in); // Ask for the user's height in inches and store in inchesInt System.out.println("How tall are you in inches?"); String inchesStr = scan.nextLine(); scan.close(); int inchesInt = Integer.parseInt(inchesStr); /* Note that another option is to user nextInt() to read in * an integer from the keyboard, and then no need to convert */ // calculate feet and inches (12 inches in a foot) int feet = inchesInt/12; int in = inchesInt%12; // Print the resulting feet and inches to the console System.out.println("You are "+ feet + " ft " + in + " inches tall."); } }