$29
In this homework you will write simple programs to exercise with functions. You’ll submit this homework via KADI system (http://46.101.216.112/)
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:
void calculateLastGrade(){
/* Your code */
}
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
Please enter the 1. midterm grade:20
Please enter the 1. homework grade:40
Please enter the final exam grade:70
Your final grade is: 51.000000
You should only send your calculateLastGrade() function to KADI system. (Do NOT send main function 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) { /* Your code */
}
int perimeterOfRectangle(int width, int height) { /* Your code */
}
int areaOfSquare(int edgeLength) {
/* Your code */
}
int perimeterOfSquare(int edgeLength) {
/* Your code */
}
double areaOfCircle(int radius) {
/* Your code */
}
double perimeterOfCircle(int radius) {
/* Your code */
}
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
Please enter the
radius of
the
circle:7
The area of the circle
is:
153.86
The perimeter of
the circle is: 43.96
You should NOT send your main function or include statements.