 # Java Program For Calculating Grades

## Question

Write a Java program which calculates final grades.

Your program must read lines (from standard input) which give the names, marks and number of cheating instances for people in a course. Your program must then compute the grade following the rules outlined (see below). Then output the person’s name, their numeric grade, and the corresponding letter grade.

More specifically, the fields in the input are separated by the “|” character. The second field is the final exam mark, the third field is the midterm mark, the fourth field is the number of bonus points and the fifth field is the number of times the person was caught cheating. To reduce tedium, we will pretend that there are only seven assignments that count. The exam and midterm mark are percentages. The assignments are out of 60, except for the first one, which is marked out of 20. (Note that a person may obtain bonus points on a given assignment, taking their mark above 100% (i.e., above 20 or above 60) for that particular assignment.)

Igotte Busted|100|97.5|3|2|17|58|60|63|-60|-60|42
John Q. Woodcutter|75|82|2|0|15|57|55|56|10|25|48

then your program should create the following output:
Igotte Busted                F    0
John Q. Woodcutter      A- 80

Use floating point numbers to do the calculations of the numeric grade, and then round that result to the nearest integer (round a number with a fractional part of 0.5 up to the next integer).
The output must have the name starting at the left margin. If the name has less than 30 characters, the letter grade starts in column 31. If the name has more than 29 characters, the entire name is printed, followed by one space, and the letter grade and numeric grade must follow. In either case, the letter grade is left-justified in a two-column field, this field is followed by one space, and that space is followed by the numeric grade right-justified in a three-column field.

Your program must perform the calculations and output the results for all input lines until either (a) EOF, or (b) it finds a line which does not match the given input format. In the latter case, your program must output an informative error message and stop.
Invent your own input data to thoroughly test your program. Make sure you include enough tests in your script file to convince the marker that your program works. Also, if you aren’t sure what the complicated part of the formula means, then put in enough test cases (which use that part of the formula) so that you can figure out what is going on.

You may need to install Java on your Linux system, if you have not done so already. If you wish, you may also install a Java IDE. However, for the run where you create the script file to be handed in, you must compile your program with the command line javac marks.java and execute your program with the command line java marks (of course, this assumes that you named your Java program marks.java).

If you wish to store your data in a file (say, testmarks.dat) so that you do not have to re-type it every time you run your program, you can “send” this data to your Java program by typing the command line “java marks < testmarks.dat”.

F=0.5*E + 0.1*M + 0.1*A + B + Jb
if E < 40
F += 0.3 * E
else
if E > 50
F+=0.2*max(E,M) + 0.1*max(E,A)
else
F+=0.02*((E-40)*max(E,M) + (50-E)*E) +0.01*((E-40)*max(E,A) + (50-E)*E)
if M < 40
F = min(F, M)
if A < 50
F = min(F, A)
Finally, this grade is adjusted as described below for anyone caught cheating.

## Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.text.DecimalFormat;
import java.util.Scanner;

public class mark {

private static boolean calculation(String line){

String [] split = line.split("\\|");

if (split.length != 12) {
return false;
}

String name = split;
double finalMark;
double middleTermMark;
double bonusPointNum;
double cheatingNum;
double [] mark = new double;
try {
for (int i = 0; i < 4; i++) {
mark[i] = Double.parseDouble(split[i + 1]);
}

mark = Double.parseDouble(split);
mark = mark <= 20.0 ? mark : 20.0 ;
mark = mark / 20.0;...
\$28.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.