The activity directory at XYZ activity center is listed as below. It is your job to suggest appropriate activities to guests based on the weather: 80 <= temp < 95: swimming 60 <= temp < 80: tennis 40 <= temp < 60: golf 20 <= temp < 40: skiingtemp > 95 or temp < 20 Visit the Activity CenterCreate a java programme that asks the user to enter a temperature and then outputs the suitable activity based on that temperature. Use a cascading if .Input :40Sample Output:Tennis
Question
The activity directory at XYZ activity center is listed as below. It is your job to suggest appropriate activities to guests based on the weather: 80 <= temp < 95: swimming 60 <= temp < 80: tennis 40 <= temp < 60: golf 20 <= temp < 40: skiingtemp > 95 or temp < 20 Visit the Activity CenterCreate a java programme that asks the user to enter a temperature and then outputs the suitable activity based on that temperature. Use a cascading if .Input :40Sample Output:Tennis
Solution
Here is a simple Java program that takes the temperature as input and suggests an activity based on the temperature range:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the temperature:");
int temp = scanner.nextInt();
if (temp >= 80 && temp < 95) {
System.out.println("Suggested Activity: Swimming");
} else if (temp >= 60 && temp < 80) {
System.out.println("Suggested Activity: Tennis");
} else if (temp >= 40 && temp < 60) {
System.out.println("Suggested Activity: Golf");
} else if (temp >= 20 && temp < 40) {
System.out.println("Suggested Activity: Skiing");
} else if (temp > 95 || temp < 20) {
System.out.println("Visit the Activity Center");
}
}
}
This program first asks the user to enter the temperature. It then checks which range the entered temperature falls into using a cascading if statement, and prints the corresponding activity. If the temperature is above 95 or below 20, it suggests visiting the Activity Center.
Similar Questions
Bonus Prelim Activity: Tourism Destination RecommenderObjective:To create a Java program that recommends tourism destinations based on user preferences using the `switch` case statement.Instructions:1. Create a New Java Class:Start by creating a new Java class named `TourismDestinationRecommender`.2. Declare Variables:Declare variables to store user preferences such as budget, preferred climate, and type of activities.3. Display Menu:Implement a menu using the `switch` case statement to allow the user to input their preferences. Menu options should include choices for budget range, climate preference, and preferred activities.4. Recommend Destination:Based on the user's input, use the `switch` case statement to recommend a tourism destination. Consider different destinations for various budgets, climates, and types of activities.5. Display Recommendation:Print a message to the user recommending a specific tourism destination based on their preferences.6. Test the Program:Run the program and test it by entering different combinations of preferences. Ensure that the program accurately recommends suitable destinations.6. Submit the Source CodeSample Output
Objective:To create a Java program that recommends tourism destinations based on user preferences using the `switch` case statement.Instructions:1. Create a New Java Class:Start by creating a new Java class named `TourismDestinationRecommender`.2. Declare Variables:Declare variables to store user preferences such as budget, preferred climate, and type of activities.3. Display Menu:Implement a menu using the `switch` case statement to allow the user to input their preferences. Menu options should include choices for budget range, climate preference, and preferred activities.4. Recommend Destination:Based on the user's input, use the `switch` case statement to recommend a tourism destination. Consider different destinations for various budgets, climates, and types of activities.5. Display Recommendation:Print a message to the user recommending a specific tourism destination based on their preferences.6. Test the Program:Run the program and test it by entering different combinations of preferences. Ensure that the program accurately recommends suitable destinations.6. Submit the Source Code
Objective: To create a Java program that recommends tourism destinations based on user preferences using the `switch` case statement. Instructions: 1. Create a New Java Class: Start by creating a new Java class named `TourismDestinationRecommender`. 2. Declare Variables: Declare variables to store user preferences such as budget, preferred climate, and type of activities. 3. Display Menu: Implement a menu using the `switch` case statement to allow the user to input their preferences. Menu options should include choices for budget range, climate preference, and preferred activities. 4. Recommend Destination: Based on the user's input, use the `switch` case statement to recommend a tourism destination. Consider different destinations for various budgets, climates, and types of activities. 5. Display Recommendation: Print a message to the user recommending a specific tourism destination based on their preferences. 6. Test the Program: Run the program and test it by entering different combinations of preferences. Ensure that the program accurately recommends suitable destinations. 6. Submit the Source Code E:\Java Programs>java TourismDestinationRecommender Tourism Destination Recommender 1. Budget Range 2. Climate Preference 3. Preferred Activities Enter your choice: 1 Select Budget Range (1: Low, 2: Medium, 3: High): 1 Recommended Destination: Backpacking in Southeast Asia E:\Java Programs>java TourismDestinationRecommender Tourism Destination Recommender 1. Budget Range 2. Climate Preference 3. Preferred Activities Enter your choice: 1 Select Budget Range (1: Low, 2: Medium, 3: High): 2 Recommended Destination: Exploring Europe on a Moderate Budget E:\Java Programs>java TourismDestinationRecommender Tourism Destination Recommender 1. Budget Range 2. Climate Preference 3. Preferred Activities Enter your choice: 1 Select Budget Range (1: Low, 2: Medium, 3: High): 3 Recommended Destination: Luxury Retreat in the Maldives E:\Java Programs>java Tourism DestinationRecommender Tourism Destination Recommender 1. Budget Range 2. Climate Preference 3. Preferred Activities Enter your choice: 2 Select Climate Preference (1: Tropical, 2: Temperate, 3: Arctic): 1 Recommended Destination: Bali, Indonesia E:\Java Programs>java TourismDestinationRecommender Tourism Destination Recommender 1. Budget Range 2. Climate Preference 3. Preferred Activities Enter your choice: 2 Select Climate Preference (1: Tropical, 2: Temperate, 3: Arctic): 2 Recommended Destination: Swiss Alps E:\Java Programs>java TourismDestinationRecommender Tourism Destination Recommender 1. Budget Range 2. Climate Preference 3. Preferred Activities Enter your choice: 2 Select Climate Preference (1: Tropical, 2: Temperate, 3: Arctic): 3 Recommended Destination: Reykjavik, Iceland E:\Java Programs>java TourismDestinationRecommender Tourism Destination Recommender 1. Budget Range 2. Climate Preference 3. Preferred Activities Enter your choice: 3 Select Preferred Activities (1: Adventure, 2: Relaxation, 3: Cultural): 1 Recommended Destination: Queenstown, New Zealand E:\Java Programs>java TourismDestinationRecommender Tourism Destination Recommender 1. Budget Range 2. Climate Preference 3. Preferred Activities Enter your choice: 3 Select Preferred Activities (1: Adventure, 2: Relaxation, 3: Cultural): 2 Recommended Destination: Bora Bora for a Relaxing Getaway E:\Java Programs>java TourismDestinationRecommender Tourism Destination Recommender 1. Budget Range 2. Climate Preference 3. Preferred Activities Enter your choice: 3 Select Preferred Activities (1: Adventure, 2: Relaxation, 3: Cultural): 3 Recommended Destination: Rome, Italy for Cultural Exploration E:\Java Programs>java TourismDestinationRecommender Tourism Destination Recommender 1. Budget Range 2. Climate Preference 3. Preferred Activities Enter your choice: 4 Invalid Menu Choice E:\Java Programs>java TourismDestinationRecommender Tourism Destination Recommender 1. Budget Range 2. Climate Preference 3. Preferred Activities Enter your choice: 0 Invalid Menu Choice E:\Java Programs>java TourismDestinationRecommender Tourism Destination Recommender 1. Budget Range 2. Climate Preference 3. Preferred Activities Enter your choice: -1 Invalid Menu Choice
Which physiological indicator can be used to monitor the intensity of physical activity during MVPAs?*1 pointA. Heart rateB. Blood pressureC. Body temperatureD. Respiratory rate
Develop a Java program to assist a user in managing their daily exerciseroutine. Allow the user to input the duration (in minutes) of exercisesperformed for morning, afternoon, and evening. Use control statements tocalculate the total exercise time throughout the day. Implement operators toperform arithmetic calculations to determine the total exercise time. Displaythe total exercise time to the user and provide feedback on whether they havemet or exceeded their daily exercise goal (e.g., 60 minutes). Utilizeappropriate data types, operators, and control statements to help users trackand manage their daily exercise routine effectively
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.