Created
August 1, 2013 19:32
-
-
Save dhust/6134479 to your computer and use it in GitHub Desktop.
IO - Complex example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Declare variables | |
Scanner input = new Scanner(System.in); | |
String favoriteFood; | |
int numberOfCandyBarsUserCanEat; | |
// Ask user for favorite food | |
System.out.print("What is your favorite food? "); | |
// Store response | |
favoriteFood = input.next(); | |
// Ask user number of candy bars they can eat | |
System.out.print("How many candy bars can you eat? "); | |
// Store response | |
numberOfCandyBarsUserCanEat = input.nextInt(); | |
// Print their responses | |
System.out.printf("Favorite food = %s, number of candy bars you can eat = %d", favoriteFood, numberOfCandyBarsUserCanEat); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment