The Program Inputs Are

The Program Inputs Are

<p>Example 1 The alarm clock has the following: (1) alarm set time, (2) current time, and (3) desired “snooze” time. Use your knowledge of loops (for-end and/or while-end) and conditional statements to write a MATLAB program that outputs the wake up time of an individual using an alarm clock. The program inputs are: (1) Alarm set time (disregard AM and PM setting), alarmset as an array with 1 row and 2 columns, with the first element being the hour and the second element being the minutes. (2) Initial “snooze” time, isnooze. (This time is always ≥4) (3) Number of times the “snooze” button is used, n. (0 ≤ n ≤ 50) Each time the snooze button is used after the first use the snooze time decreases by 1 minute, however, the minimum snooze time is 4 minutes. The program output is (after the n snooze(s)): (1) Final wake up time, wakeup as an array with 1 row and 2 columns, with the first element being the hour and the second element being the minutes.</p><p>Example: If the alarm set time is at 7:30 and is entered as alarmset=[7 30], the initial snooze time is set at 8 minutes, and the snooze button was used 6 times, the wake up time is 8:04 (overall snooze time is: 8+7+6+5+4+4=34), hence wakeup=[8 4]. Test the program for the above example.</p><p>Example 2 a) A prime number is a positive whole number which has exactly two distinct number divisors. In other words, a prime number is only divisible by itself and 1. For example, 2, 3, 5, 7, 11, 13 are prime numbers, note that the number 1 is not a prime number. Use your knowledge of loops (for-end and while-end) and/or conditional statements to write a MATLAB program that determines if an input number is a prime number. The program inputs are: 1) Any whole number, n. ( n  1) The program outputs are: 2) Brief description on whether or not the input number is a prime number.</p><p>Test your program for the number 97, which is a prime number. b) Provided with the following geometric series: S  a  ar ar 2  ...  ar n  write a MATLAB program that uses your programming knowledge (for-end loops and/or while-end loops and/or conditional statements) to determine the value of S given inputs a, r and n. The inputs are: 1) Constant, a. a  0 2) Value, r r  0 3) Value, n. n  0 The program outputs are: 2) The numeric value of S.</p><p>Test and run your program for the following combination of a, r, and n. a = 3, r = 2.1, n = 8.</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    1 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us