Solve problem 3.
Code from ques 1 and 2:
import java.util.Scanner;
/**This program keeps track of user's active time in minutes for a month**/ public class ActiveMinutesDay {
public static void main(String[] args) {
//Get user input using scanner Scanner in=new Scanner(System.in); //Declare variables int month=1; int day=1; int daysInMonth=0; int minutes=0; double minutesSum=0; month=in.nextInt(); //Assign days for given month if(month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12) { daysInMonth=31; } else if(month==2) { daysInMonth=28; } else if(month==4 || month==6 || month==9 || month==11 ) { daysInMonth=30; } else { System.out.println("Invalid month. Exiting!"); System.exit(-1); } //Proceed until user enters 0 for day while(day!=0) { day=in.nextInt(); //Proceed only if day is non-zero if(day!=0) { minutes=in.nextInt(); //Calculate minutes total if(day>0 && day }
Problem 1 - Keeping tracking of active time (running, walking, etc) In this first problem, will you start implementing a program that will keep track of the user's active time (in minutes) for a specified month. The program will also calculate the total amount of active minutes on that particular month Your program will first read a number from 1 to 12 (included). This number will represent which month the user will input his active minutes. Based on that, you should define how many days exist on the month. Assume that February always has 28 days. After, you will start reading the day and the active minutes of that day. You will keep reading day and minutes until you read as an input for the day value. There can be multiple entries for the same day. Once you read zero for the day number, you should stop and not read the minutes. Please be aware that the user might mistakenly input a day value that is not within the range of numbers in a month (e.g., day 31 in April or -10). If that occurs, you should discard the minutes (you still need to read the user's minutes). Once you are done reading the information, your program will print the total amount of active minutes on the month and the average active minutes. Remember that each day has 24 hours, and each hour has 60 minutes. You must limit your average value to 2 decimal points. If you are writing your assignment in Java, you can use the System.out.printf method. Input for Java AND Python: Inputs are separated by Enter, that is, one number per line. Input One int representing the number of the month (1-12) One int representing the day One int representing the active minutes Output The total and average active minutes for that month 7 32 10000000 On month #7, you were active 1310 minutes or 0.03% of the time. 100 9 90 15 10 15 60 DOW OPP 90 13 60 20 300 23 600 0 Problem 2 - The most active day Now, you will add an extra functionally to your program: your program will identify and print the day in which the user was most active, that is, the day with the most active minutes. The program's input is still the same, a number representing the month, then days and active minutes. You can (and should) copy your code from Problem 1 and use it as a starter code. After your program prints the total and average of the active minutes (output from problem 1), you will print the most active day according to the examples below. Tip: You should use a 10 array to keep track of the active minutes. Remember that arrays begin at 0 in most programming languages. 7 32 On month #7, you were active 1310 minutes or 0.03% of the time. You were most active on day 23 with 600 minutes. 10000000 4 100 9 90 15 10 15 60 30 90 13 60 20 300 23 600 0 Problem 3 - The activity histogram In this problem, you will add a visualization of the users activity as a histogram that plots the active minutes of each day. As an example, a hisotram for the following output: 2130 4 90 8 100 15 9 0 is depicted below (truncated at day 16 to fit the text, it should go to the last day of the month). 2 3 4 5 6 7 10 11 12 13 14 15 16 To solve this problem, you will need to use a 10 array. Each star in the histogram represents 10 minutes worth of exercise. For example, on day 1, the user had between 30 and 39 active minutes. Your program will print the histogram after it prints the information from P1 and P2