Concept explainers
You are a contestant on a game show and have won a shot at the grand prize. Before you are three doors. $1,000,000 in cash has randomly been placed behind one door. Behind the other two doors are the consolation prizes of dishwasher detergent. The game show host asks you to select a door, and you randomly pick one. However, before revealing the prize behind your door, the game show host reveals one of the other doors that contains a consolation prize. At this point, the game show host asks if you would like to stick with your original choice or to switch to the remaining door.
Write a function to simulate the game show problem. Your function should randomly select locations for the prizes, select a door at random chosen by the contestant, and then determine whether the contestant would win or lose by sticking with the original choice or switching to the remaining door. You may wish to create additional functions invoked by this function.
Next, modify your
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
ABSOLUTE C++ -TEXT
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Management Information Systems: Managing The Digital Firm (16th Edition)
Database Concepts (8th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
- Control Loops: A high school 1000 students and 1000 lockers. The principal plays the following game: She asks dthe first student to open all the lockers. Shen then asks the second student to close all the even-numbered lockers. The third student is asked to check every third locker. If it is open, the student closes it; if it is closed, the student opens it. The remaining students continue this game . In general, the nth student checks every nth locker. If the locker is open, the student closes it; if it is closed, the student opens it. After all the students have taken their turns, some of the lockers are open and some are closed. Write a program thatprompts the user to enter the number of lockers in a school. After the game is over, the program outputs the number of lockers and the locker numbers of the lockers that are open. Test run your program for the following inputs: 1000, 5000, 10,000. Do you see any pattern developing for the locker numbers that are open in the output?…arrow_forwardQ2 The Powerball Lottery 15 Points The Powerball lottery is based on a random drawing of six balls from two machines. One machine contains 69 white balls (labeled 1 through 69) and the other machine contains 26 red balls (labeled 1 through 26). To determine the winning numbers, the gamemaster draws five white balls from the first machine and one red ball (the "Powerball") from the second machine (assume all outcomes are equally likely). A player in the Powerball lottery picks five different numbers between 1 and 69 (inclusive) and a sixth number between 1 and 26 (inclusive), which may duplicate one of the first five numbers. For each of the following questions, you should write your answer as an expression. Do not give the final numeric value. For example, you should write C(4, 2)/24) instead of 0.375.arrow_forwardSerendipity Booksellers has a book club that awards points to its customers based on the number of books purchased each month. The points are awarded as follows: If a customer purchases no books, he or she earns 0 points If a customer purchases 1 through 5 books, he or she earns 5 points for each book. If a customer purchases 6 through 10 books, he or she earns 10 points for each book. If a customer purchases 11 or more books, he or she earns points equal to 20 points for each book. (Use Python) Use the Design Recipe to write the function customer_rewards which consumes the number of books purchased, and returns the total points. Include a docstring! Write 3 assert_equal statements to test your function.arrow_forward
- A serendipity bookseller has a book club that awards points to its customers based on the number of books purchased each month. The points are awarded as follows: If a customer purchases 0 books, he or she earns 0 points. If a customer purchases 1 books, he or she earns 5 points. If a customer purchases 2 books, he or she earns 15 points. If a customer purchases 3 books, he or she earns 30 points. If a customer purchases 4 or more books, he or she earns 60 points. W rite a program that asks the user to enter the number of books that he or she has purchased this month and then displays the number of points awarded. using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms; namespace Chapter_4_Problem_6___Seth{public partial class bookClubPoints : Form{public bookClubPoints(){InitializeComponent();}}} C# please code with this contextarrow_forwardEnter the colour of the baggie you are throwing (red/yellow/blue/green): red red bag lands on yellow ring. Enter the colour of the baggie you are throwing (red/yellow/blue/green): yellow yellow bag lands in hole. Enter the colour of the baggie you are throwing (red/yellow/blue/green): green green bag lands on yellow ring. Enter the colour of the baggie you are throwing (red/yellow/blue/green): blue blue bag lands on yellow ring. User points: 17 Computer points: 9 Congratulations! You won the game by 8 points. Choose 1 or 2 to play one of the following games, or 3 to quit playing 1. Cornhole 2. Guessing Medals 3. Quit Enter your choice: 3 Goodbye. Hope you enjoyed playing! • function guessMedals which asks the user for an integer from 0 to 200 (inclusive), generates a random integer between 50 and 150 (inclusive) and then tells the user what type of medal they have won, depending on how close they came to guessing the number. Medals are awarded as follows:o bronze medal for a guess…arrow_forwardBP Service Station sells gasoline and has a car wash. Fees for the car wash are the US $15,000.00 with a gasoline purchase of US $20,000.00 or more and the US $20,000.00 otherwise. Three kinds of gasoline are available: regular at K3,900.00, unleaded at the US $, 200.00, and super unleaded at the US $ 4 600.00 per litter. You are required to write a program that prints a statement for a customer. Input consists of the number of litters purchased, kind of gasoline purchased (R, U, S, or for no purchase, N), and car wash desired (Y or N). (a). Develop a Pseudocode and a structure chart for the service station problem.(b). Write a program in c++ programming to compute the amount due from a customer of the service station.arrow_forward
- Q2 / chose the right answer 1- a=3; b=5; c=7, enter ? (7/ 3,5,7/ 3,5) 2 - a=1:9; b=9-a; c= 0, enter ? ( 1,2,3,4,5,6,7,8,9 / 8,7,6,5,4,3,2,1,0 / 0) 3 - X(4+5) =9; Y(5-4) = 1; C = X+Y = ? (10 /8/ 11) { - Operator bitor (A, B) the Description is (Bitwise AND / Bitwise OR / Logical NOT) 5 - 100:-7:40 Matrix with one row is (100 93 76 79 72 65 58 81 16 / 100 93 86 79 72 65 58 51 46 / 100 23 86 79 72 35 58 51 46 )arrow_forwardRed=5 Blue = 10 P(RED)?arrow_forwardDuring a trivia game, you answered 18 out of 25 questions correctly. Your friend answered 0.7 of the questions correctly. Write a number sentence for who had the greater number of correct answers.arrow_forward
- A robot sits in a 30 foot square room. It be directed to travel a randomly generated distance between 8 and 20 feet. The user will input a value that will serve as the seed for the random number generator. Every foot it travels it indicates that it has traveled 'x feet'. Upon arrival at the user specified distance, it announces." made it!"(This will happen even if the robot moves 0 feet). The program should also indicate how many more feet the robot could travel before running into a wall assuming it always starts at one wall of the room. Note that grammar used to indicate singular versus plural distances. i.e. for an random generation of 5, the resulting output should be: How far should the robot travel? 5 feet 1 foot I made it! I can only travel 25 mor 2 feet 3 feet 4 feet 5 feet e feet. tabs are used to space the output of traveled feet 330492.1753326.qx3zay7 LAB АCTIVITY main.cpp 1 #include 2 using namespace std; 3 4 int main() int roomsize - 30; 6 int distance = 0; 7 8 cout <«…arrow_forwardFlag question Let A = {1, 2, 3, 4, 5, 6, 7} Let B = {3, 4, 5, 6, 7, 8, 9} Let X = 13 Let X=X+|An B| Let X=X+|A U B| What is the mystery number X? Answer:arrow_forwardThe 24-point card game involves picking any four cards from 52 cards, as shown in Figure 10.20. Note that the jokers are excluded. Each card represents a number. An ace, king, queen, and jack represent 1, 13, 12, and 11, respectively. Enter an expression that uses the four numbers from the four selected cards. Each card number can be used only once in each expression, and each card must be used. You can use the operators ( *, and /) and parentheses in the expression. The expression must evaluate to 24. After entering the expression, click the Verify button to check whether the numbers in the expression are currently selected and whether the result of the expression is correct. Display the verification in a dialog box. You can click the Refresh button to get another set of four cards. Assume thatimages are stored in files named 1.gif, 2.gif, ..., 52.gif, in the order of spades, hearts, diamonds, and clubs. So, the first 13 images are for spades 1, 2, 3, ..., and 13.arrow_forward
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT