Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN JAVA I provided Q1 answer with this question. PLEASE ANSWER Q 2 ONLY. QUESTION 1: QUESTION 1 ANSWER: import java.util.ArrayList; import java.util.Scanner; public class

IN JAVA

I provided Q1 answer with this question.

PLEASE ANSWER Q 2 ONLY.

QUESTION 1:

image text in transcribed

QUESTION 1 ANSWER:

import java.util.ArrayList; import java.util.Scanner;

public class Student { private String name; private int id; private String gender; private String email; private String major; private String college ; private int numberOfMinors; //a. Define a class called Student with appropriate fields and provide the required constructor, accessor (get) and mutator (set) methods. The students email address can be created with the gender and id provided (e.g., b0001234@aus.edu). public Student(String name, int id, String gender, String email, String major, String college, int numberOfMinors) { super(); this.name = name; this.id = id; this.gender = gender; this.email = email; this.major = major; this.college = college; this.numberOfMinors = numberOfMinors; } 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 getEmail() { return email; }

public void setEmail(String email) { this.email = email; }

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 getNumberOfMinors() { return numberOfMinors; }

public void setNumberOfMinors(int numberOfMinors) { this.numberOfMinors = numberOfMinors; } //b. Override the toString() method to have the students details. @Override public String toString() { return "Student [name=" + name + ", id=" + id + ", gender=" + gender + ", email=" + email + ", major=" + major + ", college=" + college + ", numberOfMinors=" + numberOfMinors + "]"; }

public static void main(String[] args) { // c. Develop a program that prompts the user to enter the students details and creates an array of students using values provided by the user. Each line of the user input represents name, ID, gender, a major, a college and the number of minors of a student. The user can end the input sequence by entering no. String n; int id; String gen; String mail; String maj; String clg ; int minors; ArrayList std = new ArrayList(); String flg = "yes"; Scanner sc = new Scanner(System.in); while(!flg.equals("no")) { System.out.println("Enter studen name : "); n = sc.next(); System.out.println("Enter studen ID : "); id = sc.nextInt(); System.out.println("Enter studen gender : "); gen = sc.next(); System.out.println("Enter studen a major : "); maj = sc.next(); System.out.println("Enter studen a college : "); clg = sc.next(); System.out.println("Enter number of minors : "); minors = sc.nextInt(); //The students email address can be created with the gender and id provided mail = gen + id + "@aus.edu"; std.add(new Student(n, id, gen, mail, maj, clg, minors)); System.out.println("Are you want continue the input sequence"); flg = sc.next(); } System.out.println("================= Student Details================="); for (Student s : std) { System.out.println(s); } } }

QUESTION 2:

image text in transcribed

A Student has a name, an ID, a gender, an email address, major, college and number of minors. a. Define a class called Student with appropriate fields and provide the required constructor, accessor (get) and mutator (set) methods. The student's email address can be created with the gender and id provided (e.g., b0001234@aus.edu). b. Override the toString() method to have the students details. c. Develop a program that prompts the user to enter the students details and creates an array of students using values provided by the user. Each line of the user input represents name, ID, gender, a major, a college and the number of minors of a student. The user can end the input sequence by entering no. d. Print the number of students entered by the user and the details of the students entered. A Student can have zero or more minors (maximum of 3 minors). A minor has a Minor Name, a Minor_Department. a. Define a class called Minor with appropriate fields and provide the required constructor, accessor (get) and mutator (set) methods. You should also consider the relationship between the Student and Minor classes. b. Modify the main program developed in Exercise lc such that, for each Student who has minors, the program prompts the user to enter the minor's name and department. c. Modify the main program to give the user the options to do the following: 1. Print details of all students including the number of minors they take. 2. Print the details of the students who have minors. Each student on two lines: one for the student and one for its minors, if they exist. 3. Print the names of the students who have more than 1 minor. 4. Exit the program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions