Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 ) Explain where and why the program went wrong / and or not a good ( use line numbers ) . 2 ) Fix
Explain where and why the program went wrongand or not a good use line numbers
Fix them to get accurate results and smart program You don't have to rewrite the whole program, just explain how to fix them use line numbers
import java.util.;
import java.io;
class Personinfo
String type;
String name;
String gender;
int age;
public class People
static ArrayList List new ArrayList;
People String file throws FileNotFoundException
Scanner input new Scanner new File peopletxt;
while inputhasNext
PersonInfo p new PersonInfo;
ptype input.next;
pname input.next;
pgender input.next;
page input.nextInt;
list.addp;
public void listString occupation
String typeString ;
if occupationequalss
typeString "student";
ifoccupationequalst
typeString "teacher";
System.out.printlnList of people";
System.out.printfType: s
typeString;
for int i ; i list.size; i
if listgetitype.equalstypeString
System.out.printlnlistgeti;name;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started