CSCI 1320 - Assignment #2


This will be your first coding assignment of the semester. It will be testing your ability to not only write a simple C program, but also your ability to use functions to decompose a problem and if statements for conditional execution. You have several options for what you do in this assignment. You only have to do one, so pick the one that suits your interests best. You could solve any of them without using functions, but in order to get full credit you have to write some functions other than main.

Grades

For this option you will write a program that calculates someones grade in this class based on values the user inputs. You will ignore dropping the lowest quiz grade for now. Have the user input 10 assignment grades, two test grades, six quiz grades, and a class participation grade in that order. Handle each of those in a function that returns the average for that part. Then write another function that takes in the partial functions and returns the total average. Print out each of the partial averages as well as the total average. Then print out the letter grade they would get using the standard of A=90-100, B=80s, C=70s, D=60s, F less than 60.

Roots of a Quadratic

For this problem you will write a program that simply gives the roots of a quadratic formula where the user inputs a, b, and c. There are a few issues though. First, the formula might be linear (a might be 0). Second, you need to print out complex roots if there are no real roots. Use separate functions to handle each of the alternatives.

Jump or Walk

This is a problem that might at first seem simple, but has some complexity to it in that you have to think of all the cases. The basic idea is that you are placed on a plane at a specified location and you want to get to the origin (0,0) as fast as possible. You have two ways of moving, either walking or jumping. You walk at a rate of 1 foot/sec and you can jump at some other rate over a fixed distance. At any time you can choose to walk or jump in any direction you want. Jumps have to be whole jumps though. If your jump is 5 feet, you can't choose to jump only 3 feet. The user gives you four pieces of information: your starting x location, you starting y location, the distance you jump in feet, and how long it takes you to complete a jump in seconds. You simply have to output the number of seconds it will take you to get to the origin using the fastest route.

For example, if the input was "3 4 2 1" you would know that you are 5 feet from the origin and that each jump will move you two feet in one second. You could walk straight there in 5 seconds. However, you could jump twice and get within 1 foot, then walk the last foot for a total time of 3 seconds.

Make sure you think of all the possibilities if you pick this option.