diff --git a/Homework3/jump_the_five b/Homework3/jump_the_five new file mode 100755 index 0000000..5a7ecd0 Binary files /dev/null and b/Homework3/jump_the_five differ diff --git a/Homework3/jump_the_five.c b/Homework3/jump_the_five.c index e9bdf93..ad732b5 100644 --- a/Homework3/jump_the_five.c +++ b/Homework3/jump_the_five.c @@ -20,7 +20,33 @@ int main(int argc, char *argv[]) { // define local variables // do calculations - // display results + // check to see if there are valid phone numbers (7 or 10 digits) + if(argc == 8 || argc == 11) + { + // iterate through the arguments in list + for(int i = 1; i < argc; i++) + { + // define and get the number using atoi + int num = atoi(argv[i]); + // check to see if the number is 5/0, and print the opposite. + if(num == 5) + { + printf("0 "); + } + else if(num == 0) + { + printf("5 "); + } + else + { + // otherwise, subtract the number from ten to get "the opposite" + printf("%i ", 10 - num); + } + } + printf("\n"); + return 0; + } + printf("You must enter 7 or 10 digits as a valid phone number.\n"); // return success return 0; -} \ No newline at end of file +} diff --git a/Homework3/temperature_chart b/Homework3/temperature_chart new file mode 100755 index 0000000..624b6f1 Binary files /dev/null and b/Homework3/temperature_chart differ diff --git a/Homework3/temperature_chart.c b/Homework3/temperature_chart.c index 0c03826..c48bb03 100644 --- a/Homework3/temperature_chart.c +++ b/Homework3/temperature_chart.c @@ -19,35 +19,26 @@ Dependencies: included by standard libraries */ int main(int argc, char *argv[]) { - // define local variables - double start = atof(argv[1]), stop = atof(argv[2]); + // check if proper arguments are provided + if (argc < 3 || argc > 4) + { + printf("You must provide two or three integers.\n"); + return 0; + } + // define the start and stops, steps if applicable + double start = atof(argv[1]); + double stop = atof(argv[2]); int step = 1; - int tempIterator; - // do calculations - if(argc == 3 || argc == 2) + if (argc == 4) { - // do the temperature chart stuff here - // check to see if a step is provided - if(argc == 3) - { - step = atof(argv[3]); - } - // do the printing and looping - printf("%f\t%f\n", start, start); - for(tempIterator = 0; tempIterator < stop; tempIterator++) - { - // print out the temp and it's conversion - printf("%f\t%f\n", ); - } + // define the step if provided. + step = atoi(argv[3]); } - else + for (start = atof(argv[1]); start <= stop; start += step) { - // fail program - printf("Please provide two or three integers.\n"); - return -1; + // print out the temperature chart + printf("%g\t%f\n", start, (start - 32) * 5 / 9); } - // display results - // done in do calculations - // return success + // end program return 0; } \ No newline at end of file