Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Describe the general purpose of a Scanner. Consider the following code snippet:

ID: 3805349 • Letter: D

Question

Describe the general purpose of a Scanner. Consider the following code snippet: Scanner consoleIn = new Scanner(System.in); int count; String desc; count = consoleIn.nextInt(); desc = consoleIn.nextLine(); System.out.println("Count: " + count + " Description: " + desc); What is printed if the program receives the following input? 10 Pencils What would we have to do to the code in the previous question to make it print "Count: 10 Description: Pencils" when given the above input? (Do not hard code that output. Use data read from the console.) Why does your change fix the problem?

Explanation / Answer

Question 11

Answer:

Scanner is a class that can be used for read a standard input from the console. we can read any type of the standard inputs from Scanner such as Integer, Double, String, Char etc.

Question 12

Answer: This is the output that will be printed in the console

Count: 10 Description:

Question 13:

Answer:

we have to make the beloww which is highlighted below

Scanner consoleIn = new Scanner(System.in);
       int count;
       String desc;
       count = consoleIn.nextInt();
       desc= consoleIn.next();
       System.out.println("Count: "+count+" Description: "+desc);

Output:

10
Pencils
Count: 10 Description: Pencils

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote