help
From: Needful (khuff3_at_georgisouthern.edu)
Date: 11/24/04
- Next message: Matt Humphrey: "Re: DecimalToBinary can't handle numbers greater that 63"
- Previous message: Chris Smith: "Re: LinkedList clear() method and C++ copy constructor confusion"
- Next in thread: Mike B: "Re: help"
- Reply: Mike B: "Re: help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 24 Nov 2004 14:52:23 +0000
help, please see my results section. what am i doing wrong?
//Project3.java: copute clothing sizes according to formulas, kelly huff,
csci 1236, 11-18-04
import javax.swing.JOptionPane;
public class Project3 {
/** Main method */
public static void main(String[] args) {
int i;
while (i != 0) {
//Prompt user to enter age
String ageString = JOptionPane.showInputDialog(null, "Enter Age:", "Project
3", JOptionPane.QUESTION_MESSAGE);
//Convert age to integer
int age = Integer.parseInt(ageString);
//Prompt user to enter weight
String weightString = JOptionPane.showInputDialog(null, "Enter Weight:",
"Project 3", JOptionPane.QUESTION_MESSAGE);
//Convert weight to integer
int weight = Integer.parseInt(weightString);
//Prompt user to enter height
String heightString = JOptionPane.showInputDialog(null, "Enter Height:",
"Project 3", JOptionPane.QUESTION_MESSAGE);
//Convert height to integer
int height = Integer.parseInt(heightString);
}
/>>> I'm having problems showing results of this program.
//Show results
JOptionPane.showMessageDialog(null, "The hat size is " + hood(hat) + ".
\nThe jacket size is " + coat(jacket) + ".\nThe waist size is " + belt
(waist) + ".", "Project3", JOptionPane.INFORMATION_MESSAGE);
//Ask user if they would like to repeat calculations
String repeatString = JOptionPane.showInputDialog(null, "If you would like
to repeat the calculations enter 1, otherwise enter 0:", "Project 3",
JOptionPane.QUESTION_MESSAGE);
//Convert repeat string to integer
i = Integer.parseInt(repeatString);
System.exit(0);
}
//Calculate hat size
public static double hood(int weight, int height) {
double hat = (weight / height) * 2.9;
return hat;
}
//Calculate jacket size
public static double coat(int age, int weight, int height) {
double jacket;
if (age >= 40)
jacket = (((age / 40) * 1.8) + ((height * weight) / 228));
else
jacket = ((height * weight) / 228);
return jacket;
}
//Calculate waist size
public static double belt(int age, int weight, int height) {
double waist;
if (age > 28)
waist = (((age / 29) * (1 / 10)) + (weight / 5.7));
else
waist = (weight / 5.7);
return waist;
}
public static int reportResults(double hat, double jacket, double waist) {
String resultString = "The hat size is " + hat + ". \nThe jacket size
is " + jacket + ". \nThe waist size is " + waist + ".";
JOptionPane.showMessageDialog(null, resultString, "Project 3",
JOptionPane.INFORMATION_MESSAGE);
}
}
- Next message: Matt Humphrey: "Re: DecimalToBinary can't handle numbers greater that 63"
- Previous message: Chris Smith: "Re: LinkedList clear() method and C++ copy constructor confusion"
- Next in thread: Mike B: "Re: help"
- Reply: Mike B: "Re: help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|