Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


yogi
java
0 Answer(s)      3 years and a month ago
Posted in : Java Beginners


You've been asked to write a program that records a student's grades and calculates the average grade and the GPA. All input and output should take place on the console. To calculate the GPA, you will need to record the final grade and the credit value for each course the student has taken in the term. A student can take any number of courses in a term, and you don't know how many courses the student is recording while the program runs. You will need to continually ask the user if they'd like to enter more data, and if they confirm, collect the data for another course. After all the data has been recorded, display the average grade and the GPA. Credit value can't be negative, and no course can have more than 9 credits. Some courses have halfcredits (e.g. a course can be .5 credits, 1.5 credits, 6 credits, etc.) Grades can't be negative, and can't be more than 110%. Sample program interaction and output can be seen below. In this example, user input is in dark red, prompts are in navy blue, and all other output is in black. GPA Calculation Enter the grade and credit value for each course. Data for Course #1: Grade: 75.5 Credit Value: 3 Enter Another Course? (Y/N) y Data for Course #2: Grade: 87.9 Credit Value: 6 Enter Another Course? (Y/N) Yes Data for Course #3: Grade: 72 Credit Value: 1.5 Enter Another Course? (Y/N) n Average Grade: 78.47 GPA: 3.71 Both the average and the GPA must be formatted to two decimal places.Note that the user is asked if they would like to enter new data after every course is recorded. Your program should be able to handle a flexible range of values for the user's inputted answer. For example, above you'll notice that "y" and "Yes" worked, even though the prompt asked for "Y" as a positive confirmation. Recall how we did this in class on the console using Character.toUpperCase() and scanner.next().charAt() Error Handling Your program should ensure that only valid data is entered. (See rules mentioned above). If the user enters an invalid value, they should be prompted again. For example: Grade Calculation Enter the grade and credit value for each course: Data for Course 1: Grade: 87 Credits: 3 Enter Another Course? (Y/N) yep Data for Course 2: Grade: -9 Error: Value must be between 0.0 and 110.0. Grade: two Error: All values entered must be numeric. Grade: 70 Credits: 3 Enter Another Course? (Y/N) y Data for Course 3: Grade: 65 Credits: 14 Error: Value must be between 0.0 and 10.0. Credits: 3 Enter Another Course? (Y/N) n Average Grade: 74.00 GPA: 3.17 Modularizing your Program Your program must include the following methods: getValidNumber() - retrieves a valid double from the user. o Requires the Scanner object, a prompt String, a minimum double value and a max double value as inputs. o Returns a valid double value between the min and max value (inclusive). o The method should prompt the user to enter the desired value, and retrieve a double value using the Scanner parameter. o If the Scanner's nextDouble() method throws an exception because the user enters an invalid double, the message "Error: Value must be between 0.0 and 110.0." (for grade value) or "Error: Value must be between 0.0 and 10.0." (for credit value) should be displayed. o If the double value entered is not between the min and max value (inclusive), the message "Error: All values entered must be numeric." should be displayed. o The user is continually prompted until a valid double value can be returned. getPoints() - determines the grade point assigned to a specific final grade value o Requires a final grade as an input (double value). o Returns a double value representing the grade point value for the value of the grade parameter. o Only valid values will be input into this method, however any grade less than 0 still results in a grade point value of 0, so if your method is written correctly, this won't be a concern. You may add other methods if they are efficient and eliminate redundant code, but they must be written correctly and efficiently and without redundancies (methods are there to get rid of redundant code!) If you add things that hinder the program's speed and efficiency, you will lose marks. How to Calculate GPA The GPA, or Grade Point Average, is calculated by dividing the total weighted credit value by the total number of credits taken by the student. The weighted credit value for one course is the grade points multiplied by the number of credits for that course. Grade points for a course are based on the grade achieved. The table below shows how grade points are determined: Final Grade Grade Points 80 and higher 4.0 75 to (but not including) 80 3.5 70 to (but not including) 75 3.0 65 to (but not including) 70 2.5 60 to (but not including) 65 2.0 50 to (but not including) 60 1.0 Below 50 0.0For example, if a student gets 76 as a final grade, the grade points would be 3.5. If a student got 49 in a course, the grade points would be 0. The weighted credit value for a course is the grade points multiplied by the number of credits earned. For example, if a student received a grade of 76 in a course worth 3 credits, the weighted credit value would be 3.5 * 3 = 10.5. A student who received 54 in a course worth 6 credits would have a weighted credit value of 1.0 * 6 = 6.0. To calculate the GPA, you need to divide the total weighted credit value for all courses taken by the total number of credits earned for all courses taken. The chart below shows how the GPA would be calculated for one student taking 4 courses: Grade Grade Points Credit Value Weighted Credit Value 87.3 4.0 3.0 12.0 74.2 3.0 3.0 9.0 61.0 2.0 3.0 6.0 55.5 1.0 3.0 3.0 Totals: 12.0 30.0 GPA = total weighted value / total credits = 30 / 12.0 = 2.50


Advertisement
View Answers

Related Tutorials/Questions & Answers:
java
java  diff bt core java and java
java
java  what is java
Advertisements
Java
Java   Whether Java is pure object oriented Language
java
java  different between java & core java
java
java  explain technologies are used in java now days and structure java
java
java   why iterator in java if we for loop
JAVA
JAVA  how the name came for java language as "JAVA
java
java  what is java reflection
java
java  is java open source
java
what is the size of array in java ?  what is the size of array in java ? what is the mean of finalize in java
java
java   in java does not pointers concept but what is nullpointers in java?   nullpointer is a runtime Exception
java
java  write a java program using filenotfoundexception
Java
Java  how to draw class diagrams in java
java
java   difference between class and interface
java
java  why multiple inheritance is not possible in java
java
java  explain object oriented concept in java
java
java  is java purely object oriented language
Java
Java   Whether Java is Programming Language or it is SOftware
java
java  what are JAVA applications development tools
java
java  how use java method
java
java  send me java interview questions
java
java  write a program in java to acess the email
java
java  Write a java code to print "ABABBABCABABBA
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  give a simple example for inheritance in java
java
java  give a simple example for inheritance in java
Java
Java  how to do java in command prompt
java
java  Does java allows multiline comments
Advertisements
 

 

 

DMCA.com