java This question concerns the following situation in a wel

java

This question concerns the following situation: in a well-known University department, the students are studying subjects in different majors. After enrolment, a list is formed of all the Study objects (each having instance variables student, subjCode, major and the corresponding getter methods). Assume that the enrollment is correct (e.g. no student in the same subject more than once, each subject with the same major each time, etc). After the list containing the Study objects is formed, it will be processed and output is printed, which gives on each line a major and the number of students qualified for that major. A student is defined to be qualified for a major provided the student is enrolled in at least two subjects of that major. The printout only gives majors where at least one student qualified, and the printout must be sorted in ascending order of number of students. Show how to design software that accepts a list of study objects, and prints the desired report Your answer should describe the data structures that you would use in your software, and indicate by pseudocode the calculation you would perform; also write down and justify the big-Oh worst case cost of your solution. If you invoke one or more of the algorithms that was taught this semester in INF01105, you do not need to explain that algorithm in detail (for example, if you say \"perform a pre-order traversal\", you are not expected to describe the details of how pre-order traversal is performed). A clearly described correct but inefficient solution will gain at least half the marks. For example, for the following enrollment (each Study object is shown as a tuple ) the output should look like: MAJOR NUMBER QUALIFIED STUDENTS ElecEng1 IT2 Observe that two students are qualified to major in IT (30600001 is enrolled in both INF01105 and INF01003; and 30600002 is enrolled in both INF01103 and INF01003), while only one student is qualified to major in ElecEng (this student is 30600001, who is enrolled in both ELEC1603 and ELEC1601; on the other hand student 3600002 is not qualified to major in ElecEng as they are enrolled in only one subject of this major, and student 30600003 is also not qualified for this major as they are enrolled in only one subject of the major).

Solution

package student;

import java.util.*;

public class Student {

public static void main(String[] args) {

   int i, q, z, c, b;

   int x=0;

   String[] name = new String[30];

   int[] age = new int[30];

   String[] course = new String[30];

   String[] year = new String[30];

   String[] section = new String[30];

   int menuChoice;

   Scanner input = new Scanner (System.in);

   start:

   do{

       System.out.println(\"\\t\\t\\tStudent Record Menu\");

       System.out.println(\"\\t\\t1. Add Student\\t2. View Students\\t3. Search Student\\t4. Exit\");

       System.out.println(\"Enter a choice: \");

       menuChoice = input.nextInt();

       if (menuChoice==1)

       {

           for (z=x; z<=29; z++)

           {

               System.out.println(\"Full name:\");

               name [z] = input.nextLine();

               System.out.println(\"Age:\");

               age [z] = input.nextInt();

               System.out.println(\"Course:\");

               course [z] = input.next();

               System.out.println(\"Year:\");

               year [z] = input.next();

               System.out.println(\"Section:\");

               section [z] = input.next();

               x++;

               continue start;

           }

       }

               else if (menuChoice==2)

               {

                   for (i=0; i<x; i++)

                   {

                       System.out.println(name[i] + age [i] + course [i] + year [i] + section [i]);

                   }

               }

   } while (menuChoice<4);

}

}

java This question concerns the following situation: in a well-known University department, the students are studying subjects in different majors. After enrolm
java This question concerns the following situation: in a well-known University department, the students are studying subjects in different majors. After enrolm

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site