Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ The purpose of this problem is to determine whether a set of weights will balance a seesaw. You will be given an even number

C++

image text in transcribed

The purpose of this problem is to determine whether a set of weights will balance a seesaw. You will be given an even number of integers representing weights on input. These weights will be placed at integral distances from the fulcrum, in the order entered from left to right. The first half of the weights will be placed on the left side of the fulcrum and the last half of the weights will be placed on the right side of the fulcrum. An integer of 0 will terminate the set of weights. For example, for the situation above, the input would be: 25 50 20 40 0.

INPUT: Your program should accept a list of integers entered at the prompt: Enter weights: . The list of integers will be terminated by the integer 0.Your program should continue to accept inputs until a 0 alone is entered. At this point your program should terminate. There will be no more than 50 weights entered.

OUTPUT: Output should be either: BALANCES or DOES NOT BALANCE.

EXAMPLE: Enter weights: 25 50 20 40 0

BALANCES

Enter weights: 2 4 6 8 2 4 0

DOES NOT BALANCE

Enter weights: 0

image text in transcribed

Your code should use a stack. (Youre free to use the STL stack!)

All code must be well commented (routines and logic blocks, not line by line).

You may assume good input, all integers & an even number of weights on each side (i.e, If there are 3 on the left, then there will be 3 on the right.)

This criterion is linked to a Learning OutcomeGrading Criteria Accurately determined balanced or not.

Accurately determined balanced or not

A seesaw (also known as a teeter-totter) is a long, narrow board suspended in the middle so that, as one end goes up, the other goes down. From physics, this is a lever where the fulcrum is in the middle. 30 30 fulcrum Archimedes was the first to explain the principle of the lever stating that equal weights at equal distances from the fulcrum are in equilibrium, and equal weights at unequal distances from the fulcrum are not in equilibrium but incline towards the weight which is at the greater distance." The above diagram illustrates that equal weights at equal distances causes the seesaw to balance. The Law of the Lever is that the lever will balance when the sum of the products of the weight and distance of the weights from the fulcrum on both sides of the fulcrum are equal. So the following set of weights and distances balance the seesaw if the weights are of distance 1 or 2 from the fulcrum. 25 50 20 40 2 1 2 2 X25 1X50 1 X 20 2 X 40

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

More Books

Students also viewed these Databases questions

Question

0 it v F F i ' follow-up

Answered: 1 week ago