Question

In: Computer Science

Need someone to rewrite this code to work in the same way: int testScore;    //Numeric test...

Need someone to rewrite this code to work in the same way:

int testScore;    //Numeric test score

        String input;     //To hold the user's input

       

        // Get the numeric test score.

        input = JOptionPane.showInputDialog("Enter your numeric test score and I will tell you the grade: ");

        testScore = Integer.parseInt(input);

       

        //Display the grade.

        if (testScore < 60)

           JOptionPane.showMessageDialog(null, "Your score of "+testScore+" is an F.");

        else if (testScore < 70)

           JOptionPane.showMessageDialog(null, "Your score of "+testScore+" is a D.");

        else if (testScore < 80)

           JOptionPane.showMessageDialog(null, "Your score of "+testScore+" is a C.");

        else if (testScore < 90)

           JOptionPane.showMessageDialog(null, "Your score of "+testScore+"e is a B.");

        else

           JOptionPane.showMessageDialog(null, "Your score of "+testScore+" is an A.");

    }

   

}

Need ans asap......

Solutions

Expert Solution

public class PrintGrade {
   public static void main(String[] args) {
       int testScore; // variable to score int score
       String message="";
       // reading user input and converting the integer to string
       testScore = Integer
               .parseInt(JOptionPane.showInputDialog("Enter your numeric test score and I will tell you the grade: "));
       // Display the grade.
       if (testScore >= 90)
           message="Your score of " + testScore + " is an A.";
       else if (testScore >= 80)
           message="Your score of " + testScore + "e is a B.";
       else if (testScore >= 70)
           message="Your score of " + testScore + " is a C.";
       else if (testScore >= 60)
           message="Your score of " + testScore + " is a D.";
       else
           message="Your score of " + testScore + " is an F.";
       JOptionPane.showMessageDialog(null, message);
   }
}

Note : If you like my answer please rate and help me it is very Imp for me


Related Solutions

NEED TO REWRITE THIS IN OOP MODE ######## HOMEWORK 19 ###### Rewrite the code in the...
NEED TO REWRITE THIS IN OOP MODE ######## HOMEWORK 19 ###### Rewrite the code in the OOP mode (class mode). ########################### lambda trick ##### first: changing label properties: after you've created a label, you ##### may want to change something about it. To do that, use configure method: ## label.configure(text = 'Yes') ## label.configure(bg = 'white', fg = 'black') ### that change the properties of a label called label. ################################################### ## from tkinter import * abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' def callback(x):...
(This is for java) I need to rewrite this code that uses a while loop. public...
(This is for java) I need to rewrite this code that uses a while loop. public class Practice6 {      public static void main (String [] args) {         int sum = 2, i=2;        do { sum *= 6;    i++;    } while (i < 20); System.out.println("Total is: " + sum); }
Is there a way to have the same response when someone does not fill out the...
Is there a way to have the same response when someone does not fill out the number correctly on my second code. Is there a way to not use the alert. <!doctype html> <html> <head> <meta charset="UTF-8"> <title>Untitled Document</title> <script>    function phonenumber(inputtxt){           var phoneno = (\(\d{3}\)|\d{3})[-\s]\d{3}-\d{4};       if(inputtxt.value.match(phoneno)){        document.getElementById("yourEntry").innerHTML = document.getElementById("myphone").value;    }    //if(!inputtxt.value.match(phoneno)){        // alert("Does not Work!")        //}    } </script> </head> <body> <form name="form1" action="#"> <input...
Here is the R code for running a t-test: t.test( numeric vector of data values, another...
Here is the R code for running a t-test: t.test( numeric vector of data values, another optional numeric vector of data values,        alternative = c("two.sided", "less", "greater"),        mu = Ho, paired = c(TRUE, FALSE), var.equal = c(TRUE,FALSE),conf.level =1-) 1.) Suppose 30 students are all taking the same Math 115 and English 101 classes at CSUN. You want to know in which class students tend to do better. The data below represents the class averages of the students in both classes....
Here is the R code for running a t-test: t.test( numeric vector of data values, another...
Here is the R code for running a t-test: t.test( numeric vector of data values, another optional numeric vector of data values,        alternative = c("two.sided", "less", "greater"),        mu = Ho, paired = c(TRUE, FALSE), var.equal = c(TRUE,FALSE),conf.level =1-) 2) You want to determine if the average height of men in California is greater than the average height of men in Nebraska. You take a random sample of 30 men in California and 30 men in Nebraska. The data below represents...
Need this 8 queen code with same exact solution without goto. Need to keep the code...
Need this 8 queen code with same exact solution without goto. Need to keep the code as similar as possible. #include <iostream> #include <cmath> using namespace std; int main(){ int q[8], c = 0, i, j,count=0; q[0] = 0; //first queen top corner nc: c++; if(c == 8 ) goto print; q[c] = -1; nr: q[c]++; if(q[c] == 8) goto backtrack; for(i= 0; i < c; i++) { if((q[i] == q[c])||(c - i == abs(q[c] - q[i]))) goto nr; }...
should all work place harassment be treated the same way?
should all work place harassment be treated the same way?
I've did most of the work i just need someone to check if my work is...
I've did most of the work i just need someone to check if my work is correct Maryam and Hanadi are planning to open a shop to sell female shoes in Abu Dhabi. The venue of the shop is decided to be a rented premises in Marina Mall. They wish to start their operations from 01 July, 2020. The following information is available about the company’s operations. i. The company predicts a sale price of AED 350 per unit. Sales...
this is for those who did Arduino projects this code is supposed to work this way,...
this is for those who did Arduino projects this code is supposed to work this way, there is a temperature sensor in the Arduino Uno along with a motor. the motor should turn on only when the temperature in the sensor exceeds 23 degrees Celcius. Here is the code float AnalogToVolts(int reading); void setup() { Serial.begin(9600); pinMode(13, OUTPUT); } void loop() { int reading; float volts; float temperature_in_celsius; reading = analogRead(A1); volts = AnalogToVolts(reading); //Function call if ( temperature_in_celsius >...
Someone post from a discussion question... (Respond to it) The most important way to decrease work...
Someone post from a discussion question... (Respond to it) The most important way to decrease work stress is to find any off switch. We currently are surrounded by technology that for the most part allows us to do work from anywhere. We have ready access to computers, phones, laptops and emails. We needs to be able to turn these things off and immerse ourselves into our personal lives with no interruptions from work.    Along these lines it is also...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT