Question
IN JAVA Modify the program below to estimate the number of times a person has sneezed in his/her lifetime. Prompt the user to enter the
IN JAVA
Modify the program below to estimate the number of times a person has sneezed in his/her lifetime. Prompt the user to enter the age in years, calculate the number of days the person has lived and the number of sneezes, then, print the person's age in days and the average number of times sneezed.
Example:
If a person entered 30, the program will print: You are 10950 days old. In average, you have sneezed 43800 times in your lifetime.
import java.util.Scanner;
public class HealthData {
public static void main (String[] args) { Scanner scnr = new Scanner(System.in); int userAgeYears = 0; int userAgeDays = 0; /* FIXME: Declare the variables needed for this calculation */ System.out.println("Enter your age in years: "); userAgeYears = scnr.nextInt(); userAgeDays = userAgeYears * 365; /* FIXME: Calculate the number of sneezes in lifetime */
System.out.println("You are " + userAgeDays + " days old."); /* FIXME: Print the result (end with a new line) */ return; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started