Question

Problem Statement: Registrar’s Office. This registrar keeps a record of undergraduate students and graduate students. They...

Problem Statement: Registrar’s Office.

This registrar keeps a record of undergraduate students and graduate students.

They want us to write an app that stores their students and displays them to the user.

For each undergrad student, the app will show the name of the student, the student’s id, whether (true/false) the student is going to graduate school and the student’s high school.

For each grad student, the app will show the name of the student, the student’s id, the class that is taught by the student, and whether (true/false) the student is a research assistant.

The user can then select a student and be given the opportunity to take one of two actions:
Action 1: List all of the graduate students that are research assistants

Action 2: Pick a random undergraduate student from the list and set their isGoingToSchool instance variable to true.

The app must redisplay the updated list of students to allow the user to once again choose an action to perform on the list.

Class Student: String name, int id
Class UnderGrad: String highSchool, boolean isGoingToGradSchool

Class Grad: String classTaught, boolean is a research assistant

Special Note: Please complete in Java using BlueJ and make it as simple as possible. Please provide notes for understanding. Thank you.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

class Student {//student class
   protected String name;
   protected int id;

   public Student(String name, int id) {
       this.name = name;
       this.id = id;
   }
}

class UnderGrad extends Student {//undergrade class
   private String highSchool;
   private boolean isGoingToSchool;

   public UnderGrad(String name, int id, String highSchool, boolean isGoingToSchool) {
       super(name, id);
       this.highSchool = highSchool;
       this.isGoingToSchool = isGoingToSchool;
   }

   public void setGoingToSchool(boolean isGoingToSchool) {//setting value
       this.isGoingToSchool = isGoingToSchool;
   }

   @Override
   public String toString() {//for showing details of the under grad
       return "Name: " + name + "\nID: " + id + "\nHigh School: " + highSchool + "\n Is Going To School: "
               + isGoingToSchool;
   }
}

class Grad extends Student {//grad class
   private String classTaught;
   private boolean isAResearchAssistant;

   public Grad(String name, int id, String classTaught, boolean isAResearchAssistant) {
       super(name, id);
       this.classTaught = classTaught;
       this.isAResearchAssistant = isAResearchAssistant;
   }

   public boolean isAResearchAssistant() {//getting value
       return isAResearchAssistant;
   }

   @Override
   public String toString() {//showing details of grad
       return "Name: " + name + "\nID: " + id + "\nClass Taught: " + classTaught + "\n Is a Research Assistant: "
               + isAResearchAssistant;
   }
}

public class Test {// driver class for testing
   public static void main(String[] args) throws IOException {
       // for taking console input
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

       /* object of Students */
       //add more students accordingly
       ArrayList<UnderGrad> ug = new ArrayList<UnderGrad>();
       ug.add(new UnderGrad("John Wisley", 1, "Something High School", false));
       ug.add(new UnderGrad("Smantha Joe", 2, "Something High School", false));
       ug.add(new UnderGrad("Dave Parker", 3, "Anything High School", false));

       ArrayList<Grad> g = new ArrayList<>();
       g.add(new Grad("Willy Williams", 4, "Science", true));
       g.add(new Grad("Sam Bran", 5, "Maths", false));
       g.add(new Grad("Joe Kent", 6, "English", true));

       System.out.println("*********Registrar Records*********");
       System.out.println();

       while (true) {// infinite loop
           // showing options
           System.out.println("1. Action 1(list research assistant)");
           System.out.println("2. Action 2(change isGoingToSchool to true)");
           System.out.println("3. Exit");
           System.out.println();

           System.out.print("Enter your choice: ");
           int choice = Integer.parseInt(br.readLine());// taking user choice
           switch (choice) {// switch case

           case 1:// for action 1
               System.out.println("List of Graduate Students who are research assistant");
               for (Grad i : g) {
                   if (i.isAResearchAssistant()) {//shwoing research assistant students
                       System.out.println(i);
                       System.out.println();
                   }
               }
               break;

           case 2:// for for action 2
               //getting the random value which will be 1 less than the size of the arraylist
               int ran = (int) (Math.random() * (ug.size()-1));
               ug.get(ran).setGoingToSchool(true);//setting true in the randome value
               System.out.println("List of all Graduate Students after update");
               for (UnderGrad i : ug) {
                   System.out.println(i);
                   System.out.println();
               }
               break;

           case 3:
               System.out.println();
               System.out.println("Thank you for using this app");
               System.exit(0);// exiting the app

           default:
               System.out.println("Wrong Choice! Try Again");
               break;
           }
       }
   }
}

Output

terminated> Test (1) [Java Application] C:\Program Files\Java\jre1.8.0_211\bin\javaw.exe (05-Jul-2019, 12:40:03 pm) Registrar1. Action 1(list research assistant) 2. Action 2(change isGoingToSchool to true) 3. Exit Enter your choice: 2 List of all Gra

