Post a New Question

Computer Science

posted by .

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

  • Computer Science -

    I forgot to mention we are using Java

  • Computer Science -

    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

Answer This Question

First Name
School Subject
Your Answer

Related Questions

More Related Questions

Post a New Question