From 6950c5dbc7876c45a7a381a0f3ca61394452511c Mon Sep 17 00:00:00 2001 From: slugle4649 Date: Wed, 14 Feb 2024 20:29:28 -0500 Subject: [PATCH] Added all files --- .gitignore | 0 README.md | 13 +++++++- gitignore | 0 program1.py | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ program2.js | 59 ++++++++++++++++++++++++++++++++++++ program3.css | 34 +++++++++++++++++++++ program3.html | 27 +++++++++++++++++ 7 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 gitignore create mode 100644 program1.py create mode 100644 program2.js create mode 100644 program3.css create mode 100644 program3.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index 4fed924..6e78d20 100644 --- a/README.md +++ b/README.md @@ -1 +1,12 @@ -# Git Lab 1 +# HUGH GLENN +**RESOURCES** + +-Saksham + +-StackOverflow + +-W3 Schools + +-Elyz Katz + +-GeeksforGeeks \ No newline at end of file diff --git a/gitignore b/gitignore new file mode 100644 index 0000000..e69de29 diff --git a/program1.py b/program1.py new file mode 100644 index 0000000..2c2b042 --- /dev/null +++ b/program1.py @@ -0,0 +1,82 @@ +import sys +import decimal + +#Reads string off command line +DollarAmount = sys.argv[1] + + +#Error Check +if len(sys.argv) > 2: + print("Only one argument (money) should be allowed") + sys.exit(-1) + +#Checks if the argument is a valid string +if DollarAmount[0] != '$': + print('The string must being with a $') + sys.exit(-1) +elif DollarAmount[1] == '.': + print('The string must include a dollar amount') + sys.exit(-1) + +#Converts string into money in terms of cents and creates dictionary of coins/dollar +#Also checks to see if string can be convrted +try: + float(DollarAmount[1:]) +except: + print('Only input numbers after the dollar symbol') + sys.exit(-1) +DollarAmount = float(DollarAmount[1:]) * 100 +Coins = {} + +#Error check to see if number is valid +if (DollarAmount < 0 or DollarAmount > 100 * 100): + print('The dollar amount must be a number 0 - 100') + sys.exit(-1) +if (DollarAmount % 1 != 0): + print('Only valid dollar amounts') + sys.exit(-1) + + + +#Sorts through all the money values and sees how many are inside +if DollarAmount // 100 == 1: + Coins['Dollar'] = 1 + DollarAmount -= DollarAmount // 100 * 100 +elif DollarAmount // 100 > 1: + Coins['Dollars'] = DollarAmount // 100 + DollarAmount -= DollarAmount // 100 * 100 +DollarAmount = round(DollarAmount) + +if DollarAmount // 25 == 1: + Coins['Quarter'] = 1 + DollarAmount -= DollarAmount // 25 * 25 +elif DollarAmount // 25 > 1: + Coins['Quarters'] = DollarAmount // 25 + DollarAmount -= DollarAmount // 25 * 25 +DollarAmount = round(DollarAmount) + +if DollarAmount // 10 == 1: + Coins['Dime'] = 1 + DollarAmount -= DollarAmount // 10 * 10 +elif DollarAmount // 10 > 1: + Coins['Dimes'] = DollarAmount // 10 + DollarAmount -= DollarAmount // 10 * 10 +DollarAmount = round(DollarAmount) + +if DollarAmount // 5 == 1: + Coins['Nickel'] = 1 + DollarAmount -= DollarAmount // 5 * 5 +elif DollarAmount // 5 > 1: + Coins['Nickels'] = DollarAmount // 5 + DollarAmount -= DollarAmount // 5 * 5 +DollarAmount = round(DollarAmount) + +if DollarAmount // 1 == 1: + Coins['Penny'] = 1 + DollarAmount -= DollarAmount // 1 +elif DollarAmount // 1 > 1: + Coins['Pennies'] = DollarAmount // 1 + DollarAmount -= DollarAmount // 1 + +for key in Coins: + print(int(Coins[key]), key) \ No newline at end of file diff --git a/program2.js b/program2.js new file mode 100644 index 0000000..3d6ccf0 --- /dev/null +++ b/program2.js @@ -0,0 +1,59 @@ +//Creates json of lower case letters indicating capitalized string, and array of letters that are printed out +let letters = {} +let rtn = [] + +//Error case +if (process.argv.length == 2){ + console.log('ERROR: You must provide at least one string') + return +} + +/** + * @params String with spaces in it + * + * + * Sorts duplicates into the array and words into the json, + * but accounts for the string being multiple words with spaces inbetween + * + */ +function SpacedString(Sentence){ + let input = '' + for (let i = 0; i < Sentence.length; i++){ + if (Sentence[i] == ' '){ + if (Object.hasOwn(letters, input.toLowerCase())){ + rtn.push(letters[input.toLocaleLowerCase()]) + }else{ + letters[input.toLowerCase()] = input + } + input = '' + }else{ + input += Sentence[i] + } + } + if (Object.hasOwn(letters, input.toLowerCase())){ + rtn.push(letters[input.toLocaleLowerCase()]) + }else{ + letters[input.toLowerCase()] = input + } +} + +//Adds all duplicates to array +for (let i = 2; i < process.argv.length; ++i) { + LowercaseString = process.argv[i].toLowerCase() + Word = process.argv[i] + if (Word.includes(' ')){ + SpacedString(Word) + } + else if (Object.hasOwn(letters, LowercaseString)){ + if (rtn.includes(letters[LowercaseString]) == false) + rtn.push(letters[LowercaseString]) + } + else{ + letters[LowercaseString] = Word + } +} + +//Prints out all duplicate strings +for (let i = 0; i < rtn.length; i++){ + console.log(rtn[i]) +} \ No newline at end of file diff --git a/program3.css b/program3.css new file mode 100644 index 0000000..788374b --- /dev/null +++ b/program3.css @@ -0,0 +1,34 @@ +/*The rectangle that holds all the choices*/ +#maincontainer{ + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + border: solid black 1px; + width: 80vw; + height: 70%; + text-align: center; + display: flex; + flex-direction: column; + justify-content: space-around; +} + +/*Main background*/ +body{ + background-color: gray; +} + +/*The background of the form*/ +div{ + background-color: blue; +} + +/*The text inside the form*/ +label{ + color: #FFFFFF; + padding: 1%; +} + +input{ + padding: 1%; +} \ No newline at end of file diff --git a/program3.html b/program3.html new file mode 100644 index 0000000..6cbfdcb --- /dev/null +++ b/program3.html @@ -0,0 +1,27 @@ + + + + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + \ No newline at end of file