Question

QUESTION Create the required java classes to store the students (id, name), the courses (id, title), the exam type (id, name)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

/* package whatever;*/

import java.util.*;
import java.lang.*;
import java.io.*;

//create class to store details of student
class Student
{
   int std_id;   //student id
   String std_name;   //student name
   int c_id;   //course id
   String c_name;   //course name
   int exam_id;   //exam id
   String[] exam_name = new String[5];       //string aray to store 5 type of exam
   int[] marks = new int[5];       //Array to store marks for each exam type
   float avg;   //To store average
  
  
   Student(int st_id, String s_name, int crs_id, String crs_name)
   {
   std_id = st_id;
       std_name = s_name;
       c_id = crs_id;
       c_name = crs_name;
      
       //Exam is same for all students
       exam_name[0] = "Quiz";
       exam_name[1] = "Homework";
       exam_name[2] = "Project";
       exam_name[3] = "Mid-Term";
       exam_name[4] = "Final";
   }
   //create methods

   //1) To store marks (in %) for student
   void storeMarks(int m[])
   {
       //copying the marks which has been passing in that function
       for(int i=0;i<5;i++)
           marks[i] = m[i];
   }
  
  
   // 2) To calculate average of each student
   // using formula (10*((A+B+C)/3)+20*D+70*E)/100
  
   void calAvg()
   {
      
       avg = (10*((marks[0]+marks[1]+marks[2])/3) + 20*marks[3] + 70*marks[4])/100;
      
       //display result
       System.out.println(std_id+" \t"+std_name+"\t"+marks[0]+"\t"+marks[1]+"\t"+marks[2]+"\t"+marks[3]+"\t"+marks[4]+"\t"+avg);
   }
}
class Main
{
   public static void main (String[] args) throws java.lang.Exception
   {
       Scanner in = new Scanner(System.in);
       //Create 4 student object
       Student std[] = new Student[4];
      
       //Enter all details of student
      
      
       for(int i=0;i<4;i++)
       {

  int st_id;
String s_name;
int crs_id;
String crs_name;
int m[] = new int[5];


           System.out.println("**Details for student "+(i+1)+"**");
           System.out.println("Enter student id: ");
           st_id = in.nextInt();
           in.nextLine();
           System.out.println("Enter student name: ");
           s_name = in.nextLine();
           System.out.println("Enter student's course id: ");
           crs_id = in.nextInt();
           in.nextLine();
           System.out.println("Enter student's course name: ");
           crs_name = in.nextLine();
          
           System.out.println("Enter student's marks ");
           for(int j=0;j<5;j++)
               m[j] = in.nextInt();
              
           //store
           std[i] = new Student(st_id,s_name,crs_id,crs_name);

   //call method to store marks
       for(int j=0;j<4;j++)
       {
           std[j].storeMarks(m);
       }
          
       }
      
      
       //calculate average and display result
       System.out.println("Student id Student name Quiz Homework Project Mid-Term Final Average");
       System.out.println();
       for(int i=0;i<4;i++)
       {
           std[i].calAvg();
       }
      
       //calculate course average
       float c_avg = 0;
       for(int i=0;i<4;i++)
       c_avg += std[i].avg;
      
       c_avg = c_avg/4;
       System.out.println("******************************************************************Course average "+c_avg);
   }
}

Output

**Details for student 1** Enter student id: 201920001 Enter student name: Ahmed Enter students course id: 222 Enter studentDataStructure Enter students marks 20 70 50 40 60 **Details for student 4** Enter student id: 201920004 Enter student name:

Add a comment
Know the answer?
Add Answer to:
QUESTION Create the required java classes to store the students (id, name), the courses (id, title),...
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
  • solve in java using Eclipse Question 6 Given a student information: Name, Surname, Quiz grade, Homework...

    solve in java using Eclipse Question 6 Given a student information: Name, Surname, Quiz grade, Homework grade, Project grade, Midterm grade and Final exam grade, Show students whose average is grater then or equal to class average in ascending order. Student average is calculated using this formula: 153 of quiz +158 of homework + 20% of project + 25% of midterm + 25% of final exam. Input specification: In the first line you will be given a number of students...

  • c++ implement a student class Determine the final scores, letter grades, and rankings of all students...

    c++ implement a student class Determine the final scores, letter grades, and rankings of all students in a course. All records of the course will be stored in an input file, and a record of each student will include the first name, id, five quiz scores, two exam scores, and one final exam score. For this project, you will develop a program named cpp to determine the final scores, letter grades, and rankings of all students in a course. All...

  • Create sql queries to find the following miscrosoft access compatible commands please 9. Courses for which...

    Create sql queries to find the following miscrosoft access compatible commands please 9. Courses for which at least three students earned a grade of A, showing the grade and the course code 10. Semesters when the highest number of courses have been scheduled, showing the semester name and the number of sections 11. (Extra) Professors that are not students, and students that are not professors, showing their ID and SSN 12. (Extra) Semesters for which all courses are taught by...

  • Write a c++ program which uses a structure having the indicated member names to store the...

    Write a c++ program which uses a structure having the indicated member names to store the following data: Name (student name) IDnum (student ID number) Tests (an array of three test scores) Average (average test score) Grade (course grade) The program will keep a list of three test scores for one student. The program may prompt the user for the name, ID number, and test scores, or these may be assigned within the program. The average test score will be...

  • Using Java: Create an array with the size of 10 and assign student details (Name, ID,...

    Using Java: Create an array with the size of 10 and assign student details (Name, ID, age and TotalMarks) to the array. Perform the Heap Sort to sort the students in ascending order based on their total marks. Steps: • Create the student list (use Random class in java to generate the age (15- 25) and total (0-100)) • Print the Student List in a table format • Perform Heap sort based on the total marks of the students •...

  • This is a C++ Program, I need the program broken up into Student.h, Student.cpp, GradeBook.h, GradeBook.cpp,...

    This is a C++ Program, I need the program broken up into Student.h, Student.cpp, GradeBook.h, GradeBook.cpp, and Main.cpp 1. The system must be able to manage multiple students (max of 5) and their grades for assignments from three different assignment groups: homework (total of 5), quizzes (total (total of 2) of 4), and exams 2. For each student record, the user should be able to change the grade for any assignment These grades should be accessible to the gradebook for...

  • in C++ You are to define a structure containing the id number, three test scores, and...

    in C++ You are to define a structure containing the id number, three test scores, and their average, for each student in a class of 20. The file pr2data.txt is included and contains the data. The program is to include the following: A function that reads 20 records of data from the file, finds the average for each student and prints each student’s record. A function that lists the ids and averages for all the students whose average is above...

  • Develop an interactive program to assist a Philosophy professor in reporting students’ grades for his PHIL-224.N1...

    Develop an interactive program to assist a Philosophy professor in reporting students’ grades for his PHIL-224.N1 to the Office of Registrar at the end of the semester. Display an introductory paragraph for the user then prompt the user to enter a student record (student ID number and five exam-scores – all on one line). The scores will be in the range of 0-100. The sentinel value of -1 will be used to mark the end of data. The instructor has...

  • Please help me with this program.You are to write a C++ program that will read in...

    Please help me with this program.You are to write a C++ program that will read in up to 15 students with student information and grades. Your program will compute an average and print out certain reports. Format: The information for each student is on separate lines of input. The first data will be the student�s ID number, next line is the students name, next the students classification, and the last line are the 10 grades where the last grade is...

  • Many classes calculate a final grade by using a weighted scoring system. For example, “Assignments” might...

    Many classes calculate a final grade by using a weighted scoring system. For example, “Assignments” might be worth 40% of your final grade. To calculate the grade for the Assignments category, the teacher takes the percentage earned on the assignments and multiplies it by the weight. So if the student earned a 90% total on the Assignments, the teacher would take 90% x 40, which means the student earned a 36 percent on the Assignments section. The teacher then calculates...

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