Question: Using a object to read input requires that data type entered must match the data type expected by the program ( and vice versa )
Using a object to read input requires that data type entered must match the data type expected by the program and vice versa Run the program provided in the template below. Enter data as follows:What is your age?
What is your income?
What is your name? YourNameHere
import java.util.Scanner; Needed for the Scanner class
This program has a problem reading input.
public class InputProblem
public static void mainString args
String name; To hold the user's name
int age; To hold the user's age
double income; To hold the user's income
Create a Scanner object to read input.
Scanner keyboard new ScannerSystemin;
Get the user's age.
System.out.printWhat is your age? ;
age keyboard.nextInt;
Get the user's income
System.out.printWhat is your annual income? ;
income keyboard.nextInt;
Get the user's name.
System.out.printWhat is your name? ;
keyboard.nextLine;
name keyboard.nextLine;
Display the information back to the user.
System.out.printlnHello name Your age is
age and your income is $
income;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
