A company wants to promote a dish that must be cooked for a predetermined time.
ID: 3564751 • Letter: A
Question
A company wants to promote a dish that must be cooked for a predetermined time. The company wants to develop an application to be placed on their website such that a user can enter the hours and minutes when the meal will be served and the app then calculates when the dish must be placed in the oven and when it must come out. The 24-hour clock convention will be used to enter the time. Following the 24-hour clock convention, the hours and minutes will be placed in separate variables. Do not choose a serving and cooking time that overlaps midnight (00:00). Write a script to perform the following calculations using the following steps
a)Define the variables numberHoursInDay=24; minutesInHour=60;
b) Obtain the time when the dish must be served. Place the hours in variable, eatHour, and the minutes in variable, eatMinute
c) Obtain the time the dish must be in the oven in minutes. Place it in variable, roastTimeMinute
d) Calculate in minutes of the day, when the cooking must end. Place the answer in the variable, endMinutesRoast.
e) Using a similar time format, calculate the minutes in the day when the cooking should start. Place it in the variable, startMinutesRoast
f) Making use of the arrays below, and relational array operators, calculate the time in 24-hour clock convention when the dish must be placed in the oven (place the answer in the variables hourIn and minutesIn) and when it needs to come out (hourOut and minutesOut).
h) See if you can find a different and more elegant way using array operations to calculate the values in the array, arrayOfHourInDay. Place the answer in, alternateWay.
Explanation / Answer
clc;
close all;
clear all;
numberHoursInDay=24;
minutesInHour=60;
eatHour = input('at hour is the order to be served');
eatMinute = input('at minute is the order to be served');
roastTimeMinute =input('how much time does it need to be roasted for');
endMinutesRoast = eatHour*minutesInHour+eatMinute ;
startMinutesRoast =endMinutesRoast-roastTimeMinute;
MinutesIn = rem(startMinutesRoast , minutesInHour);
HoursIn=startMinutesRoast/minutesInHour-rem(startMinutesRoast , minutesInHour)/minutesInHour;
MinutesOut =rem(endMinutesRoast , minutesInHour);
HoursOut=endMinutesRoast/minutesInHour-rem(endMinutesRoast , minutesInHour)/minutesInHour;
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.