Scanner class needs to be imported at the very beginning of your program before your class declaration for all three mini-programs with:
import java.util.Scanner;
Write a complete program that prompts the user for two integers and then calculates and prints the following report to the screen, exactly as shown.
For example, using 23 and 18 as the user input:
Your numbers are: 23 and 7.
Sum: 30
Subtraction: 16
Multiplication: 161
Division: 3
Remainder of Division: 2
Use the Scanner method nextInt() to read the user's numbers. Include in the declaration area:
// instantiate a new scanner and assign it to variable 'keyboard'
Scanner keyboard = new Scanner(System.in);
// initialize both operands to 0;
int firstNumber = 0;
int secondNumber = 0;
...
// Prompt the user to get the first operand then read in an integer
System.out.print("Enter the first number: ");
firstNumber = keyboard.nextInt();
...
Write a complete progrma that prompts users to enter their first name, middle name, and last name (separately). Print out their name and initials, exactly as shown:
Your name is: John Paul Chavez.
Your initials are: J.P.C
Use the Scanner method nextLine() to read the user's names:
Scanner keyboard = new Scanner(System.in)
// Prompt user here
String firstName = keyboard.nextLine();
Use the String method charAt() to extract the first (zero-th) character from each name part (the name parts are String type):
char firstInitial = firstName.charAt(0)
Write a complete program that prompts the user to enter a food item and the number of calories it contains. The program computes and outputs how many minutes the user would need to walk to burn off those calories.
Formula (truncate the result): walking time in minutes = (int)(calories / 5.4).
Use the Scanner methods nextLine() and nextInt() to read the input values:
Scanner keyboard = new Scanner(System.in);
Sample output:
// Prompt user here
Food: York Peppermint Pattie // Food
Calories: 150 // Calories
Minutes to walk: 27 // Calculated