diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 0000000..aa6fbf9 Binary files /dev/null and b/INSTALL.md differ diff --git a/README.md b/README.md index 4fed924..0dc8d16 100644 Binary files a/README.md and b/README.md differ diff --git a/gitignore b/gitignore new file mode 100644 index 0000000..e69de29 diff --git a/index.html b/index.html new file mode 100644 index 0000000..1dd9239 --- /dev/null +++ b/index.html @@ -0,0 +1,17 @@ + + + + Program 3 + + + + +
+ +
+ +
+ +
+ + \ No newline at end of file diff --git a/program1.py b/program1.py new file mode 100644 index 0000000..41399a9 --- /dev/null +++ b/program1.py @@ -0,0 +1,40 @@ +import sys + +money = sys.argv[1] + +# Replaces the first instance only of "$" and ".". Nothing happens if they don't exist. +money1 = (money.replace("$", "", 1).replace(".", "", 1)) + +if money1.isdigit(): + sum = int(money1) # Makes money1 an integer if money1 is a number. + if sum < 0 or sum > 10000: + print("Error, value must be between 0 and 100 dollars.") + else: + # Dictionary to store the value of each currency. + coins = { + "Dollar": sum // 100, + "Quarter": (sum % 100) // 25, + "Dime": (sum % 25) // 10, + "Nickel": (sum % 10) // 5, + "Penny": (sum % 5) + } + # Another format check, but for the initial variable. + if money[0] != "$" or ("." not in money): + print("Error please provide in the correct format '$x.yz' for x, y, z in positive integers.") + else: + # For key, value in coins + for i, j in coins.items(): + if j > 0: # Only if the value is greater than 0 it gets printed. E.g. 0 dollars won't get printed. + # To correctly grammatically format (dollar vs dollars): + if j == 1: + print(f"{j} {i}") + else: # j > 1 formatting for duplicate currencies. + if i == "Penny": + print(f"{j} Pennies") # Need to print j pennies, not j penny if multiple exist. + else: + print(f"{j} {i}s") # Adding s at the end works for every other currency. + + +else: + # If amount is not in valid format: + print("Error please provide in the correct format '$x.yz' for x, y, z in positive integers.") \ No newline at end of file diff --git a/program2.js b/program2.js new file mode 100644 index 0000000..2fbb05c --- /dev/null +++ b/program2.js @@ -0,0 +1,27 @@ +strings = process.argv.slice(2); + +// Check if there are no strings provided or if the array is empty +if (!strings || !strings.length) { + console.log("ERROR: You must provide at least one string"); +} +let wordCounts = new Map(); +let sentence = strings.join(" ").split(" "); + +for (let word of sentence) { + // Convert the word to lowercase for case-insensitive comparison + if (wordCounts.has(word.toLowerCase())) { + // If the word already exists in the wordCounts object, increment its count by 1 + wordCounts.get(word.toLowerCase())[1] += 1; + } else { + // If the word doesn't exist in the wordCounts object, add it with a count of 1 + wordCounts.set(word.toLowerCase(), [word, 1]); + } +} + +for (let word of wordCounts.keys()) { + // Check if the count of the word is greater than or equal to 2 + if (wordCounts.get(word)[1] >= 2) { + // If the count is greater than or equal to 2, print the word + console.log(wordCounts.get(word)[0]); + } +} diff --git a/style.css b/style.css new file mode 100644 index 0000000..eaef37d --- /dev/null +++ b/style.css @@ -0,0 +1,24 @@ +body{ + display: flex; + flex-direction: column; + align-items: center; + height: 95vh; + justify-content: center; + font-family: Verdana; + font-size: 24pt; + background-color: #346094; + color: #000000; +} + +/* vw and vh are % of viewport width/height. The last 3 lines center. */ +form{ + outline: auto; + outline-color: #000000; + background-color: #8a8a8d; + width: 80vw; + height: 70vh; + display:flex; + flex-direction: column; + align-items: center; + justify-content: center; +}