Asked by K.C
We are using Netbeans IDE for my class and i have no clue on how to write this program...
Write a program to enter a score and a points possible for a test, computer the percent, display the percent to 1 decimal place and then display the letter grade (A – F) using a standard scale (90, 80, 70, 60) – use the if ... else if ... else if ...
Example
Enter points on test: 38
Enter points possible: 49
You got 77.6 percent
That is a C
Write a program to enter a score and a points possible for a test, computer the percent, display the percent to 1 decimal place and then display the letter grade (A – F) using a standard scale (90, 80, 70, 60) – use the if ... else if ... else if ...
Example
Enter points on test: 38
Enter points possible: 49
You got 77.6 percent
That is a C
Answers
Answered by
K.C
I forgot to mention we are using Java
Answered by
MathMate
The Netbeans IDE runs only Java, so there is no ambiguity.
You need a nested if statement, which should be indented properly.
I will give an example of how the if statement should work, you will have to rework the numbers to suit your teacher's question.
// Declare score, maxScore as integer
// declare grade as character
// declare percent as double
// enter values of scores by user
// if maxScore==0, reenter maxScore
// now calculate percentage
percent=score/maxScore*100;
if (percent>=90){
grade='A';
} else if (percent>=80){
grade='B';
} else {
grade='F';
}
// output letter grade to 1 place of decimal
// output letter grade
You need a nested if statement, which should be indented properly.
I will give an example of how the if statement should work, you will have to rework the numbers to suit your teacher's question.
// Declare score, maxScore as integer
// declare grade as character
// declare percent as double
// enter values of scores by user
// if maxScore==0, reenter maxScore
// now calculate percentage
percent=score/maxScore*100;
if (percent>=90){
grade='A';
} else if (percent>=80){
grade='B';
} else {
grade='F';
}
// output letter grade to 1 place of decimal
// output letter grade
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.