UML

Java Class> Test Java Class>> Student (default package) (default package) Test main(String): void name: String id: int Studen

Add a comment
Know the answer?
Add Answer to:
Problem Statement: Registrar’s Office. This registrar keeps a record of undergraduate students and graduate students. They...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PART I: Create an abstract Java class named “Student” in a package named “STUDENTS”. This class...

    PART I: Create an abstract Java class named “Student” in a package named “STUDENTS”. This class has 4 attributes: (1) student ID: protected, an integer of 10 digits (2) student name: protected (3) student group code: protected, an integer (1 for undergraduates, 2 for graduate students) (4) student major: protected (e.g.: Business, Computer Sciences, Engineering) Class Student declaration provides a default constructor, get-methods and set-methods for the attributes, a public abstract method (displayStudentData()). PART II: Create a Java class named...

  • Student class: Instance variables name id Constructors: Default constructor Constructor that has id and name passed...

    Student class: Instance variables name id Constructors: Default constructor Constructor that has id and name passed to the constructor Methods: Accessors int getID( ) String getName( ) Class Roster: This class will implement the functionality of all roster for school. Instance Variables a final int MAX_NUM representing the maximum number of students allowed on the roster an ArrayList storing students Constructors a default constructor should initialize the list to empty strings a single parameter constructor that takes an ArrayList<Student> Both...

  • Writing 3 Java Classes for Student registration /** * A class which maintains basic information about...

    Writing 3 Java Classes for Student registration /** * A class which maintains basic information about an academic course. */ public class Course {    /** * Attributes. */ private String code; private String title; private String dept; // name of department offering the course private int credits; /** * Constructor. */ public Course(String code, String title, int credits) { // TODO : initialize instance variables, use the static method defined in // Registrar to initialize the dept name variable...

  • We wish to keep track of student advisees. Each advisee consists of a name, student id, concentra...

    We wish to keep track of student advisees. Each advisee consists of a name, student id, concentration, number of hours completed, name of advisor, whether or not they have completed a major sheet for graduation and whether or not they have filed an intent to graduate. An advisor needs the ability to: o update as well as access each advisee’s information o display all student advisees in the system including all information formatted as shown in the example o display...

  • Principles of Computer Science

    Question First, you need to design, code in Java, test and document a base class, Student. The Student class will have the following information, and all of these should be defined as Private: A. Title of the student (eg Mr, Miss, Ms, Mrs etc) B. A first name (given name) C. A last name (family name/surname) D. Student number (ID) – an integer number (of type long) E. A date of birth (in day/month/year format – three ints) - (Do NOT use the Date class from...

  • Java Project In Brief... For this Java project, you will create a Java program for a...

    Java Project In Brief... For this Java project, you will create a Java program for a school. The purpose is to create a report containing one or more classrooms. For each classroom, the report will contain: I need a code that works, runs and the packages are working as well The room number of the classroom. The teacher and the subject assigned to the classroom. A list of students assigned to the classroom including their student id and final grade....

  • n JAVA, students will create a linked list structure that will be used to support a...

    n JAVA, students will create a linked list structure that will be used to support a role playing game. The linked list will represent the main character inventory. The setting is a main character archeologist that is traveling around the jungle in search of an ancient tomb. The user can add items in inventory by priority as they travel around (pickup, buy, find), drop items when their bag is full, and use items (eat, spend, use), view their inventory as...

  • A survey of a random sample of 400 Telfer undergraduate students in third or fourth year...

    A survey of a random sample of 400 Telfer undergraduate students in third or fourth year was carried out to gather information for research about student life. Questions were asked about demographic characteristics, grades, study habits, and leisure activities. Here are some of the variables for which data were collected (they are labeled V1 through V9. for convenience). Assume that quantitative variables are normally distributed • V1: First-year overall grade (percent) • V2: Gender (1 male, 2-female) • V3: Opinion...

  • cs55(java) please Part 1: You are a programming intern at the student transfer counselor's office. Having...

    cs55(java) please Part 1: You are a programming intern at the student transfer counselor's office. Having heard you are taking CS 55, your boss has come to ask for your help with a task. Students often come to ask her whether their GPA is good enough to transfer to some college to study some major and she has to look up the GPA requirements for a school and its majors in a spreadsheet to answer their question. She would like...

  • Information About This Project             In the realm of database processing, a flat file is a...

    Information About This Project             In the realm of database processing, a flat file is a text file that holds a table of records.             Here is the data file that is used in this project. The data is converted to comma    separated values ( CSV ) to allow easy reading into an array.                         Table: Consultants ID LName Fee Specialty 101 Roberts 3500 Media 102 Peters 2700 Accounting 103 Paul 1600 Media 104 Michael 2300 Web Design...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT