diff --git a/.DS_Store b/.DS_Store index 762e875..efe23c0 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/JPNS 101/Assignments/ホールドラップ-101-1-29ページ.pdf b/JPNS 101/Assignments/ホールドラップ-101-1-29ページ.pdf new file mode 100644 index 0000000..517afd2 Binary files /dev/null and b/JPNS 101/Assignments/ホールドラップ-101-1-29ページ.pdf differ diff --git a/Research/pygameSim/CytoSim b/Research/pygameSim/CytoSim index 5f1fcca..e8f5108 160000 --- a/Research/pygameSim/CytoSim +++ b/Research/pygameSim/CytoSim @@ -1 +1 @@ -Subproject commit 5f1fcca682cb2dd9c7a0852258dfccdc52d729fb +Subproject commit e8f51086d48273a645fe4c988301f1401762e099 diff --git a/Research/pygameSim/main.py b/Research/pygameSim/main.py index cb37ebf..b440d7a 100644 --- a/Research/pygameSim/main.py +++ b/Research/pygameSim/main.py @@ -6,6 +6,9 @@ from particle import Particle from sensor import Sensor from slider import Slider +plt.ioff + + pygame.init() SCREEN_WIDTH = 800 diff --git a/csci218/Labs/lab6/GarrettHaldrupLab6.txt b/csci218/Labs/lab6/GarrettHaldrupLab6.txt new file mode 100644 index 0000000..dc6ec15 --- /dev/null +++ b/csci218/Labs/lab6/GarrettHaldrupLab6.txt @@ -0,0 +1,6 @@ +A: x <= 7 +B: x < 5 +C: x != 7 && y >= 10 +D: x == 9 || y < 5 +E: (x <= 7 || y > 10) && x <=6 +F: x < 25 && (y <= 5 || z == 4) \ No newline at end of file diff --git a/csci218/Labs/lab6/GarrettHaldruplab6.c b/csci218/Labs/lab6/GarrettHaldruplab6.c new file mode 100644 index 0000000..d5dfa8f --- /dev/null +++ b/csci218/Labs/lab6/GarrettHaldruplab6.c @@ -0,0 +1,227 @@ +/* Name: Garrett Haldrup +lab6.c +Problem: Runs a loop letting a user decide which of the 4 programs to run until they are done. +Certification of Authenticity: +I certify that this assignment is entirely my own work. +*/ + +#include +#include + +void scoreToLetter(); +void ageInfo(); +void digit2word(); +void simpleCalculator(); + +int main() { + char select, rerun; + while (1) { + + // Display Selection Info + printf("Select one program:\n"); + printf("- A: scoreToLetter\n"); + printf("- B: ageInfo\n"); + printf("- C: digit2word\n"); + printf("- D: simpleCalculator\n"); + printf("Enter selction: "); + scanf("%c", &select); + printf("\n"); + + // Standardize char selection + select = toupper(select); + + // Based on selection run a program + switch (select) { + case 'A': + scoreToLetter(); + break; + case 'B': + ageInfo(); + break; + case 'C': + digit2word(); + break; + case 'D': + simpleCalculator(); + break; + } + // Clear input buffer + while (getchar() != '\n'); + + // See if the user wants to continue the loop + printf("\nRun another? (y/n): "); + scanf("%c", &rerun); + + + // Standardize char for rerun ask + rerun = tolower(rerun); + + if (rerun == 'n') { + break; + } + + // Clear input buffer + while (getchar() != '\n'); + + printf("\n"); + + + } + + + return 0; +} + +void scoreToLetter() { + // Purpose + printf("This program will take a numerical score and convert it to a letter grade.\n"); + // Dclare int + int score; + // Take input + printf("Enter your score(0-100): "); + scanf("%d", &score); + // Switch Case and print grade + switch (score) { + case 90 ... 100: + printf("A\n"); + break; + case 80 ... 89: + printf("B\n"); + break; + case 70 ... 79: + printf("C\n"); + break; + case 60 ... 69: + printf("D\n"); + break; + case 0 ... 59: + printf("F\n"); + break; + default: + printf("Must be really bad or really good :)\n"); + } +} + +void ageInfo() { + // Purpose + printf("This program will take your age and say what you cant and can do\n\n"); + // Declare age + int age; + // Take Input + printf("Enter your age: "); + scanf("%d", &age); + + // Compare age to see range + if (age >= 18) { + printf("Can vote\n"); + if (age >= 21) { + printf("Can buy alcohol\n"); + } else { + printf("Not old enoguth to buy alcohol\n"); + } + } else { + printf("Not old enough to vote\n"); + } + +} + +void digit2word() { + // Purpose + printf("This program will take a digit (0-9) and convert it to a word.\n\n"); + + // Declare int variable + int num; + + // Ask for input number + printf("Enter a number(0-9): "); + scanf("%d", &num); + + // Swtich case the numbers + switch(num) { + case 0: + printf("Zero"); + break; + case 1: + printf("One"); + break; + case 2: + printf("Two"); + break; + case 3: + printf("Three"); + break; + case 4: + printf("Four"); + break; + case 5: + printf("Five"); + break; + case 6: + printf("Six"); + break; + case 7: + printf("Seven"); + break; + case 8: + printf("Eight"); + break; + case 9: + printf("Nine"); + break; + } + + +} + +void simpleCalculator() { + // Purpose + printf("This program will take float inputs and an operand and display the calculation!\n\n"); + // Declare floats and char + float num1, num2, answer; + char operand; + + // Ask 2 floats and operand + printf("Enter float number 1: "); + scanf("%f", &num1); + + while (1) { + printf("Enter your operand('-', '+', '*', '/'): "); + // Clear Buffer + while (getchar() != '\n'); + scanf("%c", &operand); + if (!(operand == '-' || operand == '+' || operand == '*' || operand == '/')) { + printf("Not a valid opperand! Please try again!\n"); + continue; + } + break; + } + + // Check if dividing by 0 + while (1) { + printf("Enter float number 2: "); + scanf("%f", &num2); + if (operand == '/' && !num2) { + printf("Cannot divide by 0! Please try again!\n"); + continue; + + } + break; + } + // Compute + switch (operand) { + case '-': + answer = num1 - num2; + break; + case '+': + answer = num1 + num2; + break; + case '*': + answer = num1 * num2; + break; + case '/': + answer = num1 / num2; + break; + } + // Display output + printf("%.1f %c %.1f = %.2f", num1, operand, num2, answer); +} diff --git a/csci218/Labs/lab6/lab6.o b/csci218/Labs/lab6/lab6.o new file mode 100755 index 0000000..96e0cd8 Binary files /dev/null and b/csci218/Labs/lab6/lab6.o differ diff --git a/csci218/Lect/101.c b/csci218/Lect/101.c new file mode 100644 index 0000000..9a5842e --- /dev/null +++ b/csci218/Lect/101.c @@ -0,0 +1,115 @@ +//Array, Loop, and C string + + +#include + +void iniArray(); +void evenNums(); +void oddNums(); +void copyArray(); +void Cstring(); + +int main() +{ + //iniArray(); + //evenNums(); + //oddNums(); + //copyArray(); + Cstring(); + + return 0; +} + +void iniArray(){ + printf("\nThis function ask values of array x one by one from user.\n"); + const int N = 5; + //declare an integer array x of N elements + + int x[N]; + + int len = sizeof(x)/sizeof(x[0]); + + //ask user to enter the values of elements + + for (int i = 0; i < len; i++) { + printf("Enter element %d: ", i + 1); + scanf("%d", &x[i]); + } + + //display all the values of x + printf("Array x[%d] has values: {", len); + for (int i = 0; i < len-1; i++) { + printf("%d, ", x[i]); + } + printf("%d}\n", x[len-1]); +} + +void evenNums(){ + printf("\nThe function will store 10 even numbers starting from 0 to array A. Print the array\n"); + //declare variables + + int A[10]; + + for (int i = 0; i < 10; i++) { + A[i] = i * 2 + 4; + } + + for (int i = 0; i < 10; i++) { + printf("%d ", A[i]); + } + printf("\n"); +} +void oddNums(){ + printf("\nThe function will store 10 odd numbers starting from 1 to array A. Print the array\n"); + //declare variables + int A[10]; + + for (int i = 0; i < 10; i++) { + A[i] = i * 2 + 1; + } + + for (int i = 0; i < 10; i++) { + printf("%d ", A[i]); + } + printf("\n"); +} +void copyArray(){ + printf("\nThis function copy element of array A to array B.\n"); + + int A[] = {2, 4, 6, 8}; // A is an integer array of length 4 + int B[3]; + int i; // loop index + //copy and print B + int lenB = sizeof(B)/sizeof(B[0]); + int lenA = sizeof(A)/sizeof(A[0]); + + for (int i = lenA - lenB; i < lenA; i++) { + B[i] = A[i]; + printf("%d ", B[i]); + } + printf("\n"); + //print A + for (int i = 0; i < lenA; i++) { + printf("%d ", A[i]); + } + printf("\n"); +} + +void Cstring(){ + printf("\nThis function is for you to learn C string.\n"); + //declare an array of charaters + char x[] = {'g', 'a', 'r', 'r', 'e', 't', 't', '\0'}; + printf("x = %s, size = %lu\n", x, sizeof(x)); + + //declare a C string y using " " + char y[] = "Hello There"; + printf("y = %s, size = %lu\n", y, sizeof(y)); + //declare a C string z using { }, '\0' indicate the end of string + char z[] = {'A', 'B', 'C', '\0'}; + printf("z = %s, size = %lu\n", z, sizeof(z)); + + + for (int i = 0; x[i]; i++) { + printf("%c\n", x[i]); + } +} diff --git a/csci218/Lect/output/101.o b/csci218/Lect/output/101.o new file mode 100755 index 0000000..2c2d24f Binary files /dev/null and b/csci218/Lect/output/101.o differ