0% found this document useful (0 votes)
51 views6 pages

Practical Exam # 2 Date JULY 30, 2023 Name Mina, Dianne Joy L. Score Filename: Content: PE - 1surname.m and PE - 2surname.m

This document contains instructions for a MATLAB practical exam involving two programming questions. The first question asks to create a program using a switch statement that takes a month number as input and outputs the number of days in that month. The second question asks to create a program using if/elseif/else statements that takes a 12-hour time as input and outputs the equivalent 24-hour time, handling invalid inputs. The document provides sample outputs and grading criteria.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views6 pages

Practical Exam # 2 Date JULY 30, 2023 Name Mina, Dianne Joy L. Score Filename: Content: PE - 1surname.m and PE - 2surname.m

This document contains instructions for a MATLAB practical exam involving two programming questions. The first question asks to create a program using a switch statement that takes a month number as input and outputs the number of days in that month. The second question asks to create a program using if/elseif/else statements that takes a 12-hour time as input and outputs the equivalent 24-hour time, handling invalid inputs. The document provides sample outputs and grading criteria.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

C:\Users\cmmisip\Downloads\PE1_SetA_1Q1819.

docx
V

Practical Exam
2 Date
# JULY 30, 2023
Name MINA, DIANNE JOY L. Score

Filename: Content: PE_1Surname.m and PE_2Surname.m

1.) The Gregorian calendar has the following number of days in a given month.

Month Number of Days

January, March, May, July, August, October, and December 31


February 28 or 29
April, June, September, and November 30
Create a MATLAB program (using switch) that will input month as an integer number (1-
12) and output the corresponding day for the month entered. Display an error message if
the month entered is invalid.

Sample Output:
1.) Input month (1-12) only: 9
9 is equivalent to September. It has 30 days.
2.) Input month (1-12) only: 2
2 is equivalent to February. It has 28 or 29 days.
3.) Input month (1-12) only:1 2
12 is equivalent to December. It has 31 days.

2.) Create a MATLAB program (using if-elseif-else) that will input time based on a 12-hour
clock and output its corresponding value based on a 24-hour clock. Display an error
message if the time entered is invalid.

Time based on a 12-hour clock Time based on a 24-hour clock

1:00 – 11:59 AM 1:00 -11:59


12:00 – 12:59 AM 0:00 – 0:59
12:00 – 12:59 PM 12:00 – 12:59
1:00 – 11:59 PM 13:00 – 23:59
C:\Users\cmmisip\Downloads\PE1_SetA_1Q1819.docx
V

Sample Output:
1.) Input time based on a 12-hour clock: 658
Input A or a for [AM] and P or p for [PM]: A
You entered 6:58 AM
The equivalent time based on a 24-hour clock is 6:58
2.) Input time based on a 12-hour clock: 1201
Input A or a for [AM] and P or p for [PM]: A
You entered 12:01 AM
The equivalent time based on a 24-hour clock is 0:01
3.) Input time based on a 12-hour clock: 1251
Input A or a for [AM] and P or p for [PM]: p
You entered 12:51 PM
The equivalent time based on a 24-hour clock is 12:51
4.) Input time based on a 12-hour clock: 809
Input A or a for [AM] and P or p for [PM]: p
You entered 8:09 PM
The equivalent time based on a 24-hour clock is 20:09
5.) Input time based on a 12-hour clock: 1601
Input A or a for [AM] and P or p for [PM]: A
You entered an INVALID time!
6.) Input time based on a 12-hour clock: 1089
Input A or a for [AM] and P or p for [PM]: p
You entered an INVALID time!
7.) Input time based on a 12-hour clock: 1145
Input A or a for [AM] and P or p for [PM]: S
You entered an INVALID time!

Criteria Score

1.1) Comment (Name, Course Code and Section, Date and Program Description) 10
1.2) Correct Program Logic 20
1.3) Correct Output 20
2.1) Comment (Name, Course Code and Section, Date and Program Description) 10
2.2) Correct Program Logic 20
2.3) Correct Output 20
Total 100

_______________________ _______________
Engr. Cheryl Mari M. Isip Date
C:\Users\cmmisip\Downloads\PE1_SetA_1Q1819.docx
V

In the editor window, take a screenshot and paste your output:


C:\Users\cmmisip\Downloads\PE1_SetA_1Q1819.docx
V

In the command window, take a screenshot and paste your output:


C:\Users\cmmisip\Downloads\PE1_SetA_1Q1819.docx
V

In the editor window, take a screenshot and paste your output:


C:\Users\cmmisip\Downloads\PE1_SetA_1Q1819.docx
V

In the command window, take a screenshot and paste your output:

You might also like