Skip to content

Instantly share code, notes, and snippets.

@dhust
Last active September 15, 2016 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhust/fc40657512bc3d188b206af303a5de32 to your computer and use it in GitHub Desktop.
Save dhust/fc40657512bc3d188b206af303a5de32 to your computer and use it in GitHub Desktop.
public static void main(String[] args) {
// Variables
Scanner in = new Scanner(System.in);
int shapeLength;
String shape;
// Get length and shape from the user
System.out.print("Enter the length of the shape: ");
shapeLength = in.nextInt();
System.out.print("Enter the name of the shape: ");
shape = in.nextLine();
/* If BOTH "shapeLength < 100" AND
* "shape.equalsIgnoreCase("square")" are TRUE
* then the body of that code will run
*/
if (shapeLength < 100 && shape.equalsIgnoreCase("square")) {
System.out.println("That square is small.");
}
else if (shapeLength >= 100 && shape.equalsIgnoreCase("square")){
System.out.println("That square is large.");
}
else {
System.out.println("I only like squares.");
}
// Close the scanner
in.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment