Write a program that displays the recommended weight, given the user’s age and height (cm). The formula for calculating the recommended weight is

recommendedWeight = (height – 100 + age / 10) * 0.90

Define a service class named Height and include an appropriate method for getting a recommended weight of a designated height.

rehesujhejh6j6rsj6

Sure! Here's an example of how you can write a program that calculates the recommended weight based on the user's age and height:

```java
import java.util.Scanner;

public class Height {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

System.out.print("Enter your age: ");
int age = input.nextInt();

System.out.print("Enter your height (in cm): ");
int height = input.nextInt();

double recommendedWeight = calculateRecommendedWeight(age, height);

System.out.println("Your recommended weight is: " + recommendedWeight);
}

public static double calculateRecommendedWeight(int age, int height) {
double recommendedWeight = (height - 100 + age / 10) * 0.90;
return recommendedWeight;
}
}
```

In this program, we define a service class called `Height` which includes a method `calculateRecommendedWeight` that takes in the user's age and height as parameters and calculates the recommended weight using the given formula.

The `main` method prompts the user to enter their age and height, then calls the `calculateRecommendedWeight` method to calculate and display the recommended weight.

To write a program that displays the recommended weight given the user's age and height, you can follow these steps:

1. Create a new Java class called `Height` to define the service class.
2. Inside the `Height` class, define a method called `getRecommendedWeight` with two parameters: `age` of type `int` and `height` of type `double`.
3. Calculate the recommended weight using the provided formula: `recommendedWeight = (height - 100 + age / 10) * 0.90`.
4. Return the calculated `recommendedWeight` value from the `getRecommendedWeight` method.

Here's an example implementation:

```java
public class Height {
public double getRecommendedWeight(int age, double height) {
double recommendedWeight = (height - 100 + age / 10) * 0.90;
return recommendedWeight;
}
}
```

Now you can use the `Height` class to get the recommended weight for a given age and height. Here's an example:

```java
public class Main {
public static void main(String[] args) {
Height height = new Height();
int age = 25;
double heightInCm = 170.0;
double recommendedWeight = height.getRecommendedWeight(age, heightInCm);
System.out.println("Recommended weight: " + recommendedWeight);
}
}
```

In this example, the `main` method creates an instance of the `Height` class and calls the `getRecommendedWeight` method to calculate the recommended weight based on an age of 25 and a height of 170 cm. The calculated recommended weight is then printed to the console.