40,204 views
34 votes
34 votes
Write java program quickly please i will wait your solving

Write java program quickly please i will wait your solving-example-1
User Mikeyreilly
by
3.1k points

1 Answer

27 votes
27 votes

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

Write java program quickly please i will wait your solving-example-1
Write java program quickly please i will wait your solving-example-2
User Spanky
by
2.9k points