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 code is about implementing stacks , I want for someone to rewrite it totally in...
this code is about implementing stacks , I want for someone to rewrite it totally in different way #include <iostream> #include <stdexcept> #include <vector> #include <cstdlib> using namespace std; class Stack {     public:         bool isEmpty();         // returns true if stack has no elements stored         int top();         // returns element from top of the stack         // throws runtime_error("stack is empty")         int pop();         // returns element from top of the stack and removes it...
(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); }
Rewrite the following Matlab code so it does the same thing but with complete new variable...
Rewrite the following Matlab code so it does the same thing but with complete new variable names and structure. function stump = stumpGenerator(dataX, dataY, Dt) intervals = 100; rangex1 = max(dataX(:,1)) - min(dataX(:,1)); rangex2 = max(dataX(:,2)) - min(dataX(:,2)); width = (rangex1/intervals); height = (rangex2/intervals); starterx1 = min(dataX(:,1)) - (width/2); starterx2 = min(dataX(:,2)) - (height/2); currepsilon = inf; stump = [0,0,0,1,0,0]; for i = 1:(intervals + 1)    horzRightError = sum(Dt(find(((dataX(:,1) - starterx1) .* dataY) < 0))); horzLeftError = sum(Dt(find(((dataX(:,1) -...
please explain how does the following C code work. a) int function1(int num1, int num2) {...
please explain how does the following C code work. a) int function1(int num1, int num2) { int num = num1 ^ num2; int result = 0; while(num > 0) { result += (num & 1); num >>= 1; } return result; } b) int function2(unsigned int num) { return num & ~(num - 1); } c) int f1(unsigned int x) { int count = 0; while(x) { count++; x = x&(x-1); } return count; } d) double ldexp(double x, int...
Trace this code: 1) #include<iostream> using namespace std;    class Test {     int value; public:     Test(int...
Trace this code: 1) #include<iostream> using namespace std;    class Test {     int value; public:     Test(int v); };    Test::Test(int v) {     value = v; }    int main() {     Test t[100];     return 0; } =================================================================== 2) #include <iostream> using namespace std; int main() {                 int i, j;                 for (i = 1; i <= 3; i++)                 {                                 //print * equal to row number                                 for (j = 1; j <= i; j++)                                 {                                                 cout...
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; }...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT