C Programming

Only available on StudyMode
  • Download(s) : 66
  • Published : December 4, 2012
Open Document
Text Preview
Spring 2011
Introduction to C - Programming Assignment #5
Due date: Please consult WebCourses for your section

Objectives
1. Learn how to design a program using functions.
2. Review of if statements and loops.

Note: In this assignment, you are required to write one program.

Problem: Universally Comical Funland Unified (ucf.c)
Your internship with UCF has gone quite well so far. You’ve helped design software for many different areas of the park ranging from the roller coasters to the custom t-shirts and even the ever-popular UCF Idol attraction.

At some point however, your boss would like you to unify much of your work into a single large program so that the park can run more cohesively. Instead of adding any new functionality into your program, you’ll be using your recently learned skill of writing functions to make this large program more manageable.

In particular, you will write a menu-driven program that provides the user with the following options:

1) Gift Shop Shipping
2) Calorie Counter Application
3) Roller Coaster Design
4) Printing Heart T-Shirts
5) UCF Idol
6) Quit

Each of these options will mimic Program 2A, Program 2B, Program 2C, Program 3B, and Program 4, respectively. Thus, please consult these descriptions with respect to the functionality of your program. All input specifications and output specifications will remain the exact same as in the previous write-ups of these problems.

Implementation Requirements
The main program will read the input and will invoke different functions to carry out the above subtasks (note that the main program will pass the proper values to each function). You will have to write several functions in your program and these functions must adhere to the function prototypes, pre-conditions and post-conditions specified below.

/* Pre-condition:
None
Post-condition:
Prints the menu.
*/
void printmenu();

/* Pre-condition:
price, weight: a positive real numbers less than 100.
quantity: a positive integer less than 100.
tax: 0(if not taxed), 1(if taxed)
Post-condition:
Given the four pieces of information as specified in
Program 2A, this function returns the total cost of
the corresponding order with shipping included.
*/
double itemShipping(double price, double weight,
int quantity, int tax);

/* Pre-conditions:
All four parameters are non-negative integers less
than 720.
Post-conditions:
Returns the weight change (in pounds) of the person
who walked, stood, drank and ate for the number of
minutes designated, using the calculation from
Program 2B.
*/
double weightChange(int minWalk, int minStand,
int minDrink, int minEat);

/* Pre-condition:
trackLength is positive and less than 10000.
maxTrainLength is in between 10 and 100, inclusive.
pMaxPeople points to a variable that will store the
maximum number of people for this train design.
pNumCars points to a variable that will store the
number of cars per train in the ideal design as
specified in Program 2C.
Post-condition:
The variables pointed to by pMaxPeople and pNumCars
will store the maximum number of people and the number of cars per train for this design, respectively.
*/
void rollerCoaster(int trackLength, int maxTrainLength,
int* pMaxPeople, int* pNumCars);

/* Pre-condition:
size is in between 3 and 10 inclusive.
Post-condition:
A heart with the given size will be printed, as
defined in Program 3B with the character ch.

*/
void printHeartDesign(int size, int ch);

/* Pre-condition:
ifp points to the beginning of a file that stores data about UCF Idol shows, as specified in Program 4.
Post-condition:
The results of all the shows in the file will be
printed to the screen and FILE...
tracking img