Question

Test Scores and Grade

Write a program that has variables to hold three test scores. The program should ask the user to enter three test scores and then assign the values entered to the variables. The program should display the average of the test scores and the letter grade that is assigned for the test score average. Use the grading scheme in the following table:

Test Score Average

Letter Grade

90–100

A

80–89

B

70–79

C

60–69

D

Below 60

F

Hello, I'm having some errors in my code, I was wondering if someone could help me correct it. This is my code:

import.java.util.Scanner;L public class NAM_TestScoresAndGrade { public static void main (String[] args) { double testi, test

letterGrade = D, System.out.println( Letter grade + letterGrade); } else if (averageScore <= 60); { letterGrade = F; Sy

And this is my errors, I'm not sure how to fix them.

--JGRASP exec: javac -& TestScoresAndGrade.java TestScoresAndGrade.java:1: error: <identifier> expected import.java.util.Scan

Please help me, and if I have other errors please let me know, thank you!

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

// NOTE: 2 errors in your code

(1) remove . between import and java import java.util.Scanner;

(2) spelling is wrong in sc.close();

// I have fixed both the errors

import java.util.Scanner;

public class NAM_TestScoresAndGrade {
public static void main(String args[]) {
  
double test1,test2,test3,averageScore;char letterGrade;
  
Scanner sc=new Scanner(System.in);
System.out.print("Enter first test score");
test1=sc.nextDouble();
System.out.print("Enter second test score");
test2=sc.nextDouble();
System.out.print("Enter third test score");
test3=sc.nextDouble();
averageScore=(test1+test2+test3)/3;
System.out.println("Average score: "+averageScore);
if(averageScore>=90 && averageScore<=100)
{
letterGrade='A';
System.out.println("Letter grade"+letterGrade);
}
else if(averageScore>=80 && averageScore<=89)
{
letterGrade='B';
System.out.println("Letter grade"+letterGrade);
}
else if(averageScore>=70 && averageScore<=79)
{
letterGrade='C';
System.out.println("Letter grade"+letterGrade);
}
else if(averageScore>=60 && averageScore<=69)
{
letterGrade='D';
System.out.println("Letter grade"+letterGrade);
}
else if(averageScore<=60)
{
letterGrade='F';
System.out.println("Letter grade"+letterGrade);
}
sc.close();
}
}

Add a comment
Know the answer?
Add Answer to:
Test Scores and Grade Write a program that has variables to hold three test scores. The...
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
  • ASSIGNMENT #3 ** using System; namespace GradeCalculatorNew {    class MainClass    {        public...

    ASSIGNMENT #3 ** using System; namespace GradeCalculatorNew {    class MainClass    {        public static void Main (string[] args)        {            int test1,test2,test3;            double average,average2;            char letterGrade;            Console.WriteLine("Enter test score1");            test1=Convert.ToInt32(Console.ReadLine());            Console.WriteLine("Enter test score2");            test2=Convert.ToInt32(Console.ReadLine());            Console.WriteLine("Enter test score3");            test3=Convert.ToInt32(Console.ReadLine());            average=(test1+test2+test3)/3.0;            average=(int)(average+0.5);           ...

  • Write a program called printGPA. The program should contain at least 3 methods: main, gradeAverage, and...

    Write a program called printGPA. The program should contain at least 3 methods: main, gradeAverage, and letterGrade. The user will type a line of input containing the student's name, then a number that represents the number of scores, followed by that many integer scores (user input is in bold below). The data type used for the input should be one of the primitive integer data types. Here are two example dialogues: Enter a student record: Maria 5 72 91 84...

  • Java Programming Language Edit and modify from the given code Perform the exact same logic, except...

    Java Programming Language Edit and modify from the given code Perform the exact same logic, except . . . The numeric ranges and corresponding letter grade will be stored in a file. Need error checking for: Being able to open the text file. The data makes sense: 1 text line of data would be 100 = A. Read in all of the numeric grades and letter grades and stored them into an array or arraylist. Then do the same logic....

  • Write a program that asks the user to enter five test scores. The program should display...

    Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Design the following functions in the program: calcAverage—This function should accept five test scores as arguments and return the average of the scores. determineGrade—This function should accept a test score as an argument and return a letter grade for the score (as a String), based on the following grading scale: Score Letter Grade...

  • Declare and initialize 4 Constants for the course category weights: The weight of Homework will be...

    Declare and initialize 4 Constants for the course category weights: The weight of Homework will be 15% The weight of Tests will be 35% The weight of the Mid term will be 20% The weight of the Fin al will be 30% Remember to name your Constants according to Java standards. Declare a variable to store the input for the number of homework scores and use a Scanner method to read the value from the Console. Declare two variables: one...

  • Below is a java program that inputs an integer grade and turns it into a letter...

    Below is a java program that inputs an integer grade and turns it into a letter grade. Update the below java code as follows and comment each line to explain what is happening: 1. Convert the if-else-if code block to a switch statement to solve the problem. 2. Use modulus to convert the grade input so that the range of grades are converted to one value. (comment the line) import java.util.Scanner; public class GradeLetterTest { public static void main(String[] args)...

  • Java debugging in eclipse package edu.ilstu; import java.util.Scanner; /** * The following class has four independent...

    Java debugging in eclipse package edu.ilstu; import java.util.Scanner; /** * The following class has four independent debugging * problems. Solve one at a time, uncommenting the next * one only after the previous problem is working correctly. */ public class FindTheErrors { public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); /* * Problem 1 Debugging * * This problem is to read in your first name, * last name, and current year and display them in *...

  • in C++ Create a program that will calculate a student’s grade average of 5 test scores...

    in C++ Create a program that will calculate a student’s grade average of 5 test scores and assign a letter grade for a student. The program should use a class to store the student’s data including the student’s name and score on each of 5 tests. The program should include member functions to 1) get the student’s test scores, 2) calculate the average of the test scores, and 3) display the results as follows: Test scores for Mary: 100 90...

  • Complete the program, Grade.java, below. The program takes in a student's score and prints the corresponding...

    Complete the program, Grade.java, below. The program takes in a student's score and prints the corresponding letter grade assuming a standard 60-70-80-90 scale for cutoff of each grade. For example, if a student's score is 52.6 they would be assigned an "F" grade. If a student's score is 87.8 they would be assigned a "B grade. The program should take in the score as a double value and print the letter grade (capitalized letter of A, B, C, D, or...

  • Your assignment is to write a grade book for a teacher. The teacher has a text file, which includ...

    Your assignment is to write a grade book for a teacher. The teacher has a text file, which includes student's names, and students test grades. There are four test scores for each student. Here is an example of such a file: Count: 5 Sally 78.0 84.0 79.0 86.0 Rachel 68.0 76.0 87.0 76.0 Melba 87.0 78.0 98.0 88.0 Grace 76.0 67.0 89.0 0.0 Lisa 68.0 76.0 65.0 87.0 The first line of the file will indicate the number of students...

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