diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..1d7ed1c Binary files /dev/null and b/.DS_Store differ diff --git a/Arduino/.DS_Store b/Arduino/.DS_Store new file mode 100644 index 0000000..c0eb386 Binary files /dev/null and b/Arduino/.DS_Store differ diff --git a/c/guessing_game/a.out b/c/guessing_game/a.out new file mode 100755 index 0000000..58f1a4e Binary files /dev/null and b/c/guessing_game/a.out differ diff --git a/c/guessing_game/guessing_game.c b/c/guessing_game/guessing_game.c new file mode 100644 index 0000000..e6cbf04 --- /dev/null +++ b/c/guessing_game/guessing_game.c @@ -0,0 +1,85 @@ +#include +#include + +int main(void) { + int lives = 7; + int questions = 20; + int number_range = 10; + int operator_range = 10; + int num_right = 0; + int counter = 1; + char operators[] = {'+', '-', '*', '/', '%', '=', '<', '>', '<=', '>=', '!='}; + char question_visual[questions]; + char lives_visual[lives]; + + for (int i = 0; i < questions; i++) { + question_visual[i] = '-'; + } + + for (int i = 0; i < lives; i++) { + lives_visual[i] = '+'; + } + + while (num_right <=20) { + int num1 = rand() % number_range; + int num2 = rand() % number_range; + int operator = rand() % operator_range; + int answer; + int correct_answer; + switch (operator) { + case 0: + correct_answer = num1 + num2; + break; + case 1: + correct_answer = num1 - num2; + break; + case 2: + correct_answer = num1 * num2; + break; + case 3: + correct_answer = num1 / num2; + break; + case 4: + correct_answer = num1 % num2; + break; + case 5: + correct_answer = num1 == num2; + break; + case 6: + correct_answer = num1 < num2; + break; + case 7: + correct_answer = num1 > num2; + break; + case 8: + correct_answer = num1 <= num2; + break; + case 9: + correct_answer = num1 >= num2; + break; + case 10: + correct_answer = num1 != num2; + break; + } + printf("You have %d lives left\n", lives); + printf("Question %d: What is %d %c %d?\n", counter ,num1, operators[operator], num2); + scanf("%d", &answer); + if (answer == correct_answer) { + printf("Correct!\n"); + num_right++; + question_visual[num_right] = '+'; + } else { + printf("Incorrect!\nAnswer: %d", correct_answer); + lives--; + lives_visual[lives] = ' '; + } + if (lives == 0) { + printf("Game Over!\n"); + break; + } + counter++; + } + + printf("Questions: %s\nLives: %s\n", question_visual, lives_visual); + +} diff --git a/csci218/.DS_Store b/csci218/.DS_Store new file mode 100644 index 0000000..b8131e2 Binary files /dev/null and b/csci218/.DS_Store differ diff --git a/csci218/Labs/Lab2/Lab2_Part1.c b/csci218/Labs/Lab2/Lab2_Part1.c new file mode 100644 index 0000000..0486094 --- /dev/null +++ b/csci218/Labs/Lab2/Lab2_Part1.c @@ -0,0 +1,23 @@ +/* Name: Garrett Haldrup + +Problem: Takes in name and age then outputs name with age in 5 years. +Certification of Authenticity: +I certify that this assignment is entirely my own work. +*/ +#include + +int main(void) { + char name[100]; + int age; + + printf("Enter your name: "); + scanf("%s", name); + printf("Enter your age: "); + scanf("%d", &age); + + printf("Hi %s! In five years, you will be %d\n", name, age + 5); + + return 0; +} + + diff --git a/csci218/Labs/Lab2/circleArea.c b/csci218/Labs/Lab2/circleArea.c new file mode 100644 index 0000000..11beb48 --- /dev/null +++ b/csci218/Labs/Lab2/circleArea.c @@ -0,0 +1,21 @@ +//circleArea.c +//Garrett Haldrup +//Sept 2 2024 +//This program will caclulate the area of a circle given a radius given by user +#include +int main(){ + // display the purpose of the program + printf("This program will calculate the area of a cricle\n"); + // define the variable: radius and area, both with datatype float + float radius, area; + const float PI = 3.14159; + // input: receive radius from the user (keyboard) + printf("Please enter the radius of the circle: "); + scanf("%f", &radius); + //printf("The radius of the circle is: %f\n", radius); + // process: Calculate area by using the formula of a circle + area = PI * radius * radius; + // output: display the `area` on the screen + printf("The area of the circle with radius %.2f is: %.2f\n", radius, area); + return 0; +} diff --git a/csci218/Labs/Lab2/circleArea.out b/csci218/Labs/Lab2/circleArea.out new file mode 100755 index 0000000..9e86341 Binary files /dev/null and b/csci218/Labs/Lab2/circleArea.out differ diff --git a/csci218/Labs/Lab2/countPennies.c b/csci218/Labs/Lab2/countPennies.c new file mode 100644 index 0000000..95b9b8b --- /dev/null +++ b/csci218/Labs/Lab2/countPennies.c @@ -0,0 +1,32 @@ + +/* Name: Garrett Haldrup + +Problem: Takes number of dollars, quarters, dimes, nickels, pennies. +Outputs total number of pennies: +I certify that this assignment is entirely my own work. +*/ +#include + +int main(void) { + //declare + printf("This program will calculate the number of pennies.\n"); + int dollars, quarters, dimes, nickels, pennies, totalPennies; + + //Input + printf("Enter number of dollars: "); + scanf("%d", &dollars); + printf("Enter number of quarters: "); + scanf("%d", &quarters); + printf("Enter number of dimes: "); + scanf("%d", &dimes); + printf("Enter number of nickels: "); + scanf("%d", &nickels); + printf("Enter number of pennies: "); + scanf("%d", &pennies); + + //calculate + totalPennies = (dollars * 100) + (quarters * 25) + (dimes * 10) + (nickels * 5) + pennies; + + //Display + printf("Total Pennies: %d\n", totalPennies); +} diff --git a/csci218/Labs/Lab2/countPennies.out b/csci218/Labs/Lab2/countPennies.out new file mode 100755 index 0000000..4dd87f6 Binary files /dev/null and b/csci218/Labs/Lab2/countPennies.out differ diff --git a/csci218/Labs/Lab2/myBlink/Blink.txt b/csci218/Labs/Lab2/myBlink/Blink.txt new file mode 100755 index 0000000..0626334 --- /dev/null +++ b/csci218/Labs/Lab2/myBlink/Blink.txt @@ -0,0 +1 @@ +Turn an LED on and off. \ No newline at end of file diff --git a/csci218/Labs/Lab2/myBlink/myBlink.ino b/csci218/Labs/Lab2/myBlink/myBlink.ino new file mode 100755 index 0000000..4df5a9c --- /dev/null +++ b/csci218/Labs/Lab2/myBlink/myBlink.ino @@ -0,0 +1,23 @@ +/* + myBlink.ino + + Garrett Haldrup + + Sept 2 2024 + + Turns the builtin LED on and off at a rate of 5hz +*/ + +// the setup function runs once when you press reset or power the board +void setup() { + // initialize digital pin LED_BUILTIN as an output. + pinMode(LED_BUILTIN, OUTPUT); +} + +// the loop function runs over and over again forever +void loop() { + digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) + delay(15); // wait for a second + digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW + delay(15); // wait for a second +} diff --git a/csci218/Labs/Lab2/nameAge.c b/csci218/Labs/Lab2/nameAge.c new file mode 100644 index 0000000..6d2836b --- /dev/null +++ b/csci218/Labs/Lab2/nameAge.c @@ -0,0 +1,30 @@ +/* Name: Garrett Haldrup + +Problem: Takes in name and age then outputs name with age in 5 years. +Certification of Authenticity: +I certify that this assignment is entirely my own work. +*/ +#include + +int main(void) { + printf("This program will take your name and age and see your age in 5 years\n"); + //declare + char name[100]; + int age; + + //input + printf("Enter your name: "); + scanf("%s", name); + printf("Enter your age: "); + scanf("%d", &age); + + //Calculate + age += 5; + + //output and calculate + printf("Hi %s! In five years, you will be %d\n", name, age); + + return 0; +} + + diff --git a/csci218/Labs/Lab2/nameAge.out b/csci218/Labs/Lab2/nameAge.out new file mode 100755 index 0000000..3141876 Binary files /dev/null and b/csci218/Labs/Lab2/nameAge.out differ diff --git a/csci218/Labs/Lab2/part1.o b/csci218/Labs/Lab2/part1.o new file mode 100755 index 0000000..495f237 Binary files /dev/null and b/csci218/Labs/Lab2/part1.o differ diff --git a/csci218/Labs/Lab2/part1.out b/csci218/Labs/Lab2/part1.out new file mode 100755 index 0000000..7e5fe4a Binary files /dev/null and b/csci218/Labs/Lab2/part1.out differ