Program to compute distance travelled by ball, C/C++ Programming

Assignment Help:

Produce a pseudo code to be used for development compute and display some data on the bounces a ball will make when dropped from a given height.

To simplify the problem, you assume the ball bounces in place; that is, it remains bouncing on the same spot and does not have any forward motion. The program will prompt the user for the initial height of the ball, the number of bounces to consider, and the ball's elasticity (which must lie between 0 and 1). It will compute the height of each bounce based on the initial height and the elasticity of the ball, and display it. The program will also compute the total distance travelled, which is the sum of the up and down bounces, for the given number of bounces, and display it. The program will repeat this process until the user tells it to stop.

If the ball is at height h, when it bounces, it reaches new height h', which is computed by the formula

h' = h ´ resilience

where resilience is expressed as the elasticity coefficient raised to the nth power, if n is the bounce number:

resilience = elasticityn

If the original height is H, then the first bounce height will be

h   = H ´ elasticity

With elasticity in the range between 0 and 1, each bounce will be smaller than the preceding one, but never become 0. We will therefore stop the program after a specified number of bounces.

The ball will travel the distance shown bellow (where the elasticity is 0.8) which we have drawn to help you. We have represented a forward motion for the sake of clarity (the ball bounces on the same spot).

1362_distance travel by ball as it bounce.png

Each time the ball bounces, it travels twice the height of the bounce, so the total distance travelled is

H + 2h   + 2h   + 2h   + 2h

+ ...

1

2

3

4





The user will be prompted for the initial height in this way:

Give the height in inches from which the ball is dropped:

Then the user will be asked the number of bounces:

Give  the  number  of  times  the  ball  will  bounce:

And finally the user will be asked the elasticity of the ball:

Give  the  elasticity  of  the  ball  (between  0  and  1):

For each bounce the program will display the following:

On bounce 9 the ball rises to a height of 99.9 inches.

After the last bounce the program will display the following:

The total distance travelled by a ball with an elasticity of 0.999 when dropped from a height of 99.9 inches and after bouncing 9 times is 999 inches.

The user will be asked if the program is to continue:

Another try?

 b.  Amend your formulae to calculate until bounce height becomes less than 1 inch and produce number of bounces.


Related Discussions:- Program to compute distance travelled by ball

Find and print the oldest and the youngest employee, Draw a flowchart ...

Draw a flowchart for a program that allows the user to enter 20 names along with their ages and their Social Security Numbers in three parallel arrays. Programs shou

What should one throw?, A: C++, unlike only about every other language with...

A: C++, unlike only about every other language with exceptions, is extremely accomodating while it comes to what you can throw. Actually, you can throw anything you akin to. That b

Store marks and name, Program is to store marks and name, roll no in a file...

Program is to store marks and name, roll no in a file: class stud   {     int rno;     char name[20];     int m1,m2,m3;     public:                 void acce

Array, how to pass array

how to pass array

Constructor, Why copy constructor accepts reference to an object and not t...

Why copy constructor accepts reference to an object and not the object itself, whether ah hence it we do otherwise

Write an application to test class integerset, Set of Integers) Create clas...

Set of Integers) Create class IntegerSet. Each IntegerSet object can hold integers in the range 0-100. The set is represented by an array of bools. Array element a[i] is true if in

Sorted linked list , Node *orderedInsert(Node *p, int newval); /* Allocates...

Node *orderedInsert(Node *p, int newval); /* Allocates a new Node with data value newval and inserts into the ordered list with first node pointer p in such a way that the data va

Need help, how to make basics strong and best logic skills what are the bes...

how to make basics strong and best logic skills what are the best way to be a expert programmer ? what counts a lot knowledge or practice?

Explain destructors, Destructors A destructor function gets implemented...

Destructors A destructor function gets implemented whenever an instance of the class to which it belongs goes out of existence. The primary usage of a destructor function is

Explain union, Unions A union is also like a structure, except that onl...

Unions A union is also like a structure, except that only single variable in the union is stored in the allocated memory at a time. It is a collection of mutually exclusive var

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd