We created a person whose name is "quit" - probably not what the programmer had in mind.

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
100%

We created a person whose name is "quit" - probably not what the programmer had in mind. Fix this bug 

IJ
File Edit View Navigate Code Analyze Refactor Build Run Iools VCS Window Help
Main - Main.java
Main
src G Main m main
Main
O Project -
G Main.java
Person.java X
v Main CAUsers\Tsuiy\ldeaProjects\Main
1
Gimport java.util.ArrayList;
A 1
.idea
Aimport java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner keyboardScanner = new Scanner (System.in);
> out
2
src
C Main
3
O Person
4 >
. Main.iml
> ulı External Libraries
PO Scratches and Consoles
6
ArrayList<Person> people = new ArrayList<>();
7
8.
System.out.println("hello world");
9.
String input
II II .
%3D
10
while (!input.trim().toLowerCase ().equals("quit")) {
11
System.out.println("enter your name: ");
12
input = keyboardScanner.nextLine();
13
Person p = new Person (input.trim());
14
people.add(p);
15
p.print();
16
17
System.out.println("These are the people");
- ");
System.out.println(":
for (Person p:people){
18
19
20
p.print();
22
}
23
System.out.println("Bye.. .");
24
}
25
}
26
avorites . Structure
Transcribed Image Text:IJ File Edit View Navigate Code Analyze Refactor Build Run Iools VCS Window Help Main - Main.java Main src G Main m main Main O Project - G Main.java Person.java X v Main CAUsers\Tsuiy\ldeaProjects\Main 1 Gimport java.util.ArrayList; A 1 .idea Aimport java.util.Scanner; public class Main { public static void main(String[] args){ Scanner keyboardScanner = new Scanner (System.in); > out 2 src C Main 3 O Person 4 > . Main.iml > ulı External Libraries PO Scratches and Consoles 6 ArrayList<Person> people = new ArrayList<>(); 7 8. System.out.println("hello world"); 9. String input II II . %3D 10 while (!input.trim().toLowerCase ().equals("quit")) { 11 System.out.println("enter your name: "); 12 input = keyboardScanner.nextLine(); 13 Person p = new Person (input.trim()); 14 people.add(p); 15 p.print(); 16 17 System.out.println("These are the people"); - "); System.out.println(": for (Person p:people){ 18 19 20 p.print(); 22 } 23 System.out.println("Bye.. ."); 24 } 25 } 26 avorites . Structure
IJ
File Edit View Navigate Code Analyze Refactor Build Run Iools VCS Window Help
Main - Person.java
Main
src G Main
Main
O Project -
G Main.java X
© Person.java
v Main CAUsers\Tsuiy\ldeaProjects\Main
1
public class Person {
A1
.idea
> out
2
private String name;
src
C Main
O Person
4
Person (String aName){
Main.iml
> ulı External Libraries
name = aName;
PO Scratches and Consoles
}
8.
public void print(){
9.
System.out.println("Person:
+ name);
10
11
12
E TODO
e Problems
華 Debug
2 Terminal
KBuild
3 Event Log
O All files are up-to-date (5 minutes ago)
12:1 CRLF UTF-8 4 spaces
* Favorites . Structure
Transcribed Image Text:IJ File Edit View Navigate Code Analyze Refactor Build Run Iools VCS Window Help Main - Person.java Main src G Main Main O Project - G Main.java X © Person.java v Main CAUsers\Tsuiy\ldeaProjects\Main 1 public class Person { A1 .idea > out 2 private String name; src C Main O Person 4 Person (String aName){ Main.iml > ulı External Libraries name = aName; PO Scratches and Consoles } 8. public void print(){ 9. System.out.println("Person: + name); 10 11 12 E TODO e Problems 華 Debug 2 Terminal KBuild 3 Event Log O All files are up-to-date (5 minutes ago) 12:1 CRLF UTF-8 4 spaces * Favorites . Structure
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Structure chart
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
  • SEE MORE 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