CSE102 HW02 solution

$25.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

Part 1 50pts
In this part you will write a function that plots the graph of a given function
int fTheFunction(int x, int functionNumber). f is a hidden function that takes an integer and
returns an integer. There are 5 such functions that your function is going to be tested with.
Your function should plot x and y axis lines also.
First function is f(x)=2*x and its graph is in the sample output below.
Signature
int fTheFunction(int x,int functionNumber)
void drawFunction(int xAxis,int yAxis,int functionNumber);
Sample Usage
result = fTheFunction(x,functionNumber )
(x=4; functionNumber=1; result=8)
drawFunction(xAxis,yAxis,functionNumber);
(xAxis=40 ; yAxis=40 ; functionNumber=1)
Output
| *
|
| *
|
| *
|
| *
|
| *
|
| *
|
| *
|
| *
|
| *
|
| *
|
| *
|
| *
|
| *
|
| *
|
| *
|
| *
|
| *
|
| *
|
| *
|
| *
|
|—————————————-
Part 2
In this part you will write a function to draw a simple car that contains two stacked
rectangles and two circles as wheels.
a)20pts
Write a function that draws rectangle.
b)20pts
Write a function that draws two circles near each other.
c)10pts
Write a function to draw a car using two functions above.
Signature
void drawRectangle(int width,int height, int startingPoint, int printLastLine);
void drawDoubleCircle(int radius, int startingPoint , int whellDistance);
void drawCar();
Sample Usage
drawRectangle (width,height, startingPoint, printLastLine);
( width:10, height:40, startingPoint:11, printLastLine:0)
drawDoubleCircle(radius, startingPoint ,whellDistance);
( radius:4, startingPoint:7 whellDistance:12)
drawCar(); (Output of this function as below)
Return Value
****************************************
* *
* *
* *
* *
* *
* *
* *
* *
* *
************************************************************
* *
* *
* *
* *
* *
* *
* *
* *
************************************************************
* *
* * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * *
* *