Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please dont use loops. Problem 2 (15 points) It is often important to validate if the user entered an acceptable input to a program. For

Please dont use loops.

image text in transcribedimage text in transcribedimage text in transcribed

Problem 2 (15 points) It is often important to validate if the user entered an acceptable input to a program. For this problem, you may safely assume that the user only enters positive numeric integer inputs (i.e. do not consider the case where the user inadvertently enters letters instead ofnumbers, or the case where the user has entered negative numbers). Emulate the output format below; your code should printthe output exactly as shown in the sample runs. Your code should also be generalized enough to handle additional cases beyond the numbers in the sample runs. Prompt the user to enter a number of days, to enter a number of hours, to enter a number of minutes, and to enter a number of seconds. Print the values that the user entered to the Command Window Consider the following maximums: There are 24 hours in a day; a correction will be needed if the user enters more than 23 There are 60 minutes in an hour, a correction will be needed if the user enters more than 59 There are 60 seconds in a minute; a correction will be needed if the user enters more than 59 If the user's input meets or exceeds any, some, or all of these maximums, correct their values so that they do not exceed the maximum. As a numeric example, if the user enters 2 days, 30 hours, 62 minutes, and 62 seconds, the program should store the data as 3 days, 7 hours, 3 minutes, and 2 seconds. Only use techniques discussed in the course to perform the correction (i.e. do not look up alternative built-in MATLAB approaches to perform the correction). The number of days does not need to be constrained (i.e. do not worry about years Test to see if any correction was made to any of the user's inputs. If there was a correction to any of the values the user entered, print the statement "The user entered values required correction" lf there was not a correction, print the statement "The user-entered values required no correction." Furthermore, if the values were corrected, print the corrected values. Sample runs of this code with output follow below

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_2

Step: 3

blur-text-image_3

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

Guide To Client Server Databases

Authors: Joe Salemi

2nd Edition

1562763105, 978-1562763107

More Books

Students also viewed these Databases questions

Question

Calculate the lifetime value (LTV) of a loyal customer.

Answered: 1 week ago