# CSE 102 – Computer Programming Homework #2

\$30.00

Category:

## Description

In this homework you will write simple programs to exercise with functions. You’ll submit this homework
PART I (40 pts)
In the previous homework you wrote a program that calculates the overall grade of the students. In this
part of this homework you will write a program which consists of one main function and one helper
function for this job. Assume that there is only one midterm, one homework and one final exam and your
program will calculate the grade. Please do not forget that your program should work exactly as the
example runs given below the part definitions.
The helper function’s signature is defined below:
}
and there will be no input/output operations in the main function.
Example run:
Please enter the 1. midterm weight:20
Please enter the 1. homework weight:30
Please enter the final exam weight:50
or include statements.)
PART II (60 pts)
Write a program that calculates the area and perimeter of certain geometric shapes. You will write helper
functions for each shape type that calculates the area or perimeter and return the result.
You can test your functions in your main function. You should not do an I/O operation within the helper
functions(there will be no printf or scanf). Functions prototypes are defined below, you should not change
either names or the parameters of the functions.
Note: PI = 3.14
int areaOfRectangle(int width, int height) {
}
int perimeterOfRectangle(int width, int height) {
}
int areaOfSquare(int edgeLength) {
}
int perimeterOfSquare(int edgeLength) {
}
}
}
Example run:
Please enter the width of the rectangle:10
Please enter the height of the rectangle:20
The area of the rectangle is: 200
The perimeter of the rectangle is: 60
Please enter the width of the square:10
The area of the square is: 100
The perimeter of the square is: 40