1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sedbober [7]
3 years ago
9

JAVA Write a program that first asks the user to type a letter grade and then translates the letter grade into a number grade. L

etter grades are A, B, C, D, and F, possibly followed by + or –. Their numeric values are 4, 3, 2, 1, and 0. There is no F+ or F–. A + increases the numeric value by 0.3, a – decreases it by 0.3. However, an A+ has value 4.0. Use a class Grade with a method getNumericGrade. Also provide a tester class. Use -1 as a sentinel value to denote the end of letter grade inputs. The running results of your program should be like: Please enter a letter grade (enter -1 to end the input): B- The numeric value is 2.7. Please enter a letter grade (enter -1 to end the input):C The numeric value is 2.0. Please enter a letter grade (enter -1 to end the input):-1 The grade translation ends.
Computers and Technology
1 answer:
ale4655 [162]3 years ago
4 0

Answer:

Follows are the code to this question:

import java.util.*;//import package for user input

class GradePrinter//defining class GradePrinter

{

double numericValue = 0;//defining double variable

String grade = "";//defining String variable

GradePrinter()//defining default constructor  

{

Scanner xb = new Scanner(System. in );//defining Scanner  class object

System.out.print("Enter Grade: ");//print message

grade = xb.nextLine();//input string value  

}

double getNumericGrade()//defining double method getNumericGrade

{

if (grade.equals("A+") || grade.equals("A"))//defining if block that check input is A+ or A

{

numericValue = 4.0;//using  numericValue variable that hold float value 4.0

}

else if (grade.equals("A-"))//defining else if that check grade equals to A-

{

numericValue = 3.7;//using  numericValue variable that hold float value 3.7

}

else if (grade.equals("B+"))//defining else if that check grade equals to B-

{

numericValue = 3.3;//using  numericValue variable that hold float value 3.3

}

else if (grade.equals("B"))//defining else if that check grade equals to B

{

numericValue = 3.0;//using  numericValue variable that hold float value 3.0

}

else if (grade.equals("B-"))//defining else if that check grade equals to B-  

{

numericValue = 2.7;//using  numericValue variable that hold float value 2.7

}

else if (grade.equals("C+"))//defining else if that check grade equals to C+  

{

numericValue = 2.3; //using  numericValue variable that hold float value 2.3

}

else if (grade.equals("C")) //defining else if that check grade equals to C  

{

numericValue = 2.0; //using numericValue variable that hold float value 2.0

}

else if (grade.equals("C-")) //defining else if that check grade equals to C-  

{

numericValue = 1.7;//using umericValue variable that hold float value 1.7

}

else if (grade.equals("D+"))//defining else if that check grade equals to D+  

{

numericValue = 1.3;//using umericValue variable that hold float value 1.3

}

else if (grade.equals("D"))//defining else if that check grade equals to D

{

numericValue = 1.0;//using umericValue variable that hold float value 1.0

}

else if (grade.equals("F"))//defining else if that check grade equals to F

{

numericValue = 0;//using umericValue variable that hold value 0

}

else//defining else block

{

System.out.println("Letter not in grading system");//print message

}

return numericValue;//return numericValue

}

}

class Main//defining a class main

{

public static void main(String[] args)//defining main method

{

GradePrinter ob = new GradePrinter();// creating class GradePrinter object

double numericGrade = ob.getNumericGrade();//defining double variable numericGrade that holds method Value

System.out.println("Numeric Value: "+numericGrade); //print Value numericgrade.

}

}

Output:

Enter Grade: B

Numeric Value: 3.0

Explanation:

In the above-given code, a class "GradePrinter" is defined inside the class a string, and double variable "grade and numericValue" is defined, in which the grade variable is used for input string value from the user end.

After input, the sting value a method getNumericGrade is defined, which uses multiple conditional statements is used, which holds double value in the which is defined in the question.

In the main class, the "GradePrinter" object is created and defines a double variable "numericGrade", that calling method and store its value, and also use print method to print its value.

You might be interested in
What is the program that searches through data bases?
german
If i'm right its call: Algorithm
5 0
3 years ago
What is the cell reference for row 22 and column B? __________<br><br> In excel
vovikov84 [41]
The cell reference is B22

plz thank me, it keeps me motivated to answer more of your questions :)
8 0
3 years ago
What answer best explains why improper netiquette is considered dangerous? Individuals who violate user policies are often charg
adell [148]

Answer:

Students become vulnerable to cyberbullying and harassment.

Explanation:

3 0
3 years ago
Read 2 more answers
Identify and explain the three tiers of web-based applications.
prisoha [69]

In the case of three-tier architecture, the tiers are as follows: Presentation tier (also known as the user interface or the client application) Business logic tier (also known as the application server) Data storage tier (also known as the database server)

This was on google i take no credit for this work

Btw I don´t know if this is what u want

7 0
2 years ago
Imagine you were going to use a dedicated workstation for an animation job rather than a personal PC or the all-purpose PCs you
xeze [42]

Answer:

Explanation:

The three most notable differences that any user will notice between these two would be the following

  1. High-Resolution Display
  2. Specific Hardware (graphics tablet, camera, etc)
  3. Increased Speed

An individual that is working in a career in Animation needs a workstation that is capable of rendering animations which take lots of processing power. Therefore, the workstation would have to be high-end meaning that it will be much faster than a normal personal PC. Animation and Digital Design require a very High-Resolution display and specific hardware to allow you to bring your creations to life and make sure they look as beautiful as possible. All of this is not found in a normal personal PC either.

7 0
3 years ago
Other questions:
  • Design the below using an array// Sunrise Freight charges standard// per-pound shipping prices to the five states they serve// –
    6·1 answer
  • Which line is not a computer-generated forecast?Which line is not a computer-generated forecast?the black line representing 20th
    12·1 answer
  • What is information technology
    11·1 answer
  • Please help!
    10·2 answers
  • Which of the following is NOT part of the URL for an Internet web site?
    13·1 answer
  • 1. Software that is designed to intentionally cause harm to a device, server, or network is A. outware B.loggerware C.
    12·1 answer
  • What is my mistake on this code? (Python)
    9·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    6·1 answer
  • What is cloud computing?
    13·2 answers
  • If there is a secure socket layer in place, what will you need in addition to a user id in order to access the shared files?.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!