Computer users and applications need the time and date for various reasons. This can be achieved by keeping track of the
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Computer users and applications need the time and date for various reasons. This can be achieved by keeping track of the
Computer users and applications need the time and date for various reasons. This can be achieved by keeping track of the number of seconds that have elapsed since some reference date and time. The number of seconds elapsed can then be converted to determine the current date and time. (The built-in matlab functions that do something like this include date and clock) For this assignment, you will write a program to determine the time and date corresponding to an elapsed number of seconds since 00:00:00 on 1 January 2021. Have the user input the value of elapsed seconds. The output (to the screen should be the corresponding hour (in military time), minute, second day of the month, month name, year, and day of the week name (Sunday - Saturday). Your output should be formatted like the following 23:59:32 2 January 2022 Sunday Don't forget that a leap year has 366 days with 29 days in February Leap years are years that are evenly divisible by 4, with the exception of those evenly divisible by 100, but those divisibly by 400 are leap years. Your program should be accomplished using the assignment operator (a) mathematical operators (+-1,**), basic logical operators and functions (&)-xor), basic relational operators and functions (--<-, strcmp), decision making and repetition constructs (if-elseif-else, switch-case- otherwise, for, while)and input/output functions we've learned (e.&. input, display, sprintt, fprintf). To determine whether a number is evenly divisible, you are also allowed to use the built-in matlab remainder (rem, mod) and rounding (floor, fox, round) functions. No other built-in matlab functions are allowed. You should use modutar programming to solve this problem. Your main parent script should contain only a handful of commands, each of which should be a call to a child function you have written It is a very good idea to code this in stages. First calculate the year, output the result, and make sure it works. Then move to the month and make sure that works, then the numerical date, then the hour, etc. Work on the day of the week name only after all the previous parts of the program work Go through the problem solving steps discussed in class. Also be sure to document your code well and use good programming practices. For full credit, you must provide several appropriate test cases of different types. When your program executes correctly and cleanly and has been verified with appropriate testing, you are ready to submit your assignment for grading.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!