Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Installation Instructions:
1 change: 1 addition & 0 deletions README 2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Git Lab 1
Empty file added gitignore
Empty file.
30 changes: 30 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<head>
<title>Problem 3: User Form</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<form class="user-form">
<label for="username">Username:</label>
<input id="username" ><br><br>

<label for="password">Password:</label>
<input id="password" ><br><br>

<label for="fav-color">Favorite Color:</label>
<input type="color" id="fav-color" onchange="changeColor()"><br><br>

<input id="submit" value="Submit">
</form>
</div>

<script>
function changeColor() {
var colorPicker = document.getElementById("fav-color");
var selectedColor = colorPicker.value;
colorPicker.style.backgroundColor = selectedColor;
}
</script>
</body>
</html>
74 changes: 74 additions & 0 deletions program1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

/**
* Checks the input string that represents some amount of money
* must be in the format '$X.YZ' where X is the dollar amount and YZ represents cents.
* @param {string} input - The input string representing the monetary amount.
*/

function processInput(input) {
// make sure the input is in the right format
let regex = /^\$([1-9]\d*|0)(\.\d{2})?$/;
if (!regex.test(input)) {
console.log("Eror: The string must be in the format $X.YZ");
return;
}

//seperate the dollars and cents from the input
let splitinput = input.slice(1).split('.');
let amtdollars = splitinput[0];
let cents;
if (splitinput.length > 1) {
cents = splitinput[1];
} else {
cents = '00';
}

//cast both amounts to int and get the total amount of cents
let total = parseInt(amtdollars) * 100 + parseInt(cents);

/**
* sorts the total cents into seperate denominations.
* @param {number} totalCents - total amount in cents.
* @returns {Object} an object containing the counts of dollars, quarters, dimes, nickels, and pennies.
*/

function sort(totalcents) {
let dollars = Math.floor(totalcents / 100);
totalcents = totalcents % 100;
let quarters = Math.floor(totalcents / 25);
totalcents = totalcents % 25;
let dimes = Math.floor(totalcents / 10);
totalcents = totalcents % 10;
let nickels = Math.floor(totalcents / 5);
let pennies = totalcents % 5;

return {
dollars: dollars,
quarters: quarters,
dimes: dimes,
nickels: nickels,
pennies: pennies
};
}

//log all the denominations
let denominations = sort(total);
if (denominations.dollars > 0) console.log(`${denominations.dollars} dollars`);
if (denominations.quarters > 0) console.log(`${denominations.quarters} quarters`);
if (denominations.dimes > 0) console.log(`${denominations.dimes} dimes`);
if (denominations.nickels > 0) console.log(`${denominations.nickels} nickels`);
if (denominations.pennies > 0) console.log(`${denominations.pennies} pennies`);

}

// Main
if (process.argv.length !== 3) {
console.log("ERROR: Incorrect number of arguments. Usage: node program.js \"$X.YZ\"");
} else {
var input = process.argv[2];
if (!input.startsWith('$')) {
console.log("ERROR: The string must begin with a $");
} else {
processInput(input);
}
}
51 changes: 51 additions & 0 deletions program2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import sys

def duplicates(strings):

"""
finds and prints duplicate words in a list of strings.

Arguments:
strings (list): a list of strings provided by the user to check for duplicates

Returns:
none
"""

#check if strings is empty
if not strings:
print("ERROR: You must provide at least one string")
return

#word counts is where the program stores the count of words
word_counts = {}
for string in strings:
#split into substrings
words = string.split()

for word in words:
#convert word to lowercase
word_lower = word.lower()
if word_lower not in word_counts:
#if word is not yet in word count, it will add it
word_counts[word_lower] = []
#if word is already found, the program appends the extra word to that list
word_counts[word_lower].append(word)


#set makes sure that we dont accidentally add duplicates twice to the list
duplicates = set()

#if the length of a world list is more than 1 that means there was a duplicate word, so when it is greater than 1, it is added to the duplicates set
for word_list in word_counts.values():
if len(word_list) > 1:
duplicates.update(word_list)


for word in duplicates:
print(word)


#get input from terminal
args = sys.argv[1:]
duplicates(args)
50 changes: 50 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: rgb(57, 146, 235);
color: #ffffff;
}

.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

.user-form {
width: 80%;
height: 70%;
background-color: rgb(161, 161, 161);
padding: 20px;
border-radius: 10px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
}

label {
font-size: 18px;
font-weight: bold;
}

#username,
#password,
#fav-color,
#submit {
width: calc(100% - 20px);
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 5px;
font-size: 16px;
}

#submit {
background-color: rgb(40, 78, 154);
color: #ffffff;
cursor: pointer;
}

#submit:hover {
background-color: rgb(139, 199, 212);
}