Compare commits
2 Commits
c82e8c8b27
...
22cf3e8401
| Author | SHA1 | Date | |
|---|---|---|---|
| 22cf3e8401 | |||
| 4a1c1376a0 |
BIN
Research/Haldrup Sprint1.key
Executable file
BIN
Research/Haldrup Sprint1.key
Executable file
Binary file not shown.
109
csci218/Assignments/BMI.c
Normal file
109
csci218/Assignments/BMI.c
Normal file
@ -0,0 +1,109 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
int main(){
|
||||
|
||||
// Declare Variables
|
||||
// Float values for calculations
|
||||
float bmi, weight, height, mostellar, duBois, boyd, lifeExpect;
|
||||
|
||||
// Int values to store the result of the scanf fucntion
|
||||
int weightResult, heightResult;
|
||||
|
||||
// Char to store the gender with max length of 7 and a line string for formatting
|
||||
char gender[7];
|
||||
char line[] = "********************************";
|
||||
|
||||
// Display Program Purpose
|
||||
printf("%s%s%s*\n", line, line, line);
|
||||
printf("*\tThis program will calculate your BMI, Life Expectancy, and BSA(mulitple methods)\t*\n");
|
||||
printf("*\twith just your weight(kg), height(cm), and gender.\t\t\t\t\t*\n");
|
||||
printf("%s%s%s*\n", line, line, line);
|
||||
|
||||
// Read in weight, height, and gender from user
|
||||
printf("Please enter your weight(kg): ");
|
||||
weightResult = scanf("%f", &weight);
|
||||
while (weight <= 0 || weightResult != 1) {
|
||||
while (getchar() != '\n');
|
||||
if (weight <= 0) {
|
||||
printf("Bad Value: Weight must greater than 0! fmt: XX.X\n");
|
||||
} else {
|
||||
printf("Bad Value: Please enter a decimal input! fmt: XX.X\n");
|
||||
}
|
||||
printf("Please re-enter your weight(kg): ");
|
||||
weightResult = scanf("%f", &weight);
|
||||
}
|
||||
|
||||
printf("Please enter your height(cm): ");
|
||||
heightResult = scanf("%f", &height);
|
||||
while (height <= 0 || heightResult != 1) {
|
||||
while (getchar() != '\n');
|
||||
if (height <= 0) {
|
||||
printf("Bad Value: Height must greater than 0! fmt: XX.X\n");
|
||||
} else {
|
||||
printf("Bad Value: Please enter a decimal input! fmt: XX.X\n");
|
||||
}
|
||||
printf("Please re-enter your height(cm): ");
|
||||
heightResult = scanf("%f", &height);
|
||||
}
|
||||
|
||||
// Make sure correct values for gender are entered
|
||||
while (1) {
|
||||
// Read in gender from user
|
||||
printf("Please enter your gender(male or female): ");
|
||||
scanf("%s", gender);
|
||||
|
||||
// Loop through all chars in gender and convert to lower case
|
||||
for (int i = 0; i < strlen(gender); i++) {
|
||||
gender[i] = tolower(gender[i]);
|
||||
}
|
||||
|
||||
// Check if gender is valid
|
||||
if (!(strcmp("male", gender)) || !(strcmp("female", gender))) {
|
||||
break;
|
||||
} else {
|
||||
printf("Bad value: Please enter either male or female\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Calculate the BMI
|
||||
bmi = 10000 * (weight / pow(height, 2));
|
||||
|
||||
// Calculate the BSA(Mosteller's)
|
||||
mostellar = sqrt((height * weight) / 3600);
|
||||
|
||||
// Calculate the BSA(Dubois)
|
||||
duBois = (0.20247 * pow((height / 100), 0.725)) * pow(weight, 0.425);
|
||||
|
||||
// Calculate the BSA(boyd)
|
||||
boyd = (0.0003207 * pow(height, 0.3)) * pow((1000 * weight), (0.6721 - (0.0188 * log10(weight))));
|
||||
|
||||
// Check if overweight and gender to select correct life expectancy message
|
||||
// Only need to check one since the input screens to just two options
|
||||
if (strcmp("male", gender)) {
|
||||
if (bmi > 25) {
|
||||
lifeExpect = 81.4;
|
||||
} else {
|
||||
lifeExpect = 83.5;
|
||||
}
|
||||
} else {
|
||||
if (bmi > 25) {
|
||||
lifeExpect = 77.3;
|
||||
} else {
|
||||
lifeExpect = 79.4;
|
||||
}
|
||||
}
|
||||
|
||||
// Display values and output
|
||||
printf("For a %s with weight(kg) of %.1fkg and height(cm) of %.1fcm\n", gender, weight, height);
|
||||
printf("You have a BMI of %.1f and a life expectancy of %.1f years\n", bmi, lifeExpect);
|
||||
printf("You also have a BSA calculated using\n");
|
||||
printf(" - Mosteller's:\t%.3f\n", mostellar);
|
||||
printf(" - DuBois:\t\t%.3f\n", duBois);
|
||||
printf(" - Boyd:\t\t%.3f\n", boyd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
csci218/Assignments/bmi.out
Executable file
BIN
csci218/Assignments/bmi.out
Executable file
Binary file not shown.
BIN
csci218/Labs/.DS_Store
vendored
BIN
csci218/Labs/.DS_Store
vendored
Binary file not shown.
@ -11,13 +11,13 @@
|
||||
// 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);
|
||||
pinMode(7, 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
|
||||
digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||
delay(250); // wait for a second
|
||||
digitalWrite(7, LOW); // turn the LED off by making the voltage LOW
|
||||
delay(250); // wait for a second
|
||||
}
|
||||
|
||||
36
csci218/Labs/Lab4/dataRepresentation/dataRepresentation.ino
Normal file
36
csci218/Labs/Lab4/dataRepresentation/dataRepresentation.ino
Normal file
@ -0,0 +1,36 @@
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(9600);
|
||||
|
||||
int value = 151;
|
||||
|
||||
|
||||
Serial.print("Binary of ");
|
||||
Serial.print(value);
|
||||
Serial.print(" is: ");
|
||||
Serial.println(value, BIN);
|
||||
Serial.print("Decimal of ");
|
||||
Serial.print(value);
|
||||
Serial.print(" is: ");
|
||||
Serial.println(value, DEC);
|
||||
Serial.print("Hexidecimal of ");
|
||||
Serial.print(value);
|
||||
Serial.print(" is: ");
|
||||
Serial.println(value, HEX);
|
||||
Serial.print("Octal of ");
|
||||
Serial.print(value);
|
||||
Serial.print(" is: ");
|
||||
Serial.println(value, OCT);
|
||||
|
||||
for (int i = 0; i < 26; i++) {
|
||||
Serial.write(i + 65);
|
||||
Serial.print(" ");
|
||||
}
|
||||
Serial.println();
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
|
||||
}
|
||||
21
csci218/Labs/Lab4/displayLetter/displayLetter.ino
Normal file
21
csci218/Labs/Lab4/displayLetter/displayLetter.ino
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
int i = 65;
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(9600);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
Serial.write(i);
|
||||
Serial.print(" ");
|
||||
i++;
|
||||
if (i == 91) {
|
||||
i = 65;
|
||||
Serial.println();
|
||||
}
|
||||
delay(100);
|
||||
|
||||
}
|
||||
12
csci218/Labs/Lab4/example1/example1.ino
Normal file
12
csci218/Labs/Lab4/example1/example1.ino
Normal file
@ -0,0 +1,12 @@
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(9600);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
Serial.println("Hello World!");
|
||||
delay(500);
|
||||
|
||||
}
|
||||
24
csci218/Labs/triangleArea/triangleArea.ino
Normal file
24
csci218/Labs/triangleArea/triangleArea.ino
Normal file
@ -0,0 +1,24 @@
|
||||
#include <math.h>
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(9600);
|
||||
|
||||
float area, p, a, b, c;
|
||||
|
||||
a = 3;
|
||||
b = 4;
|
||||
c = 5;
|
||||
|
||||
p = (a + b + c) / 2;
|
||||
|
||||
area = sqrt(p * (p - a) * (p - b) * (p - c));
|
||||
|
||||
Serial.println(area);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
|
||||
}
|
||||
12
csci218/Lect/912class.c
Normal file
12
csci218/Lect/912class.c
Normal file
@ -0,0 +1,12 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
|
||||
int userNum;
|
||||
scanf("%d", &userNum);
|
||||
if (userNum % 3) {
|
||||
printf("is not a multiple of 3\n");
|
||||
} else {
|
||||
printf("is a multiple of 3\n");
|
||||
}
|
||||
}
|
||||
BIN
csci218/Lect/912class.out
Executable file
BIN
csci218/Lect/912class.out
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user