Assignment #14: More Variables and Printing
Code
/// Name: Kiran O'Farrell
/// Period: 7
/// Program name: More Variables and Printing
/// File Name: MoreVariables.java
/// Date Finished: 9/2/15
public class MoreVariables {
public static void main(String[] args) {
String name, eyes, teeth, hair;
int age, height, weight;
name = "Kiran O'Farrell";
age = 15; // not a lie
height = 68; // inches
weight = 130; // lbs
eyes = "brown";
teeth = "white";
hair = "black";
System.out.println( "Let's talk about " + name + "." );
System.out.println( "He's " + height + " inches tall. That's " + (2.54 * height) + " centimeters.");
System.out.println( "He's " + weight + " pounds. That's " + (0.453592 * weight) + " kilograms.");
System.out.println( "Actually, that's not too heavy." );
System.out.println( "He's got " + eyes + " eyes and " + hair + " hair." );
System.out.println( "His teeth are usually " + teeth + " depending on the coffee." );
// This line is tricky; try to get it exactly right.
System.out.println( "If I add " + age + ", " + height + ", and " + weight
+ " I get " + (age + height + weight) + "." );
}
}
Picture of the output