From health tips to tech hacks, find it all on IDNLearn.com. Join our community to receive prompt and reliable responses to your questions from knowledgeable professionals.

Write java program quickly please i will wait your solving

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

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

View image Genan
View image Genan