投稿を編集してコードを更新しました...コンパイルすると、「シンボルが見つかりません」というエラーメッセージが表示されます。このエラーは見たことがないので、デバッグ方法がわかりません。皆さんの助けに本当に感謝しています!
public class HealthRecord {
private int ID; // stores ID number
private String last; // stores last name
private String first; //stores first name
private double height; // stores height
private double weight; // stores weight
private double bmi;// i may need to create the bmi variable so that it can be stored (weight / (height*height)) *703;
public HealthRecord( int ID, String last, String first, double height, double weight)
{
this.ID = ID;
this.last = last;
this.first = first;
this.height = height;
this.weight = weight;
this.bmi = bmi;
}
public int getID() {
return ID;
}
public void setID(int ID) {
this.ID = ID;
}
public String getLast() {
return last;
}
public void setLast(String last) {
this.last = last;
}
public String getFirst() {
return first;
}
public void setFirst(String last) {
this.first = first;
}
public double getheight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
public double getWeight() {
return weight;
}
public void setWeight(double weight) {
this.weight = weight;
}
public double getbmi() {
return (weight / (height*height)) *703;
}
public void setbmi(double bmi) {
this.bmi = bmi;
}
}
次の授業
import java.util.Scanner;
import java.io.File;
public class OpenFile
{
private Scanner input;
public void openFile() throws Exception
{
input = new Scanner(new File("medrec.txt")); // opens the text file to be read (weight / (height*height)) *703);
}
public void readFile()
{
int ID; // stores ID number
String last; // stores last name
String first; //stores first name
double height; // stores height
double weight; // stores weight
input.nextLine();
while(input.hasNextLine())
{
ID = input.nextInt();
last = input.next();
first = input.next();
height = input.nextDouble();
weight = input.nextDouble();
HealthRecord healthrecord= new HealthRecord(ID,last,first,height,weight);
System.out.printf("%d", healthrecord.getID(), healthrecord.getBmi());
}
}
public void closeFile()
{
input.close();
}
}