Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java 1. USE OBJECT ORIENTATED PROGRAM DESIGN TO SOLVE PROBLEM Create a class BMI

ID: 3698035 • Letter: J

Question

Java 1. USE OBJECT ORIENTATED PROGRAM DESIGN TO SOLVE PROBLEM Create a class BMI. (Body Mass Index) BMI = 703 astir weight/height astir height//Weight in lbs, height in inches The BMI class should also return the person's name using the program. Create a method for calculating BMI and round BMI to 1 decimal place Create a method for returning the BMI possibilities Severe Thinness 40.1 Construct your class to contain multiple constructors. Use the this. Keyword if you like. Execute a few versions of the program Passing different values into the program using different parameter and argument configurations.1 Output: The BMI for John is 26.5 which is the Over Weight Category, or The BMI for Susan is 17 which is in the Moderate Thiness Category 2. Create a computer program that will calculate the range for 3 different vehicles. The program should create a "programmer created" class, where 3 int objects are created passengers, fuel capacity, mpg. Create a voidQ method inside the "programmer created " class to calculate vehicle range, range = fuel capacity * miles per gallon. Each Vehicle type should have unique values for number of passengers, fuel capacity, and miles per gallon. Follow the sample below and return information on 3 vehicle types. Sample Output://Create similar output for 3 Vehicle Types The minivan carries= 7 The minivan has a fuel capacity of = 16 The minivan mpg = 21 The minivan has a range of: 336 miles

Explanation / Answer

1)

BMI.java

package org.students;

import java.util.Scanner;

public class BMI {

   public static void main(String[] args) {
       // Variables
       String name; //The User's name
       double weight; // The user's weight
       double height; // The user's height
       double bmi; // The user's BMI
       String description=" ";
      
       // Create a Scanner object for keyboard input.
       Scanner keyboard = new Scanner(System.in);
       Scanner keyboard1 = new Scanner(System.in);
         
       // Tell the user what the program will do.
       System.out.println(":: This program will calculate your body mass index, or BMI ::");
      
       //Getting Name of the user
       System.out.print("Enter the Name :");
       name=keyboard1.next();
      
       // Get the user's weight.
       System.out.print("Enter your weight, in Pounds(lbs) : ");
       weight = keyboard.nextDouble();
         
       // Get the user's height.
       System.out.print("Enter your height, in inches: ");
       height = keyboard.nextDouble();
      
       //Calling the method which calculate BMI
       bmi=calculateBMI(height, weight);
      
       if(bmi<16)
       {
           description="Severe Thickness";
       }
       else if(bmi>16.1 && bmi<17)
       {
           description="Moderate Thickness";
       }
       else if(bmi>17.1 && bmi<18.5)
       {
           description="Mild Thinness";
       }
       else if(bmi>18.6 && bmi<26)
       {
           description="Normal";
       }
       else if(bmi>26.1 && bmi<30)
       {
           description="Over Weight";
       }
       else if(bmi>30.1 && bmi<35)
       {
           description="Obese Calss 1";
       }
       else if(bmi>35.1 && bmi<40)
       {
           description="Obese Class 2";
       }
       else if(bmi>40.1)
       {
           description="Obese Class 3";
       }
      
       // Display the user's BMI.
       System.out.println("The BMI for '"+name+"' is "+ bmi+" which is '"+description+"' cattegory");
  

   }
   //Method which calculate the BMI
   public static double calculateBMI (double height, double weight) {
   return weight * 703 / (height * height);
   }

}

______________________________________________________________________________

output:

:: This program will calculate your body mass index, or BMI ::
Enter the Name :John
Enter your weight, in lbs: 220
Enter your height, in inches: 68
The BMI for 'John' is 33.44723183391003 which is 'Obese Calss 1' cattegory

____________________________________________________________________________________

2)

package org.students;

public class VehicleRange {
   //Instance variables
   private String vname;
   private int noofpassengers;
   private int fcapacity;
   private int milpergal;

   //Parameterized Constructor
   public VehicleRange(String vname, int noofpassengers, int fcapacity,
           int milpergal) {
       super();
       this.vname = vname;
       this.noofpassengers = noofpassengers;
       this.fcapacity = fcapacity;
       this.milpergal = milpergal;
   }

//Method which calculates the range
   void calRange()
   {
       int range=fcapacity * milpergal;
       System.out.println("The "+vname+" carries ="+noofpassengers);
       System.out.println("The "+vname+" has a fuel capacity ="+fcapacity);
       System.out.println("The "+vname+" mpg ="+milpergal);
       System.out.println("The "+vname+" has a range of :"+range+" miles");
       System.out.println("_________________________________");
       }

   public static void main(String[] args) {
       //Creating references to VehicleRange class.
       VehicleRange vr,vr1,vr2;
      
   //Creating an object to VehicleRange class by passing parameters.
       vr=new VehicleRange("Minivan", 7, 16, 21);
       //Calling the method.
       vr.calRange();
      
       //Creating an object to VehicleRange class by passing parameters.
       vr=new VehicleRange("Car", 4, 30, 15);
       //Calling the method.
       vr.calRange();
      
       //Creating an object to VehicleRange class by passing parameters.
       vr=new VehicleRange("Bus", 50, 40, 10);
       //Calling the method.
       vr.calRange();

   }

}

_____________________________________________________________________________________

output:

The Minivan carries =7
The Minivan has a fuel capacity =16
The Minivan mpg =21
The Minivan has a range of :336 miles
_________________________________
The Car carries =4
The Car has a fuel capacity =30
The Car mpg =15
The Car has a range of :450 miles
_________________________________
The Bus carries =50
The Bus has a fuel capacity =40
The Bus mpg =10
The Bus has a range of :400 miles
_________________________________

___________________________________________________________________________________

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote