From 8644699f4d2fce12a41289f9627bc45be9dd1965 Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Thu, 3 Dec 2020 09:32:13 +0700 Subject: [usth/ICT3.2] Develop web applications --- usth/ICT3.2/prac/2/1.js | 9 +++++++ usth/ICT3.2/prac/2/10.html | 49 ++++++++++++++++++++++++++++++++++++ usth/ICT3.2/prac/2/11.html | 55 +++++++++++++++++++++++++++++++++++++++++ usth/ICT3.2/prac/2/2.js | 5 ++++ usth/ICT3.2/prac/2/3.js | 5 ++++ usth/ICT3.2/prac/2/4.js | 2 ++ usth/ICT3.2/prac/2/5.js | 2 ++ usth/ICT3.2/prac/2/6.js | 11 +++++++++ usth/ICT3.2/prac/2/7.js | 1 + usth/ICT3.2/prac/2/8.js | 11 +++++++++ usth/ICT3.2/prac/2/9.js | 9 +++++++ usth/ICT3.2/prac/2/labwork.pdf | Bin 0 -> 1400060 bytes 12 files changed, 159 insertions(+) create mode 100644 usth/ICT3.2/prac/2/1.js create mode 100644 usth/ICT3.2/prac/2/10.html create mode 100644 usth/ICT3.2/prac/2/11.html create mode 100644 usth/ICT3.2/prac/2/2.js create mode 100644 usth/ICT3.2/prac/2/3.js create mode 100644 usth/ICT3.2/prac/2/4.js create mode 100644 usth/ICT3.2/prac/2/5.js create mode 100644 usth/ICT3.2/prac/2/6.js create mode 100644 usth/ICT3.2/prac/2/7.js create mode 100644 usth/ICT3.2/prac/2/8.js create mode 100644 usth/ICT3.2/prac/2/9.js create mode 100644 usth/ICT3.2/prac/2/labwork.pdf (limited to 'usth/ICT3.2/prac/2') diff --git a/usth/ICT3.2/prac/2/1.js b/usth/ICT3.2/prac/2/1.js new file mode 100644 index 0000000..ecc78f2 --- /dev/null +++ b/usth/ICT3.2/prac/2/1.js @@ -0,0 +1,9 @@ +const DAYS = ['Monday', 'Tuesday', 'Wednesday', + 'Thursday', 'Friday', 'Saturday', 'Sunday']; +const NOW = new Date(); +const HOUR24 = NOW.getHours(); +const HOUR12 = HOUR24 % 12; +const PERIOD = HOUR24 < 12 ? 'AM' : 'PM'; + +console.log(`Today is: ${DAYS[NOW.getDay()-1]}`); +console.log(`Current time is: ${HOUR12} ${PERIOD}: ${NOW.getMinutes()}: ${NOW.getSeconds()}`) diff --git a/usth/ICT3.2/prac/2/10.html b/usth/ICT3.2/prac/2/10.html new file mode 100644 index 0000000..d092b48 --- /dev/null +++ b/usth/ICT3.2/prac/2/10.html @@ -0,0 +1,49 @@ + + + + + + + +

Sign Up

+
+

+ + +

+

+ + +

+

+ + +

+

+ + + + + +

+
+ + diff --git a/usth/ICT3.2/prac/2/11.html b/usth/ICT3.2/prac/2/11.html new file mode 100644 index 0000000..51c0922 --- /dev/null +++ b/usth/ICT3.2/prac/2/11.html @@ -0,0 +1,55 @@ + + + + + + + +
+

+ + +

+

+ + +

+

+ + + + + +

+ The Result is:  + +

