Question

In: Computer Science

In Java Create a simple GUI that gets the exam score and shows the corresponding letter...

In Java

Create a simple GUI that gets the exam score and shows the corresponding letter grade by clicking on the “Convert Score to Letter Grade” button.

Solutions

Expert Solution

Here is code:

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/


import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class Score extends JFrame implements ActionListener {

    JTextField txtdata;

    JButton calbtn = new JButton("Calc");

    JLabel outputLb = new JLabel();

    public Score() {

        JPanel myPanel = new JPanel();

        add(myPanel);

        myPanel.setLayout(new GridLayout(1, 2));

        JLabel label = new JLabel("Enter Score : ");

        myPanel.add(label);

        txtdata = new JTextField();

        myPanel.add(txtdata);

        myPanel.add(calbtn);

        calbtn.addActionListener(this);

        myPanel.add(outputLb);

    }

    public void actionPerformed(ActionEvent e) {

        if (e.getSource() == calbtn) {

            int data = Integer.parseInt(txtdata.getText()); //perform your operation

            String result = "";

            if (data > 100) {

                result = "Bad score";

            } else if (data >= 85 && data <= 100) {

                result = "Letter grade : A";

            } else if (data >= 75 && data <= 84) {

                result = "Letter grade : B";

            } else if (data >= 60 && data <= 74) {

                result = "Letter grade : C";

            } else if (data >= 50 && data <= 59) {

                result = "Letter grade : D";

            } else if (data < 0) {

                result = "Bad score";

            } else if (data < 50) {

                result = "Letter grade : F";

            } else {

                result = "Bad score";

            }

            outputLb.setText(result);

        }

    }

    public static void main(String args[]) {

        Score g = new Score();

        g.setLocation(10, 10);

        g.setSize(500, 70);

        g.setVisible(true);

    }

}

Output:


Related Solutions

Create a java Swing GUI application that presents the user with a “fortune”. Create a java...
Create a java Swing GUI application that presents the user with a “fortune”. Create a java Swing GUI application in a new Netbeans project called FortuneTeller. Your project will have a FortuneTellerFrame.java class (which inherits from JFrame) and a java main class: FortuneTellerViewer.java. Your application should have and use the following components: Top panel: A JLabel with text “Fortune Teller” (or something similar!) and an ImageIcon. Find an appropriate non-commercial Fortune Teller image for your ImageIcon. (The JLabel has a...
in a gui ' in java write a program that draws equal a simple fence with...
in a gui ' in java write a program that draws equal a simple fence with vertical, spaced slats backed by two boards. Behind the fence show a simple house support Make sure the in the und. house is visible between the slats in the fence.
In java, Create a GUI which works as an accumulator 1. There is a textfield A...
In java, Create a GUI which works as an accumulator 1. There is a textfield A which allows user to enter a number 2. There is also another textfield B with value start with 0. 3. When a user is done with entering the number in textfield A and press enter, calculate the sum of the number in textfield B and the number user just entered in textfield A, and display the updated number in textfield B
Topic is relates to Java programming! Code using java GUI 2. Create the following controls: a)...
Topic is relates to Java programming! Code using java GUI 2. Create the following controls: a) a TextField b) a Button c) a Text d) a Label 3. create the following container and put them the above controls: a) a VBox controller b) a BorderPane controller c) a GridPane
Create the pseudocode solution to a program that calculates the final score and letter grade for...
Create the pseudocode solution to a program that calculates the final score and letter grade for one student. Please use the following grading system: 9 Homework Assignments – 100 points each 10 points 11 Quizzes – 100 points each 5 points 5 Projects – 100 points each 10 points 6 Discussion posts – 100 points each 10 points 4 Exams – 100 points each 65 points A = 90 – 100% B = 80 – 89% C = 70 –...
Create in java an interactive GUI application program that will prompt the user to use one...
Create in java an interactive GUI application program that will prompt the user to use one of three calculators, label project name MEDCALC. You can use any color you want for your background other than grey. Be sure to label main java box with “MEDCALC” and include text of “For use only by students” On all three calculators create an alert and signature area for each user. The alert should be something like “All calculations must be confirmed by user...
Use the below info to create a java program A GUI interface to ensure a user...
Use the below info to create a java program A GUI interface to ensure a user is old enough to play a game. Properly formatted prompts to input name, address, phone number, and age. Remember that name, address, phone number, etc. can be broken out in additional fields. Refer to the tutorial from this week’s Reading Assignment Multiple vs. Single Field Capture for Phone Number Form Input for help with this. Instructions to ensure that the information is displayed back...
PLZ USE JAVA ECLIPSE AND EXPLAIN Create a GUI which works as an accumulator:  There...
PLZ USE JAVA ECLIPSE AND EXPLAIN Create a GUI which works as an accumulator:  There is a textfield A which allows user to enter a number  There is also another textfield B with value start with 0.  When a user is done with entering the number in textfield A and press enter, calculate the sum of the number in textfield B and the number user just entered in textfield A, and display the updated number in textfield...
Write a java code that gets student test scores from the user. Each test score will...
Write a java code that gets student test scores from the user. Each test score will be an integer in the range 0 to 100. Input will end when the user enters -1 as the input value. After all score have been read, display the number of students who took the test, the minimum score, the maximum score, the average score (with decimal point, and the number of A where an A is a score in the range 90-100.
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: • Number of days on the trip • Amount of airfare, if any • Amount of car rental fees, if any • Number of miles driven, if a private vehicle was used • Amount of parking fees, if any • Amount of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT