Hello,
I am new to programming, but am working on a program that takes 6 inputted grade averages on a scale of 0.0 - 100.0 (exceptions in the case someone has exceeded the traditional 100.0 limit) and then divides it by 6 and returns the value in a dialog box. However, I want to take the values inputted and convert them to a 4.0 scale (90.0-100.0 = 4.0, 80.0-89.99 = 3.0, etc.) and then get the average of that so that I can return an average on a 4.0 scale. I have been trying to accomplish this but haven't been able to figure it out and would appreciate some help. Also, as of right now my program only prompts the user for 6 inputs, but I'd like the user to be able to input as many as he/she would like to, any suggestions? I am pasting the code I currently have below.
import javax.swing.JOptionPane; public class GPA_Calculation1_0 { public static void main(String[] args) { String courseOne = JOptionPane.showInputDialog("Enter numeric GPA of Course One: ");//Course one double numOne = Double.parseDouble(courseOne); String courseTwo = JOptionPane.showInputDialog("Enter numeric GPA of Course Two: ");//Course two double numTwo = Double.parseDouble(courseTwo); String courseThree = JOptionPane.showInputDialog("Enter numeric GPA of Course Three: ");//Course three double numThree = Double.parseDouble(courseThree); String courseFour = JOptionPane.showInputDialog("Enter numeric GPA of Course Four: ");//Course four double numFour = Double.parseDouble(courseFour); String courseFive = JOptionPane.showInputDialog("Enter numeric GPA of Course Five: ");//Course five double numFive = Double.parseDouble(courseFive); String courseSix = JOptionPane.showInputDialog("Enter numeric GPA of Course Six: ");//Course six double numSix = Double.parseDouble(courseSix); double averageNum = ((numOne + numTwo + numThree + numFour + numFive + numSix)/6.0); JOptionPane.showMessageDialog(null, "Your numeric GPA is: " + averageNum);//Displays output of calculation in dialog box System.exit(0); } }