Homework #0
Go to file
2025-02-17 22:18:41 +09:00
.devcontainer init 2025-02-17 22:06:53 +09:00
assets init 2025-02-17 22:06:53 +09:00
.gitignore init 2025-02-17 22:06:53 +09:00
index.html init 2025-02-17 22:06:53 +09:00
main.js init 2025-02-17 22:06:53 +09:00
README.md Homework link 2025-02-17 22:18:41 +09:00
style.css init 2025-02-17 22:06:53 +09:00
SubmissionNotes.md init 2025-02-17 22:06:53 +09:00

Homework 0 - Welcome to Software Prototyping!

  • Use this homework to test yourself before taking the course (no points will be awarded for this homework).
  • Live demo

General Description

In this assignment, you need to implement a function that computes the time difference between two integer numbers input by the user, representing time expressed in the military format HHMMSS. HH stands for hours (00 to 23), MM for minutes (00-59), and SS for seconds (00-59). The function validates the input (i.e., it checks whether hours, minutes, and seconds are correct), computes the difference between the two numbers, and returns a string formatted as "HH:MM:SS" with the resulting time difference to be displayed in the graphical interface.

Here is the function signature that you have to complete:

function computeDifference(start, end) {
  // TODO: fill up the content on this function
  return 'HH:MM:SS'; // PLACEHOLDER
}
  • The function parameters start and end are the two input times. So, for example, 123456 would mean hours are 12, minutes are 34, and seconds are 56.
  • The maximum difference between the two times is 23:59:59.
  • end can be smaller than start: in such case, it means that you need to compute the time difference from the previous day at the time start to the next day at the time end.
  • If the user input is invalid (for example, minutes greater than 59), you should return undefined.
  • The time difference to return as a string should be formatted with the : between hours and minutes and minutes and seconds. For example, 10:01:20 means that there is a difference of 10 hours, 1 minute, and 20 seconds.
  • Feel free to modify the code as you please (e.g., creating new functions, global variables, or anything you want to).

How to get started

  • Clone or download this repository on your computer.
  • Open the repository folder with VSCode
  • Start coding in main.js, which is the only file you need to modify
  • To see the result, use the LiveServer extension

About grading

The maximum score for this assignment is 100 points. If the program does not compile (e.g., not a valid javascript file), the score is 0. If it runs, the score is inversely proportional to the number of errors. If the code has runtime errors, there is a 20 points penalty, plus a penalty for any additional part that cannot be checked.

You will receive a score for this assignment, however this DOES NOT COUNT toward your final score. It is a score only for yourself to help you decide whether to take this class or not.

How to submit

  1. After completing your code, make sure to fill up the SubmissionNotes with your basic info and indicate whether you received any help. Feel free to add any relevant information.
  2. Zip the folder of this repository containing your solution.
  3. Submit the homework using the class submission system.
  4. For any problem, feel free to contact the professor or TA via Discord. No emails, please.

Notes about submission

  • Only submissions made with the system will be considered (e.g., no direct emails to TA or Prof).
  • You can re-submit as many times as you want: the last submission only will be considered.
  • Submissions after the deadline (even a few minutes) will receive a penalty of 20%. After 24 hours from the deadline, you will receive 0 points.
  • Keep a screenshot that proves your completed submission.