Jane
October 6th, 1999, 10:21 PM
please help me. I'm not sure how to read in the strings and integers. I'd like another class named Reader, but i'm not sure of the correct syntax. Below is what the program is supposed to do:
package simpleIO;
import java.io.*;
import java.text.*;
public class BodyMass
{
public static void main (String[]args)
{
person girl=new person ();
girl.getData();
girl.displayData();
girl.displayBMI();
}
}//class BodyMass
public class person
{
private String name;
private double height, weight, heightFeet, heightInches;
public void getData();
}
class Reader ?????
{
BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
???????????????????
}//class Reader
public void getData();
{
System.out.print("Name:");
name=Reader.readString();
System.out.print("Height in inches:");
heightInches=Reader.readheightInches;
System.out.print("Weight:");
weight=Reader.readweight;
}
}//void getData();
public void displayData();
{
System.out.println("Your name is " + name);
System.out.println("Your height is " + height);
System.out.println("Your weight is " + weight);
}
}//displayData
public void displayBMI();
{
BMI=(weight * 705)/heightInches * heightInches;
System.out.printline("Your body mass index is " + BMI);
}
}//displayBMI
==================
Java application that has two classes, one containing the main method that starts the action and the other that describes a person. The data for this class should be a person's name, weight in pounds and height in feet and inches. It should have a method that reads in the data from the keyboard and another that displays the information.
A third method should calculate (and return) the person's body mass index. To compute this, multiply the person's weight in pounds by 705. Then divide this result by the person's height in inches squared. For example, if the person weighs 120 pounds and is 5 feet 2 inches tall (62 inches), his or her body mass index is (120 * 705) / (62 * 62) or 22.
The main method should declare a person and then call the appropriate methods to read in and display the data. It should then display the person's body mass index.
package simpleIO;
import java.io.*;
import java.text.*;
public class BodyMass
{
public static void main (String[]args)
{
person girl=new person ();
girl.getData();
girl.displayData();
girl.displayBMI();
}
}//class BodyMass
public class person
{
private String name;
private double height, weight, heightFeet, heightInches;
public void getData();
}
class Reader ?????
{
BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
???????????????????
}//class Reader
public void getData();
{
System.out.print("Name:");
name=Reader.readString();
System.out.print("Height in inches:");
heightInches=Reader.readheightInches;
System.out.print("Weight:");
weight=Reader.readweight;
}
}//void getData();
public void displayData();
{
System.out.println("Your name is " + name);
System.out.println("Your height is " + height);
System.out.println("Your weight is " + weight);
}
}//displayData
public void displayBMI();
{
BMI=(weight * 705)/heightInches * heightInches;
System.out.printline("Your body mass index is " + BMI);
}
}//displayBMI
==================
Java application that has two classes, one containing the main method that starts the action and the other that describes a person. The data for this class should be a person's name, weight in pounds and height in feet and inches. It should have a method that reads in the data from the keyboard and another that displays the information.
A third method should calculate (and return) the person's body mass index. To compute this, multiply the person's weight in pounds by 705. Then divide this result by the person's height in inches squared. For example, if the person weighs 120 pounds and is 5 feet 2 inches tall (62 inches), his or her body mass index is (120 * 705) / (62 * 62) or 22.
The main method should declare a person and then call the appropriate methods to read in and display the data. It should then display the person's body mass index.