Hey, need help with Dropping ball and Bouncing

This is a discussion on Hey, need help with Dropping ball and Bouncing within the C++ Programming forums, part of the General Programming Boards category; Hey everyone. Im having a bugger of a time with this program. Basically, im not sure if its right. I ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    16

    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
    Last edited by thynksheraze; 02-23-2003 at 03:31 PM.

  2. #2
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Click Read Me #3 in my signature, it will guide you.

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Also check the first readme in RoD's signature and scroll down to
    11.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to create a bouncing ball?
    By Swerve in forum C++ Programming
    Replies: 7
    Last Post: 09-12-2008, 04:41 AM
  2. The Old Bouncing Ball
    By bartybasher in forum Game Programming
    Replies: 3
    Last Post: 08-19-2003, 04:06 AM
  3. Simple bouncing ball program
    By funkydude9 in forum Game Programming
    Replies: 3
    Last Post: 08-18-2003, 11:00 PM
  4. Bouncing ball - help ??
    By Gugge in forum C Programming
    Replies: 7
    Last Post: 04-13-2002, 03:34 PM
  5. Bouncing ball
    By motocross95 in forum Game Programming
    Replies: 10
    Last Post: 01-07-2002, 09:25 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21