Making a calculator about letter grades

Course Queries Syllabus Queries 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

I am taking Maths and I want to make a calculator which tells me the each note I need to take in the final exam to get each letter grade. In the syllabus it tells us that our note is calculated by this:

MT1 - First midterm %26.6 MT2- Second midterm %26.6 F- Final % 26.6 Q - Quizzes % 10 HW- Homeworks % 10

These are the grade intervals: A 80-100 A- 75-80 B+ 70-75 B 65-70 B- 60-65 C+ 55-60 C 50-55 C- 45-50 D+ 40-45 D+ 30-40 F 0-30

You enter MT1, MT2, Q, HW in the JTextFields and when you click the button it will update the jlabel's near the letter grades. When I run the code for the first time, it works but when I want to change it program doesn't update the numbers. Could you help?

Final_Calculator:

import javax.swing.*;
import java.awt.*;

public class Final_Calculator extends JFrame
{

    public static void main(String[] args) 
    {
        JFrame frame = new JFrame("Final Calculator");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(new Results());
        frame.pack();
        frame.setVisible(true);
    }
}

Grades:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class Grades extends JPanel
{
    private JLabel l1, l2, l3, l4;
    private JTextField t1, t2, t3, t4;
    private double sum,result, MT1, MT2, Q, HW;
    private JButton button;

    public Grades() 
    {
        setPreferredSize(new Dimension(200,100));
        l1 = new JLabel("MT1");
        l2 = new JLabel("MT2");
        l3 = new JLabel("Q");
        l4 = new JLabel("HW");
        t1 = new JTextField("100");
        t2 = new JTextField("100");
        t3 = new JTextField("100");
        t4 = new JTextField("100");
        button = new JButton("Click!");

        TextListener listener = new TextListener();

        button.addActionListener(listener);

        add(l1);
                                                
                                                
0 views
0 shares
profilepic.png
manpreet 2 years ago

From the looks of it/only working once, it looks like you are not updating the label after clicking the button.Label text have to updated via label.setText(""); just calling the method wont do anything.


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.