Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please step by step to explain how the code solves the question. pic one is the code pic two is the question the code the

please step by step to explain how the code solves the question. pic one is the code pic two is the question
the code
image text in transcribed
the problem
image text in transcribed
//=>MonthActiveTime.java import java.util. HashMap: import java.util.Scanner public class MonthactiveTime ( public static void main(String[] args) { HashMap Integer, Integer monthDaysMap - new HashMapot) monthDaysMap.put(1,31); monthDaysMap.put(2,28); monthDaysMap.put(3,31) monthDaysMap.put(4,30) monthDaysmap.put(5,31) monthDaysMap.put(6,30) monthDayamap.put(7,31) monthDays Map.put(8,31); monthDaysMap.put(9,30); monthDaysMap.put(10,31); monthDaysMap.put(11,30); monthDaysMap.put/12,31); Seanner scanner = new Scanner(System.in); int month - scanner.nextInt() int totalMinutes - 0; 17 [monthDays Map.contains Key (month)) { int day - scanner.nextInt () while (day 0){ 1/System.out.printint "Day:"tday); if(daymonthDaya Map.get(month)) scanner.nextInt() 1/System.out.println("Discart:"+day); day scanner.nextInt(): continue : } int minutes - scanner.nextInt(); totalminutes + minutes //System.out.println("Total Mint"+totalMinutes): day - scanner.nextInt(): > else return; double totalMinsInMonth monthDaysMap.get(month) 24-60; double cent - 0100.0d/totalMinsInMonth)"totalMinutes System.out.println("on month #" +month+", you were active totalMinutest" minutes or +String.format("$.24.cent)+" of the time.") 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 minuten 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 date on the month. Assume that February always has 21 days Alter, you will start reading the day and the active minutes of that day. You will be 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 der for the day number, you should stop and not read the minutes Please be wware that the user might mistakenly input a day value that is not within the range of numbers in a monthlee. day 31 in Aprilor-30). 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 hout has minutes You must limit your average value to 2 decimal points. If you are writing your assignment in Bewe. You can use the System.out.printf method Input for Java AND Python inputs are separated by Enter that is, one number perline Input . One int representing the number of the month(1-12) One int representing the day One in representing the active minutes Output The total and average active minutes for that month Examples: Input 1 30 Output On sonth 2. you were active 22% Rinutes or 0.571 st the time 90 . 100 9 On month 17, you were active 1310 minutes or 2.333 of the time. 32 10000000 4 100 9 90 15 10 15 60 30 90 13 60 20 300 23 600

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 2 Lnai 9285

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Joao Gama ,Alipio Jorge ,Carlos Soares

1st Edition

3319235249, 978-3319235240

More Books

Students also viewed these Databases questions

Question

Have roles been defined and assigned?

Answered: 1 week ago

Question

Are these written ground rules?

Answered: 1 week ago

Question

How do members envision the ideal team?

Answered: 1 week ago