Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using jGrasp and the Software Development Kit, write a program in response to th

ID: 3661833 • Letter: U

Question

Using jGrasp and the Software Development Kit, write a program in response to the following prompt:

Design a GUI program to find the weighted average of four test scores. The four test scores and their respective weights are given in the following format:

testscore1 weight1
...

For example, the sample data is as follows:

75 0.20
95 0.35
85 0.15
65 0.30

The user is supposed to enter the data and press a Calculate button. The program must display the weighted average.

Remember to follow proper form and design in your response.

Submit your compiled Java code for this assignment, compress the .java file into a single .zip file.

For additional details, refer to the Programming Problems Rubric in the Assignment Guidelines and Rubrics folder

Explanation / Answer

import java.awt.Button;
import java.awt.Color;
import java.awt.Event;
import java.awt.Graphics;
import java.awt.Label;
import java.awt.TextField;
import java.applet.*;


public class WeightedAverage extends Applet
{
   TextField T1,T2,T3,T4,T5,T6,T7,T8;
   Button calculate=new Button("Calculate");
   Label result;
   double res;
public void init() {
T1 = new TextField(10);
T2 = new TextField(10);
T3 = new TextField(10);
T4 = new TextField(10);
T5= new TextField(10);
T6 = new TextField(10);
T7 = new TextField(10);
T8 = new TextField(10);
  
add(T1);
add(T2);
add(T3);
add(T4);
add(T5);
add(T6);
add(T7);
add(T8);
add(calculate);
T1.setText("0");
T2.setText("0");
T3.setText("0");
T4.setText("0");
T5.setText("0");
T6.setText("0");
T7.setText("0");
T8.setText("0");
}

public void paint(Graphics g) {
   g.drawString("Weighted Average is : "+res,10,80);
  
  
}

public boolean action(Event e, Object o){
repaint();

int w1, w2, w3, w4;
double avg=0.0;
if(e.target==calculate)
{

w1=Integer.parseInt(T2.getText());
w2=Integer.parseInt(T4.getText());
w3=Integer.parseInt(T6.getText());
w4=Integer.parseInt(T8.getText());

res=(w1+w2+w3+w4)/4;
}
return true;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote