import javax.swing.JOptionPane;
public class ReverseNumbers
{
private static final int MAX = 10;
public static void main(String[] args)
{
int numbers[] = new int[MAX];
String input;
String output;
for (int i=0; i<numbers.length; i++)
{
input = JOptionPane.showInputDialog(null, "Enter integer #"+(i+1)+": ");
numbers[i] = Integer.parseInt(input);
}
output = "The numbers entered in reverse order are:";
for (int i=numbers.length-1; i>=0; i--)
output += "\n"+numbers[i];
JOptionPane.showMessageDialog(null, output);
}
}
^^^ This is the code to which I need to implement into what I already have... I'm a complete beginner so I do not quite know
how to do this... Any feedback is appreciated. Below is what I have already..
//************************************************** ***********************************************
//* Program calculates BMI for individuals who weigh between 60 to 400 pounds and 48 to 96 inches *
//* This program will create an array of individuals. *
//************************************************** ***********************************************
//
import javax.swing.JOptionPane;
// Name the class
public class BMI4
{
public static void main (String[] args)
{
// Declare the variables
String firstName;
String lastName;
int weight;
double height;
BMICalculator2[] bmiObjects;
String BMIRating = "Normal";
String input;
int numberOfPeople;
input = JOptionPane.showInputDialog(null, "How many people do you want to calculate BMI?", "Number of People",
JOptionPane.QUESTION_MESSAGE);
numberOfPeople = Integer.parseInt(input);
bmiObjects = new BMICalculator2[numberOfPeople];
for (int count=0; count<bmiObjects.length; count++)
{
// IMPROVE THIS USING Count AS WAS DONE WITH i IN ReverseNumbers.java
firstName = JOptionPane.showInputDialog(null, "Please enter your first name: ");
lastName = JOptionPane.showInputDialog(null, "Please enter your last name: ");
weight = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter your weight in lbs (Weight must be between 60-400lbs): "));
// Validate correct weight entry
while (weight < 60 || weight > 400)
{
weight = Integer.parseInt(JOptionPane.showInputDialog(null,
"Weight must be between the range of 60 to 400 lbs. Please enter a valid weight."));
}
height = Double.parseDouble(JOptionPane.showInputDialog(nul l,
"Enter your height in inches (Height must be between the range of 48 to 96 inches. Please enter a valid height."));
// Validate correct height entry
while (height < 48 || height > 96)
{
height = Double.parseDouble(JOptionPane.showInputDialog(nul l,
"Height must be between the range of 48 to 96 inches Please enter a valid height."));
}
bmiObjects[count] = new BMICalculator2(firstName, lastName, weight, height);
} // for
for (int count=0; count<bmiObjects.length; count++)
{
// Output information
JOptionPane.showMessageDialog(null, bmiObjects[count], "BMI Calculation #"+(count+1), JOptionPane.INFORMATION_MESSAGE);
} // for
} // main
} // class