Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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,

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 1D array to keep track of the active minutes.

Need help with problem 2. first one is already completed

Code:

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

}

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

Discuss the key components of PMSs.

Answered: 1 week ago