stuck at formatting string/integer
I'm currently trying to run a program in which computes grades per weighted percentages.. I've gotten everything right all the way up til formatting the string to 2 decimal places. In the red towards the bottom is where im guessing im messing up.. also I know my code is a little choppy... so any help would be greatly appreciated!! thank you, tony
Code:
import javax.swing.JOptionPane;
public class Assign3
{
public static void main(String[] args)
{
String hw = JOptionPane.showInputDialog ("Enter homework weight percentage:");
String midterm = JOptionPane.showInputDialog ("Enter midterm weight
percentage:");
String finalex = JOptionPane.showInputDialog ("Enter final exam weight
percentage:");
int p1 = Integer.parseInt(hw);
int p2 = Integer.parseInt(midterm);
int p3 = Integer.parseInt(finalex);
int p4 = 10;
String hws = JOptionPane.showInputDialog ("Enter homework score: (0-600
points)");
String mts = JOptionPane.showInputDialog ("Enter midterm score (0-100 points):");
String fs = JOptionPane.showInputDialog ("Enter final score (0-100 points):");
String labs = JOptionPane.showInputDialog ("Enter lab participation score (0-100
points):");
int x1 = Integer.parseInt(hws);
int x11 = (x1 / 6);
int x2 = Integer.parseInt(mts);
int x3 = Integer.parseInt(fs);
int x4 = Integer.parseInt(labs);
int output1 = (((p1*x11)+(p2*x2)+(p3*x3)+(p4*x4)) / 100);
String output = Integer.toString(output1);
output = String.format("%.2d", output);
JOptionPane.showMessageDialog(null, output);
System.out.println(output);
}
}