John is a magician; he has three cups and one ball. John asks people to specify how many times the cups are swapped, also asks which cups are swapped among each other. After that, John tells people which cup that has the ball. Write a program that perform what John is doing. Note: Initially, assume that the ball is under cup 1. Sample1: Sample2: How many times do you want to swap cups? 2 How many times do you want to swap cups? 3 What cups do you want to swap between them?| What cups do you want to swap between them? 1 2 3 What cups do you want to swap between them? | What cups do you want to swap between them? 2 |1 3 2 The Cup that has the ball is: 3 What cups do you want to swap between them? 2 3 The Cup that has the ball is: 2

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 15PE
icon
Related questions
Question

python

John is a magician; he has three cups and one ball. John asks people to specify how
many times the cups are swapped, also asks which cups are swapped among each
other. After that, John tells people which cup that has the ball.
Write a program that perform what John is doing.
Note: Initially, assume that the ball is under cup 1.
Sample1:
Sample2:
How many times do you want to swap cups? 2 How many times do you want to swap cups? 3
What cups do you want to swap between them?||What cups do you want to swap between them?
1
2
3
What cups do you want to swap between them? | What cups do you want to swap between them?
2
|1
3
2
The Cup that has the ball is: 3
What cups do you want to swap between them?
2
3
The Cup that has the ball is: 2
Transcribed Image Text:John is a magician; he has three cups and one ball. John asks people to specify how many times the cups are swapped, also asks which cups are swapped among each other. After that, John tells people which cup that has the ball. Write a program that perform what John is doing. Note: Initially, assume that the ball is under cup 1. Sample1: Sample2: How many times do you want to swap cups? 2 How many times do you want to swap cups? 3 What cups do you want to swap between them?||What cups do you want to swap between them? 1 2 3 What cups do you want to swap between them? | What cups do you want to swap between them? 2 |1 3 2 The Cup that has the ball is: 3 What cups do you want to swap between them? 2 3 The Cup that has the ball is: 2
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr