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.

Write java program quickly please i will wait your solving

Write Java Program Quickly Please I Will Wait Your Solving class=

Sagot :

genan

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

View image genan
View image genan