1 import java.util.Scanner; 2 class Question1 { 3 public static void main(String[] args) { 4 5 6 7 8 9 10 11 12 13} } Scanner keyboard = new Scanner(System.in); System.out.print("Enter your name: "); String name keyboard.nextLine(); System.out.print("Enter number of children you have: "); String numChildren = keyboard.nextLine(); System.out.println("Hi" + name); System.out.println("If you adopt another child, you would have " + numChildren + 1 + " children"); Consider the following sample run showing the user interaction with this program: $java Question1 Enter your name: Jane Doe Enter number of children you have: 2 What will the first line of output after the prompts for this program be? A. Hi name B. HiJane Doe OC. Hi Jane Doe

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
1. The following Java program is used for both Question 1 and Question 2:
1 import java.util.Scanner;
2 class Question1 {
3 public static void main(String[] args) {
4
5
6
7
8
9
10
11
12 }
13}
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter your name: ");
String name keyboard.nextLine();
System.out.print("Enter number of children you have: ");
String numChildren = keyboard.nextLine();
System.out.println("Hi" + name);
System.out.println("If you adopt another child, you would have
numChildren + 1 + " children");
Consider the following sample run showing the user interaction with this program:
$ java Question1
Enter your name: Jane Doe
Enter number of children you have: 2
What will the first line of output after the prompts for this program be?
A. Hi name
B. HiJane Doe
C. Hi Jane Doe
"
Transcribed Image Text:1. The following Java program is used for both Question 1 and Question 2: 1 import java.util.Scanner; 2 class Question1 { 3 public static void main(String[] args) { 4 5 6 7 8 9 10 11 12 } 13} Scanner keyboard = new Scanner(System.in); System.out.print("Enter your name: "); String name keyboard.nextLine(); System.out.print("Enter number of children you have: "); String numChildren = keyboard.nextLine(); System.out.println("Hi" + name); System.out.println("If you adopt another child, you would have numChildren + 1 + " children"); Consider the following sample run showing the user interaction with this program: $ java Question1 Enter your name: Jane Doe Enter number of children you have: 2 What will the first line of output after the prompts for this program be? A. Hi name B. HiJane Doe C. Hi Jane Doe "
2. Consider the following sample run showing the user interaction with the above program:
$java Question1
Enter your name: Jane Doe
Enter number of children you have: 2
What will the second line of output after the prompts for this program be?
A. If you adopt another child, you would have 3 children
B. If you adopt another child, you would have 21 children
C. You have a lot of children
D. None of the above
Transcribed Image Text:2. Consider the following sample run showing the user interaction with the above program: $java Question1 Enter your name: Jane Doe Enter number of children you have: 2 What will the second line of output after the prompts for this program be? A. If you adopt another child, you would have 3 children B. If you adopt another child, you would have 21 children C. You have a lot of children D. None of the above
Expert Solution
Step 1
The Scanner class is used to get user input and it is found in the java.util package.
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Adjacency Matrix
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education