Question: Can you please help stop the program below from continous running: I am sure where the loop is breaking down Create a program that keeps
Can you please help stop the program below from continous running: I am sure where the loop is breaking down
Create a program that keeps track of specific information for Students. The information stored should be the following:
First Name, Last Name, Major, GPA, UIN, NetID, Age, Gender,
For this simple program we will only need to store 10 students in an ArrayList. Your students should be stored in an object called Student.
You should be able to add, display, remove, save and load Students in the ArrayList.
You should submit for grading 2 files: Lab6Driver.java and Student.java
Hint: Its MUCH easier to build your save method first, then cater your load method to how youve determined to save it.
Expert Answer
Anonymous answered this
Was this answer helpful?
0
0
375 answers
The required program is as follows:
Stud.java
class Stud
{
private String fName;
private String lName;
private String maj;
private String gpa;
private String IN;
private String id;
private String age;
private String gender;
public Stud(String fName, String lName,String maj, String gpa,String IN, String id, String age,String gender){
super();
this.fName = fName;
this.lName = lName;
maj = MAJ;
gpa = GPA;
id = ID;
IN = in;
int ch =input.nextInt();
switch(ch)
{
case 1: addStud(newStud)
break;
case 2: removeStud(newStud)
break;
case 3: displayStud(newStud)
break;
case 0: System.out.println("Thankyou for visiting.");
System.exit(0);
}
}
}
public static void addStud(ArrayList
Scanner scan= new Scanner(System.in);
boolean stud_add = false;
System.out.println("Please enter first name: ");
String fName = scan.next();
System.out.println("Please enter last name: ");
String lName = scan.next();
System.out.println("Please enter major: ");
String maj = scan.next();
System.out.println("Please enter GPA: ");
String gpa = scan.next();
System.out.println("Please enter UIN: ");
String IN = scan.next();
System.out.println("Please enter NetId: ");
String id = scan.next();
System.out.println("Please enter your age: ");
String age = scan.next();
System.out.println("Please enter your gender: ");
String gender = scan.next();
if(newStud.size()
{
newStud.add(new Stud(fName,lName,maj,gpa,IN,id,age,gender));
System.out.println("Entry added");
}
else
{
System.out.println(" Student Array Full....");
}
private static void dispStud(ArrayList
{
for(Stud s : newStud){
System.out.println(s);
}
}
private static void rmStud(ArrayList
{
Scanner scan = new Scanner(System.in);
System.out.println("Enter the UIN of the student to remove: ");
String IN = scan.nextLine();
for(Student s: newStud){
if(((Stud s).getIN().equals(in){
newStud.rm(s);
System.out.println("Student Entry Removed");
break;
}
else
{
System.out.println("Sorry.No such entry found"+in);
}
}
}
}
age = ag;
gender = gen;
}
public String getfName()
{
return fName;
}
public void setfName(String fName)
{
this.fName = fName;
}
public String getlName()
{
return lName;
}
public void setlName(String lName)
{
this.lName = lName;
}
public String getMaj()
{
return maj;
}
public void setMaj(String Maj)
{
this.maj = MAJ;
}
public String getgpa()
{
return gpa;
}
public void setgpa(String gpa)
{
gpa = GPA;
}
public String getIN()
{
return IN;
}
public void setIN(String IN)
{
IN = in;
}
public String getid()
{
return id;
}
public void setid(String id)
{
id = ID;
}
public String getage()
{
return age;
}
public void setage(String age)
{
age = ag;
}
public Sting getgender()
{
return gender;
}
public void setgender(String gender)
{
gender = gen;
}
public String getIN()
{
return null;
}
StudTest.java
import java.util.*;
public class StudTest
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
ArrayList
System.out.println("Welcome To Student List!!...");
System.out.println("Select a number from the Menu below: ");
while(true)
{
System.out.println("1. Add Student");
System.out.println("2. Remove Student");
System.out.println("3. Display Student");
System.out.pritnln("4. Exit");
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
