Develop a Java program to help a user manage their daily water intake.Allow the user to input the amount of water consumed (in liters) for morning,afternoon, and evening. Use control statements to calculate the total waterconsumed throughout the day. Implement operators to perform arithmeticcalculations to determine the total water intake. Display the total water intaketo the user and provide feedback on whether they have met or exceeded therecommended daily water intake (e.g., 2.5 liters). Utilize appropriate datatypes, operators, and control statements to help users track and manage theirdaily water intake effectively.
Question
Develop a Java program to help a user manage their daily water intake.Allow the user to input the amount of water consumed (in liters) for morning,afternoon, and evening. Use control statements to calculate the total waterconsumed throughout the day. Implement operators to perform arithmeticcalculations to determine the total water intake. Display the total water intaketo the user and provide feedback on whether they have met or exceeded therecommended daily water intake (e.g., 2.5 liters). Utilize appropriate datatypes, operators, and control statements to help users track and manage theirdaily water intake effectively.
Solution
Here is a simple Java program that can help a user manage their daily water intake:
import java.util.Scanner;
public class WaterIntakeManager {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the amount of water consumed in the morning (in liters): ");
double morningIntake = scanner.nextDouble();
System.out.println("Enter the amount of water consumed in the afternoon (in liters): ");
double afternoonIntake = scanner.nextDouble();
System.out.println("Enter the amount of water consumed in the evening (in liters): ");
double eveningIntake = scanner.nextDouble();
double totalIntake = morningIntake + afternoonIntake + eveningIntake;
System.out.println("Your total water intake today is: " + totalIntake + " liters");
if (totalIntake < 2.5) {
System.out.println("You have not met the recommended daily water intake of 2.5 liters. Please drink more water.");
} else if (totalIntake == 2.5) {
System.out.println("You have met the recommended daily water intake of 2.5 liters. Good job!");
} else {
System.out.println("You have exceeded the recommended daily water intake of 2.5 liters. Be careful not to drink too much water.");
}
}
}
This program first prompts the user to input the amount of water they consumed in the morning, afternoon, and evening. It then calculates the total water intake by adding up these three values. The total water intake is then displayed to the user. Finally, the program uses control statements to provide feedback to the user based on whether they have met, not met, or exceeded the recommended daily water intake of 2.5 liters.
Similar Questions
Develop a Java program to assist a user in managing their daily calorieintake. Allow the user to input the calories consumed for breakfast, lunch,and dinner. Use control statements to calculate the total calories consumedthroughout the day. Implement operators to perform arithmetic calculationsto determine the total calories. Display the total calorie count to the userand provide feedback on whether they have exceeded or stayed within theirdaily calorie limit (e.g., 2000 calories). Utilize appropriate data types,operators, and control statements to help users track and manage their dailycalorie intake effectively.
Write a program in java to input number of water units consumed.Get the details like consumer name, consumer number, consumer type and the no. of units consumed. If the consumer is “Domestic” compute the total bill amount according to following slab.
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
List two ways we can do to reduce the amount of water used in a day
Determine the estimated total volumes ofwater used in 24 h for “essential” tasks andfor “optional” tasks.
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.