我刚刚编辑了我的帖子以更新我的代码......当我编译指出“找不到符号”时,我仍然收到一条错误消息。我从来没有见过这个错误所以我不知道如何调试它,非常感谢大家的帮助!
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();
}
}