Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ball and the rocket will both move, one after the other. Write Create a new meth

ID: 3753975 • Letter: B

Question

ball and the rocket will both move, one after the other. Write Create a new method, bounceBallO, that moves the ball smoothly to the floor" of the window and then moves it back up to its original height. The signature of bounceBall) is: publie void bounceBallo To do this you will need to write two consecutive while loops. The first loop will move the ball down until it reaches the lower-right window boundary. Use an xDistance of I and a yDistance of 3. The second loop will move the ball upward as long as it is lower than its original height and has not reached the right side of the window. Use an xDistance of 1 and a yDistance of -3. Test bounceBall0 before someone checks your lab. WACOM

Explanation / Answer

Hello,

I have written a simple c program for your requirement kindly go through

#include <stdio.h>

#include <conio.h>

#include <graphics.h>

#include <dos.h>

int main() {

public void bounceBall()

int gd = DETECT, gm;

int i, x, y, flag=0;

initgraph(&gd, &gm, "C:\TC\BGI");

/ *x and y axis */

x = 1;

y = -3;

while (!kbhit()) {

  if(y >= getmaxy()-30 || y <= 30)

     flag = !flag;

     /* draws the gray board */

     setcolor(RED);

     setfillstyle(SOLID_FILL, RED);

     circle(x, y, 30);

     floodfill(x, y, RED);

/* delay for 50 milli seconds */

delay(50);

/* clears screen */

cleardevice();

if(flag){

     y = y + 5;

} else {

     y = y - 5;

}

    }

    getch();

closegraph();

return 0;

}

}