Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Wasif Hassan Niazi 02-235221-012

OOP CLASS TASK 4

import java.util.Scanner;

public class ClassTaskBMI {

public static void main(String[] args) {

Scanner data =new Scanner(System.in);

double weight, height, BMI;

System.out.print("Enter Your Weight: ");

weight=data.nextDouble();

System.out.print("Enter Your Height:");

height= data.nextDouble();

BMI=calculateBMI(weight,height);

findStat(BMI);

public static double calculateBMI (double weight, double height)

{double BMI= (weight/(height*height)*703);

return BMI;

public static String findStat (double BMI) {

if (BMI < 18.5 ) {

System.out.println(" According to your BMI: "+BMI+" , you're currently Underweight");}

else if (BMI >= 18.5 && BMI < 24.9) {

System.out.println("According to your BMI: "+BMI+" , you're currently Normal");}

else if (BMI >= 25.0 && BMI < 29.9) {

System.out.println("According to your BMI: "+BMI+" , you're currently Overweight");}

else if (BMI >= 30) {

System.out.println("According to your BMI: "+BMI+" , you're currently Obese");}

return null;

}// finding status

} //class
Wasif Hassan Niazi 02-235221-012

Q2)

class PatientInfo {

String name;

int age;

String doctorName;

int time;

void getAppointment (String d, int t){

doctorName = d;

time = t;

void displayAppointment () {

System.out.println( " Patient's Appointment to Dr" +doctorName);

System.out.println("The time of Appointment is: " +time ) ;

void insertInfo( String n, int a){

name = n;

age = a; }

void displayInfo() {

System.out.println("Name of patient is:" +name);


Wasif Hassan Niazi 02-235221-012

System.out.println("Age of patient is:" + age);

}}

public class Hosp {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

PatientInfo patient = new PatientInfo() ;

System.out.println("Enter Patient's name: ");

patient.name = input.nextLine();

System.out.println("Enter Patient's age: ");

patient.age = input.nextInt();

System.out.println("Which doctor do you have appointment with? ");

patient.doctorName = input.next();

System.out.println("Enter Appointment time: ");

patient.time = input.nextInt();

patient.insertInfo(patient.name, patient.age);

patient.getAppointment (patient.doctorName , patient.time);

patient.displayInfo();

patient.displayAppointment();

}}
Wasif Hassan Niazi 02-235221-012

You might also like