Discover a world of knowledge at Westonci.ca, where experts and enthusiasts come together to answer your questions. Explore thousands of questions and answers from knowledgeable experts in various fields on our Q&A platform. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.
Sagot :
Answer:
Output:
Ali : Very Overweight
Mohammed : Very Overweight
Salma : Very Overweight
Huda : Normal
Jassim : Very Overweight
Fatima : Very Overweight
Explantion:
Step 1: Code is Given Below
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
public class BMI {
public static void main(String[] args) throws IOException {
File file=new File("People.txt"); //creates a new file instance
FileReader fr=new FileReader(file); //reads the file
BufferedReader br=new BufferedReader(fr);
String line;
//read file line by line
while((line=br.readLine())!=null){
//split line by space
String data[]=line.split(" ");
//extract name, weight and height
String name=data[0];
int weight=Integer.parseInt(data[1]);
double height=Double.parseDouble(data[2]);
//find BMI
double bmi=weight/(height*height);
System.out.print(name+" : ");
//check if BMI Class
if(bmi<18.5)
System.out.println("Underweight");
else if(bmi<=24.9)
System.out.println("Normal");
else if(bmi<=29.9)
System.out.println("Overweight");
else
System.out.println("Very Overweight");
}
}
}
Hope this helps, Let me know if you have any questions !
Screenshot for more organize set up of the code
We appreciate your time. Please come back anytime for the latest information and answers to your questions. We hope you found what you were looking for. Feel free to revisit us for more answers and updated information. Stay curious and keep coming back to Westonci.ca for answers to all your burning questions.