Question
in JAVA: student class: import java.util.ArrayList; import java.util.Scanner; public class Main { private String name; private int id; private String gender; private String major; private
in JAVA:
student class:
import java.util.ArrayList;
import java.util.Scanner;
public class Main
{
private String name;
private int id;
private String gender;
private String major;
private String college ;
private int minors;
public Main(String name, int id, String gender, String major, String college, int minors)
{
super();
this.name = name;
this.id = id;
this.gender = gender;
this.major = major;
this.college = college;
this.minors = minors;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public String getGender()
{
return gender;
}
public void setGender(String gender)
{
this.gender = gender;
}
public String getMajor()
{
return major;
}
public void setMajor(String major)
{
this.major = major;
}
public String getCollege()
{
return college;
}
public void setCollege(String college)
{
this.college = college;
}
public int minors()
{
return minors;
}
public void setminors(int minors)
{
this.minors = minors;
}
@Override
public String toString()
{
return " Student's 1) name: " + name + " 2) ID: " + id + " 3) gender: " + gender +" 4) major: " + major
+ " 5) college: " + college + " 6) minors number: " + minors ;
}
public static void main(String[] args)
{
String n;
int id;
String gen;
String maj;
String clg ;
int minors;
ArrayList
String flg = "yes";
Scanner sc = new Scanner(System.in);
while(!flg.equals("no"))
{
System.out.println("Enter student's name : ");
n = sc.next();
System.out.println("Enter student's ID and email (Bxxxxxxxx@aus.edu) ");
id = sc.nextInt();
System.out.println("Enter student's gender (Male/Female) : ");
gen = sc.next();
System.out.println("Enter student's major : ");
maj = sc.next();
System.out.println("Enter student's college : ");
clg = sc.next();
System.out.println("Enter student's minors number: ");
minors = sc.nextInt();
std.add(new Main(n, id, gen, maj, clg, minors));
System.out.println("Do you want to proceed? ");
flg = sc.next();
}
for (Main s : std)
{
System.out.println(s);
}
}
}
Student.txt:
Exercise 1: [Course.javal A Course has a name, a number, a course code, an offering department, an instructor, and an array of students registered. a. Define a class called Course with appropriate fields and provide the required constructor, accessor (get) and mutator (set) methods. The course's code can be created with the department and the number provided (e.g., Department: CMP Number: 256 course code: CMP 256). b. Override the toString() method to have the courses' details. c. Modify the existing Student class so that a student can have at least 2 courses registered for him/herStep 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