1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alexandra [31]
3 years ago
5

Create a java program using the following instructions:

Computers and Technology
1 answer:
Tom [10]3 years ago
6 0

Answer:

import java.util.Scanner;

public class HealthProfile  

{

private String name;

private int age;

private double weight;

private double height;

private double bmi;

private String category;

 

 

public void setName(String name)

{

 this.name = name;

}

public String getName()

{

 return name;

}

public void setAge(int age)

{

 this.age = age;

}

public int getAge()

{

 return age;

}

public void setWeight(double weight)

{

 this.weight = weight;

}

public double getWeight()

{

 return weight;

}

public void setHeight(double height)

{

 this.height = height;

}

public double getHeight()

{

 return height;

}

public void setBmi(double bmi)

{

 this.bmi = bmi;

}

public double getBmi()

{

 bmi = (weight * 703) / (height * height);

 return bmi;

}

public void setCategory(String category)

{

 this.category = category;

}

public String getCategory()

{

 if (bmi < 18.5){

  category = "underweight";

 } else if (bmi < 25){

  category = "normal";

 } else if (bmi < 30){

  category ="overweight";

 }else{

  category = "obese";

 }

 

 return category;

}

 

 

public static void main(String[] args)

{

Scanner input = new Scanner(System.in);

 

HealthProfile myHealthProfile = new HealthProfile();

System.out.println("This program reads in your data and calculates your Body Mass Index (BMI)");

System.out.println("Please enter your name: ");

String theName = input.nextLine();

myHealthProfile.setName(theName);

System.out.println("Please enter your age: ");

int theAge = input.nextInt();

myHealthProfile.setAge(theAge);

System.out.println("Please enter your weight in pounds: ");

double theWeight = input.nextDouble();

myHealthProfile.setWeight(theWeight);

System.out.println("Please enter your height in inches: ");

double theHeight = input.nextDouble();

myHealthProfile.setHeight(theHeight);

System.out.println();

System.out.println(theName);

System.out.printf("Your age is %s\n", myHealthProfile.getAge());

System.out.printf("Your weight is %s\n", myHealthProfile.getWeight(), "LBS");

System.out.printf("Your height is %s\n", myHealthProfile.getHeight());

System.out.printf("Your Body Mass Index (BMI) is %.2f\n", myHealthProfile.getBmi());

System.out.printf("You are %s\n", myHealthProfile.getCategory());

 

 

 

System.out.println();

System.out.printf("Name in object myHealthProfile is: %n%s%n", myHealthProfile.getName());

}

}  

You might be interested in
Write a statement that increments (adds 1 to) one and only one of these five variables: reverseDrivers parkedDrivers slowDrivers
MariettaO [177]

Answer:

The c++ coding for this scenario is given below.

if( speed < 0 )

           reverseDrivers = reverseDrivers + 1;

   else if( speed >= 0 && speed < 1 )

           parkedDrivers = parkedDrivers + 1;

   else if( speed >= 1 && speed < 40 )

           slowDrivers = slowDrivers + 1;

   else if( speed >= 40 && speed < 65 )

          safeDrivers = safeDrivers + 1;

   else

     speeders = speeders + 1;

Explanation:

First, five integer variables are declared and initialized.

int reverseDrivers = 0, parkedDrivers = 0, slowDrivers = 0, safeDrivers = 0, speeders = 0;

All the above variables need to be incremented by 1 based on the given condition, hence, these should have some original value.

Another variable speed of data type integer is declared.

int speed;

The variable speed is initialized to any value. User input is not taken for speed since it is not mentioned in the question.

Based on the value of the variable speed, one of the five variables, declared in the beginning, is incremented by 1.

The c++ program to implement the above scenario is as follows.

#include <iostream>

using namespace std;

int main() {

   int reverseDrivers = 0, parkedDrivers = 0, slowDrivers = 0, safeDrivers = 0, speeders = 0;

   int speed = 34;

   

   if( speed < 0 )

   {

       reverseDrivers = reverseDrivers + 1;

       cout<<" reverseDrivers " <<endl;

   }

   else if( speed >= 0 && speed < 1 )

   {

       parkedDrivers = parkedDrivers + 1;

      cout<<" parkedDrivers "<<endl;

   }

   else if( speed >= 1 && speed < 40 )

   {

       slowDrivers = slowDrivers + 1;

      cout<<" slowDrivers "<<endl;

   }

   else if( speed >= 40 && speed < 65 )

   {

       safeDrivers = safeDrivers + 1;

       cout<<" safeDrivers "<<endl;

   }

   else

   {

       speeders = speeders + 1;

       cout<<" speeders "<<endl;

   }

return 0;

}

The program only outputs the variable which is incremented based on the value of the variable speed.

3 0
3 years ago
What type of program would you use to create a personal budget?
zepelin [54]
While Word might be the simplest application for listing your personal income and expenses, using Excel is the easiest way to create and use a budget, based on the formulas you can create to have the budget do the work for you, instead of vice versa.
7 0
3 years ago
Read 2 more answers
Refer to the color wheel to identify the color scheme:
nekit [7.7K]

I believe it's Monochromatic?

I'm not sure but I think it's that.

Good luck! :D

5 0
3 years ago
Once artwork is inserted into a placeholder, it can be moved around on a slide. True False
inn [45]

Answer:

The answer to this question is true.

Explanation:

The artwork is used on the PowerPoint for making the presentation more effective. The artwork is also known as Clip Art. In the Microsoft PowerPoint, the clip art is a collection of media files like image file, video file, an audio file, and an animation file. If our computer has an Internet connection, then we can add new clip art for free. If we use the artwork or clip art on slide So it can be moved around on the slide.

6 0
3 years ago
Complete the statement using the correct term.
vladimir1956 [14]

The BODY of the site is what will be displayed on the web page. It contains most of the distinctive content of the web page.

A web page refers to a document exhibited by the browser, which is generally written in the HTML language.

The body of a web page is a big area in the center that contains the most important and distinctive content of a web page.

The body will determine the central content of the HTML document, which will be observable on the web page (e.g., a photo gallery).

Learn more about a web page here:

brainly.com/question/16515023

5 0
3 years ago
Other questions:
  • You have a hard disk that is formatted with the fat32 file system. you would like to implement file and folder permissions on th
    10·1 answer
  • Why is it important to match the latencies fo the older modules to the newer modules?
    14·1 answer
  • What programming language is used for Arduinos?
    6·2 answers
  • What symbol do you use to choose a feature for your notes on Notion?
    8·1 answer
  • All sensitive media on a laptop should be encrypted.
    14·1 answer
  • Which would be included in a SaaS platform?<br><br> A.data link<br> B.IaaS<br> C.Java<br> D.vb.net
    5·1 answer
  • Read a sentence from the console.
    6·1 answer
  • PLZZZZ HELPPP and please don’t send a link , Explain how the processing stage contributes to a computer creating an output.
    8·1 answer
  • Read each of the following statements about Computer Science and explain why you think that statement is true.
    9·1 answer
  • A classic game, Wario Land, has an invincible main character who reacts to the environment in order to solve puzzles. So, for ex
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!