I am trying to run a program for my class where I have to have the average computed and the teacher wants to see 2 numbers past the decimal point. I know what I need to add, however I have no idea where to put it to make it work properly... This is the first program that I have had to do on my own and for the most part I think I have it...
import javax.swing.JOptionPane;
public class Modeling_001C_4Loops {
public static void main(String[] args) {
// Define height and weight and assign values
final int HEIGHT = 70;
final double WEIGHT = 110.4999;
// Prompt user for height in inches
String applicantsHeightString = JOptionPane.showInputDialog("Enter applicants height (in inches)");
double applicantsHeight = Double.parseDouble(applicantsHeightString);
if (applicantsHeight >= HEIGHT) {
JOptionPane.showMessageDialog(null, "Send applicant to get Weighed");
}
else if (applicantsHeight < HEIGHT) {
JOptionPane.showMessageDialog(null, "Send her home...does not qualify");
}
// Prompt user of Weight in pounds
if (applicantsHeight >= HEIGHT) {
String applicantsWeightString = JOptionPane.showInputDialog("Enter Applicants Weight (in pounds)");
double applicantsWeight = Double.parseDouble(applicantsWeightString);
if (applicantsWeight <= WEIGHT) {
JOptionPane.showMessageDialog(null, "Congratulate her and Send to the first Photographer");
}
else if (applicantsWeight > WEIGHT) {
JOptionPane.showMessageDialog(null, "Send her home! Does not meet weight requrements!");
}
// Define variables for Photographer 1
if (applicantsHeight >= HEIGHT && applicantsWeight <= WEIGHT) {
String photographer1String = JOptionPane.showInputDialog("Enter 1st Photographers Score");
double photographer1 = Double.parseDouble(photographer1String);
if (photographer1 >= 1 && photographer1 <= 10)
JOptionPane.showMessageDialog(null, "Send to 2nd Photographer!");
else if (photographer1 == 0) {
JOptionPane.showMessageDialog(null, "No Pictures! IDon't want to break the camera" +
"...it's my favorite");
}
else if (photographer1 >= 10.01) {
JOptionPane.showMessageDialog(null, "Invalid Input! Please try again.");
}
// Define variables for Photographer 2
if (photographer1 >= 1 && photographer1 <= 10) {
String photographer2String = JOptionPane.showInputDialog("Enter 2nd Photographers Score");
double photographer2 = Double.parseDouble(photographer2String);
if (photographer2 >= 1 && photographer2 <= 10)
JOptionPane.showMessageDialog(null, "Send to 3rd Photographer!");
else if (photographer2 == 0) {
JOptionPane.showMessageDialog(null, "What was the last guy thinking?" +
" Send her home! NOW!!");
}
else if (photographer2 >= 10.01) {
JOptionPane.showMessageDialog(null, "Invalid Input! Please try again.");
}
// Define variables for Photographer 3
if (photographer2 >= 1 && photographer2 <= 10) {
String photographer3String = JOptionPane.showInputDialog("Enter 3rd Photographers Score");
double photographer3 = Double.parseDouble(photographer3String);
if (photographer3 >= 1 && photographer3 <= 10)
JOptionPane.showMessageDialog(null, "Calculate Average Score");
else if (photographer3 == 0) {
JOptionPane.showMessageDialog(null, "Waste of my time. How did she make it this far?");
}
else if (photographer3 >= 10.01) {
JOptionPane.showMessageDialog(null, "Invalid Input! Please try again");
}
// Define average and assign a value
double averageScore = (photographer1 + photographer2 + photographer3) / 3;
if (averageScore <= 7.9 && photographer3 != 0) {
JOptionPane.showMessageDialog(null, "%10.2f" + " Average " + averageScore + "!" +
" Too high risk, not worth spending your money!!");
}
else if (averageScore >= 8 && averageScore <=8.7) {
JOptionPane.showMessageDialog(null, "%10.2f" + " Average " + averageScore + "!" +
" Medium to High risk....but could make you money. Eventually!");
}
else if (averageScore >= 8.8 && averageScore <= 9.3) {
JOptionPane.showMessageDialog(null, "%10.2f" + " Average " + averageScore + "!" +
" Low to Medium risk....has a pretty good chance to make you money!");
}
else if (averageScore >= 9.4 && averageScore <= 9.9) {
JOptionPane.showMessageDialog(null, "%10.2f" + " Average " + averageScore + "!" +
" Low risk to good investment....Excelant chance you will make money " +
"bring her on board!");
}
else if (averageScore == 10) {
JOptionPane.showMessageDialog(null, "%10.2f" + " Average " + averageScore + "!" +
" Get her to sign a contract before she realizes how much she could take you for!!!");
}
}
}
}
}
}
}
This is where I thought they would go, but all it does is add it as text in the message box, which is not what I want it to do
Any suggestions would be great!