# Thread: Hey, need help with Dropping ball and Bouncing

1. ## Hey, need help with Dropping ball and Bouncing

Hey everyone. Im having a bugger of a time with this program. Basically, im not sure if its right. I have to set a height for a ball to drop from, then ask how many bounces would you like to calculate. The results are how many times it bounced (negligable bounces are of .00001 feet.). I also have to show how many feet and INCHES (so it would show like 12 feet, 3 inches) it bounced. Not like 12.34 inches or somethinng. Am i doing this right? and if anyone can point me in the direction of doing it the right way, that would help

---- begin code

/* Azhar Sheraze
6 weeks Program
Ball Bounce
*/

#include <iostream>
#include <conio>
#include <cstring>
#include <iomanip>

void main()
{

int bounce, bounce2, go_on, balltype, end;

float feet, total, ratio, height,
tennis=.49, rubberball=.81, lacross= .75;

total=0;
go_on=2;
bounce2=0;

clrscr ();

cout << setiosflags(ios::showpoint|ios::fixed)<<setprecisi on(2);

do
{

do
{
clrscr();

//Here is where I ask what type of ball

cout << "Please choose the type of ball (type 1, 2, or 3)" << endl;
cout << "1. Tennis Ball " << endl;
cout << "2. Rubber Ball " << endl;
cout << "3. Lacross Ball"<< endl;
cin >> balltype;
cout << endl;

if(balltype == 1)
ratio=tennis;

if(balltype == 2)
ratio = rubberball;

if(balltype == 3)
ratio = lacross;

cout << "Is this a correct selection? 1 for yes, 0 to try again." << endl;
cin >> go_on;

}while(go_on==0);

//Here is where I ask the feet and the bounces they want

cout << "Enter the height in feet that the ball is dropped from..." <<endl;
cin >> feet;
cout << endl;

cout << "How many bounces you want the ball to bounce?" <<endl;
cin >> bounce;
cout <<endl;

//My Calculations

height=feet;

do
{
total=total+height;
height=height*ratio;
total=total+height;
bounce2=bounce2+1;
}while(bounce>0 && height > .00001);

//Here is my total and the bounce of the ball

cout << "The ball bounced "<< bounce2 <<" times and went a total distance of: " << total << endl;
cout << endl;

cout << "Press 1 to choose another ball, or 0 to quit." << endl << endl;
cin >> end;

total=0;
bounce=0;

}while(end==1);

}

------------- end c0de---------------------

Thanks a lot for your time

2. Click Read Me #3 in my signature, it will guide you.

3. Also check the first readme in RoD's signature and scroll down to
11.