+
+ + diff --git a/usth/ICT3.2/prac/2/2.js b/usth/ICT3.2/prac/2/2.js new file mode 100644 index 0000000..97b49ba --- /dev/null +++ b/usth/ICT3.2/prac/2/2.js @@ -0,0 +1,5 @@ +const C = 'Temperature in Celsius: '; +const F = 'Temperature in Fahrenheit: '; + +alert(F + (prompt(C) * 1.8 + 32)); +alert(C + ((prompt(F) - 32) / 1.8)); diff --git a/usth/ICT3.2/prac/2/3.js b/usth/ICT3.2/prac/2/3.js new file mode 100644 index 0000000..45bd66e --- /dev/null +++ b/usth/ICT3.2/prac/2/3.js @@ -0,0 +1,5 @@ +const WEIGHT = Math.trunc(Math.random() * 10); +const GUESS = Math.trunc(Number( + prompt('Guess the weight of the marrow (1-10)'))); + +alert(GUESS == WEIGHT ? 'Good Work' : 'Not Matched'); diff --git a/usth/ICT3.2/prac/2/4.js b/usth/ICT3.2/prac/2/4.js new file mode 100644 index 0000000..25c2a17 --- /dev/null +++ b/usth/ICT3.2/prac/2/4.js @@ -0,0 +1,2 @@ +const S = prompt('Enter five space-separated numbers'); +alert(`The largest is ${Math.max(...S.split(' ').map(Number))}.`); diff --git a/usth/ICT3.2/prac/2/5.js b/usth/ICT3.2/prac/2/5.js new file mode 100644 index 0000000..ee502b7 --- /dev/null +++ b/usth/ICT3.2/prac/2/5.js @@ -0,0 +1,2 @@ +for (let i = 1; i < 16; ++i) + console.log(i % 2 ? `${i} is odd` : `${i} is even`); diff --git a/usth/ICT3.2/prac/2/6.js b/usth/ICT3.2/prac/2/6.js new file mode 100644 index 0000000..52cb82a --- /dev/null +++ b/usth/ICT3.2/prac/2/6.js @@ -0,0 +1,11 @@ +const A039943 = [0, 1, 4, 16, 20, 37, 42, 58, 89, 145]; // OEIS + +for (i = j = 1; i < 11; ++j) { + for (k = j; + !A039943.includes(k); + k = k.toString().split('').map(n => n*n).reduce((m, n) => m+n)); + if (k == 1) { + console.log(j); + i++; + } +} diff --git a/usth/ICT3.2/prac/2/7.js b/usth/ICT3.2/prac/2/7.js new file mode 100644 index 0000000..e268937 --- /dev/null +++ b/usth/ICT3.2/prac/2/7.js @@ -0,0 +1 @@ +alert(`Output: ${prompt('Input:').split('').reverse().join('')}`); diff --git a/usth/ICT3.2/prac/2/8.js b/usth/ICT3.2/prac/2/8.js new file mode 100644 index 0000000..07a4042 --- /dev/null +++ b/usth/ICT3.2/prac/2/8.js @@ -0,0 +1,11 @@ +function isPrime(n) { + if (n < 2 || n != Math.trunc(n)) + return false; + for (let i = 2; i * i <= n; ++i) + if (n % i == 0) + return false; + return true; +} + +if (!module.parent) + console.log(isPrime(Number(process.argv[2])) ? 'prime' : 'no prime'); diff --git a/usth/ICT3.2/prac/2/9.js b/usth/ICT3.2/prac/2/9.js new file mode 100644 index 0000000..628b9b4 --- /dev/null +++ b/usth/ICT3.2/prac/2/9.js @@ -0,0 +1,9 @@ +function second(a) { + let b = [...a].sort(); + return [b[1], b[b.length-2]]; +} + +if (!module.parent) { + let [min, max] = second(process.argv.slice(2)); + console.log(`${min} and ${max}`); +} diff --git a/usth/ICT3.2/prac/2/labwork.pdf b/usth/ICT3.2/prac/2/labwork.pdf new file mode 100644 index 0000000..f8d8ece Binary files /dev/null and b/usth/ICT3.2/prac/2/labwork.pdf differ -- cgit 1.4.1