Question
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++
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
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 |
|
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started