In text form please no images Using jGrasp and the Software Development Kit, wri
ID: 663642 • Letter: I
Question
In text form please no images
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.2095 0.3585 0.1565 0.30The 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
Explanation / Answer
// Copy the below program and paste it in the Jgrasp editor
// then compile and run it.
import java.util.Scanner;
public class JgraspWeightedAverage
{
// Calculate Weighted average of four test scores
public static void main(String[] args)
{
// an array of double to store test score
double [] Testscore = new double[4];
double [] Weight=new double[4];
double Calculate_Weight_avg=1;
int i = 0, j = 0, k = 0, counter = 1;
Scanner readscore = new Scanner(System.in);
// prompt for inputs: Test score
System.out.println("Enter Test score : ");
System.out.println("enter TestScore and Weight pairs :");
// Test score for 1st input..
while(i<4)
{
Testscore[i] = readscore.nextDouble();
Weight[i]=readscore.nextDouble();
i++;
}
for(k=0;k<4;k++)
{
//Calculating weighted average
Calculate_Weight_avg = Calculate_Weight_avg + Testscore[k]*Weight[k];
}
// Printing calculated Weighted average score
System.out.println("The weighted Average is: "+Calculate_Weight_avg);
}
}
// To view this in GUI form
// Click the Run in Canvas button on toolbar. you should see an empty viewer canvas window. in the CSD window , // you should see that the program is stopped at first executable statement.
// now click the Debug button to execute the statement. and proceed further.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.