Question

Write a complete JAVA program, including comments (worth 2 pts -- include a good comment at...

Write a complete JAVA program, including comments (worth 2 pts -- include a good comment at the top and at least one more good comment later in the program), to process data for the registrar as follows: NOTE: Include prompts. Send all output to the screen. 1. Read in the id number of a student, the number of credits the student has, and the student’s grade point average (this is a number like 3.25). Print the original data right after you read it in. A typical set of values could be: 1234 21 2.25 Print something like this: student 1234 has 21 credits and has a grade point average of 2.25 2. If the student has 60 credits or less print this is a lowerclassman, otherwise print this is an upperclassman. Keep a count of how many upperclassmen there are. 3. Compute an adjusted gpa as follows: divide the number of credits by the gpa. Print this value. 4. If the adjusted gpa is 20 or greater, print a message saying this student is above average. Otherwise, print a message saying the student is not above average. 5. a.Compute how many credits the student needs to graduate with 120 credits. Print this message. b. Determine how many semesters it will take the student to graduate assuming the student takes 15 credits per semester. Print this value as an integer. For example, if the student has 80 credits, print “Student needs 40 credits to graduate. It will take 3 semesters to graduate.” (40/15 +1) But if student has 75 credits, there are 45 remaining to graduate, and that will also take 3 semesters. (45/15) So you many need to determine if the number of credits remaining is divisible by 15. 6. Repeat the entire series of calculations for the next student, and the next, until every student has been processed. You must decide how to tell when every student has been processed. Make sure that this method is described in a comment. 7. Print the following values with appropriate message: the total number of students. how many of the students are upperclassmen (#2 above). the percent (with 3 decimal places) of students who are upperclassmen. Suggestion: You will need two separate counters for these tasks.

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

JAVA CODE:

import java.util.*;
public class Registrar{
    public static int upperClassCounter;
    public static int studentCounter;
    public Registrar(){
        upperClassCounter = 0;
        studentCounter = 0;
    }
    // This program has all the functions from 1 to 5
    public void program(){
        Scanner sc = new Scanner(System.in);
        // Gets ID input
        System.out.println("Input the ID of the student: ");
        int id = sc.nextInt();
        // Gets the number of credits
        System.out.println("Input number of credits: ");
        int numcredits = sc.nextInt();
        // Gets GPA
        System.out.println("Input student's grade point average: ");
        double gpa = sc.nextDouble();
        // sstudentCounter is incremented by 1 everytime this function is called
        studentCounter += 1;
        // Prints the user input
        System.out.println("");
        System.out.println("Student's ID: " + id);
        System.out.println("Number of credits the student has: " + numcredits);
        System.out.println("Student's GPA: " + gpa);
        // Checks if the student is upperclassman or lowerclassman
        if (numcredits < 60){
            System.out.println("This is a lowerclassman.");
        }
        else{
            System.out.println("This is an upperclassman.");
            upperClassCounter += 1;
        }
        // Adjusted GPA is calculated
        double adjustedGPA = Math.round(numcredits*100 / gpa)/100;
        System.out.println("Adjusted GPA: " + adjustedGPA);
        // Checks if the student is above average or not
        if (adjustedGPA >= 20){
            System.out.println("The student is above average.");
        }
        else{
            System.out.println("The student is not above average.");
        }
        // Calculates the credits needed to graduate
        int creditsToGraduate = 120 - numcredits;
        System.out.println("Student needs " + creditsToGraduate + " credits to graduate.");
        // Calculates the semester needed to complete 
        double semesterNeeded;
        if(creditsToGraduate % 15 == 0){
            semesterNeeded = creditsToGraduate / 15;
        }
        else{
            semesterNeeded = (creditsToGraduate/15 + 1);
        }
        System.out.println(semesterNeeded);
    }
    public static void main(String[] args){
        Registrar r1 = new Registrar();
        // Gets number of students from the user
        System.out.println("Enter the number of students to process: ");
        Scanner sc = new Scanner(System.in);
        int numStudents = sc.nextInt();
        // This loop will keep running for all the students
        while(numStudents > studentCounter){
            r1.program();
        }
        System.out.println("");
        // Final information is printed
        System.out.println("Every Student has been processed.");
        System.out.println("Total number of students: " + studentCounter);
        System.out.println("Number of students who are upperclassmen: " + 
                upperClassCounter);
        double percentUpper = (double) Math.round((double) upperClassCounter * 100000 /(double) studentCounter) / 1000;
        System.out.printf("Percentage of students who are upperclassmen: " +  percentUpper);
    
    }
}

OUTPUT:

Enter the number of students to process: 5 Input the ID of the student: 1234 Input number of credits: 21 Input students grad

Input the ID of the student: 5698 Input number of credits: 60 Input students grade point average: 3 Students ID: 5698 Numbe

Add a comment
Know the answer?
Add Answer to:
Write a complete JAVA program, including comments (worth 2 pts -- include a good comment at...
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
  • Write a Java program, including comments, to compute statistics for how students did on an exam....

    Write a Java program, including comments, to compute statistics for how students did on an exam. The program should compute various things about a student and print it all out. Then it repeats the process for each new student until the entire set of data has been completed. (a) The program reads in and prints the ID number of a student [see step (g) below] and then the number of right answers and the number of wrong answers. (The total...

  • Write a C++ program to store and update students' academic records in a binary search tree....

    Write a C++ program to store and update students' academic records in a binary search tree. Each record (node) in the binary search tree should contain the following information fields:               1) Student name - the key field (string);               2) Credits attempted (integer);               3) Credits earned (integer);               4) Grade point average - GPA (real).                             All student information is to be read from a text file. Each record in the file represents the grade information on...

  • Task 2) Write and execute a C program using any C compiler to input students' number...

    Task 2) Write and execute a C program using any C compiler to input students' number of previous semesters attended and marks of all the modules he has studied. And do the following: a. Determine and display grade received for each module studied according to the following conditions: Condition Result Marks is greater than or equal to 91 A Marks is greater than or equal to 70 B Marks is greater than or equal to 50 D Otherwise F b....

  • Problem Specification: Write a C++ program to calculate student’s GPA for the semester in your class. For each student, the program should accept a student’s name, ID number and the number of courses...

    Problem Specification:Write a C++ program to calculate student’s GPA for the semester in your class. For each student,the program should accept a student’s name, ID number and the number of courses he/she istaking, then for each course the following data is needed the course number a string e.g. BU 101 course credits “an integer” grade received for the course “a character”.The program should display each student’s information and their courses information. It shouldalso display the GPA for the semester. The...

  • Write a complete Java program, including comments in both the main program and in each method,...

    Write a complete Java program, including comments in both the main program and in each method, which will do the following: 0. The main program starts by calling a method named introduction which prints out a description of what the program will do. This method is called just once.      This method is not sent any parameters, and it does not return a value. The method should print your name. Then it prints several lines of output explaining what the...

  • using java Program: Please read the complete prompt before going into coding. Write a program that...

    using java Program: Please read the complete prompt before going into coding. Write a program that handles the gradebook for the instructor. You must use a 2D array when storing the gradebook. The student ID as well as all grades should be of type int. To make the test process easy, generate the grade with random numbers. For this purpose, create a method that asks the user to enter how many students there are in the classroom. Then, in each...

  • In C++, write a complete program that receives a series of student records from the keyboard...

    In C++, write a complete program that receives a series of student records from the keyboard and stores them in three parallel arrays named studentID and courseNumber and grade. All arrays are to be 100 elements. The studentID array is to be of type int and the courseNumber and grade arrays are to be of type string. The program should prompt for the number of records to be entered and then receive user input on how many records are to...

  • [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and...

    [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and methods must be used for this program. Process: •Read the number of students in a class. Make sure that the user enters 1 or more students. •Create an array with the number of students entered by the user. •Then, read the name and the test score for each student. •Calculate the best or highest score. •Then, Calculate letter grades based on the following criteria:...

  • Write a program that determines how many terms 10 students need to graduate. Step 1. Create...

    Write a program that determines how many terms 10 students need to graduate. Step 1. Create an algorithm (either flowchart or pseudocode) that you will use to write the program. Place the algorithm in a Word document. Step 2. Code the program in Eclipse and ensure the following steps are accomplished. 1.  Define a two-dimension array with 10 rows and 2 columns. 2.  Prompt the user to enter the number of courses they have left to graduate (value must be between 1...

  • Write a program that determines how many terms 10 students need to graduate. Step 1. Create...

    Write a program that determines how many terms 10 students need to graduate. Step 1. Create an algorithm (either flowchart or pseudocode) that you will use to write the program. Place the algorithm in a Word document. Step 2. Code the program in Eclipse and ensure the following steps are accomplished. 1.  Define a two-dimension array with 10 rows and 2 columns. 2.  Prompt the user to enter the number of courses they have left to graduate (value must be between 1...

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