Question

In: Computer Science

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.

Solutions

Expert Solution

Java code for the given question:

import java.util.*;
public class SGrades{
public static void main(String args[]){

int sid=-1, ncredits=0;
float gpa=0;
Boolean cont = true;
String ip, nt;
char ct;

StringTokenizer st;
Scanner sc; //= new Scanner(System.in);

int count=0, uman=0, tk=0;

while (cont){

ip = "";
sc = new Scanner(System.in);
System.out.println("Enter Stud Id, No. of Credits and GPA");
sid = sc.nextInt();
ncredits = sc.nextInt();
gpa = sc.nextFloat();

count++;


System.out.println("Student " + sid + " has " + ncredits + " credits and has a grade point average of " + gpa);
if( ncredits <= 60 )
System.out.println("Student " + sid + " is a lowerclassman");
else{
System.out.println("Student " + sid + " is a upperclassman");
uman++;
}

float adj_gpa = ncredits / gpa;
System.out.println("Adjusted GPA for Student " + sid + " is: " + adj_gpa);

if( adj_gpa >= 20 )
System.out.println("Student " + sid + " is above average");
else
System.out.println("Student " + sid + " is a not above average");

int to_grad = 120 - ncredits;

System.out.println("Student " + sid + " needs " + to_grad + " credits to graduate");

int n_sems;
if ( to_grad%15 == 0 )
n_sems = to_grad / 15;
else
n_sems = (to_grad / 15) + 1;

System.out.println("Student " + sid + " needs " + n_sems + " semesters to graduate ");

//Asking the user to repeat the process for next student or not


System.out.println("Do you want to assess one more student(y/n)");
ct = sc.next().charAt(0);
if( ct== 'n' || ct=='N' )
cont = false;

//sc.close();


}

System.out.println("Total Number of Students: " + count);
System.out.println("Number of upperclassman: " + uman);
float uman_per = ((float)(uman/count)*100);
System.out.println("Percentage of upperclassman: "+ uman_per);
}
}


Related Solutions

Write a complete Java program, including comments in each method and in the main program, to...
Write a complete Java program, including comments in each method and in the main program, to do the following: Outline: The main program will read in a group of three integer values which represent a student's SAT scores. The main program will call a method to determine if these three scores are all valid--valid means in the range from 200 to 800, including both end points, and is a multiple of 10 (ends in a 0). If the scores are...
Write a complete Java program, including comments in each method and in the main program, to...
Write a complete Java program, including comments in each method and in the main program, to do the following: Outline: The main program will read in a group of three int||eger values which represent a student's SAT scores. The main program will call a method to determine if these three scores are all valid--valid means in the range from 200 to 800, including both end points, and is a multiple of 10 (ends in a 0). If the scores are...
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...
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...
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...
Write the following program in java please. a. Include a good comment when you write the...
Write the following program in java please. a. Include a good comment when you write the method described below: Method method1 receives an integer, n, and a real number, d, and returns a real number. If the integer is positive it returns the square root of the real number added to the integer. If the integer is negative or zero it returns the absolute value of the integer multiplied by the real number. b. Write the statements from the main...
Hello, Please write this program in java and include a lot of comments and please try...
Hello, Please write this program in java and include a lot of comments and please try to make it as simple/descriptive as possible since I am also learning how to code. The instructions the professor gave was: Create your own class Your own class can be anything you want Must have 3 instance variables 1 constructor variable → set the instance variables 1 method that does something useful in relation to the class Create a driver class that creates an...
Please write a complete C coding program (NOT C++) that has the following: (including comments) -...
Please write a complete C coding program (NOT C++) that has the following: (including comments) - declares two local integers x and y - defines a global structure containing two pointers (xptr, yptr) and an integer (z) - declares a variable (mst) by the type of previous structure - requests the values of x and y from the user using only one scanf statement - sets the first pointer in the struct to point to x - sets the second...
C++ Download the attached program and complete the functions. (Refer to comments) main.cpp ~ #include #include...
C++ Download the attached program and complete the functions. (Refer to comments) main.cpp ~ #include #include #define END_OF_LIST -999 using namespace std; /* * */ int exercise_1() { int x = 100; int *ptr; // Assign the pointer variable, ptr, to the address of x. Then print out // the 'value' of x and the 'address' of x. (See Program 10-2) return 0; } int exercise_2() { int x = 100; int *ptr; // Assign ptr to the address of...
Comments : For each function in your program, you must include a comment block that includes...
Comments : For each function in your program, you must include a comment block that includes a name of the function, the input parameters of the function, and the return type of the function. Use short phrase descriptions to describe each. Guard Conditions and Exception Handling: This time, your program must guard against common errors. An empty vector cannot be used for a variance or standard deviation. A file must be opened correctly. A file must be written to correctly....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT