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);           ...

  • Step 4: Add code that discards any extra entries at the propmt that asks if you...

    Step 4: Add code that discards any extra entries at the propmt that asks if you want to enter another score. Notes from professor: For Step 4, add a loop that will validate the response for the prompt question:       "Enter another test score? (y/n): " This loop must only accept the single letters of ‘y’ or ‘n’ (upper case is okay). I suggest that you put this loop inside the loop that already determines if the program should collect...

  • 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....

  • 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...

  • 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...

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

    Write a javascript 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. Write the following methods in the program: calcAverage—This method should accept five test scores as arguments and return the average of the scores. determineGrade—This method should accept a test score as an argument and return a letter grade for the score,

  • IN JAVA (ECLIPSE) Design a TestScores class that has fields to hold three test scores. (If...

    IN JAVA (ECLIPSE) Design a TestScores class that has fields to hold three test scores. (If you have already written the TestScores class for programming challenge 8 of chapter 3, you can modify it.) the class constructor should accept three test scores as arguments and assign these arguments to the test score fields. The class should also have accessor methods for the test score fields, a method that returns the average of the test scores, and a method that returns...

  • 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 *...

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