/* 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---------------------