Concept explainers
A government research lab has concluded that an artificial sweetener commonly used in diet soda pop will cause death in laboratory mice. A friend of yours is desperate to lose weight but cannot give up soda pop. Your friend wants to know how much diet soda pop it is possible to drink without dying as a result. Write a
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Elementary Surveying: An Introduction To Geomatics (15th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out With Visual Basic (8th Edition)
Starting Out with Python (4th Edition)
- (Program) Write a program to simulate the rolling of two dice. If the total of the two dice is 7 or 11, you win; otherwise, you lose. Embellish this program as much as you like with betting, different odds, different combinations for win or lose, stopping play when you have no money left or reach the house limit, displaying the dice, and so forth. (Hint: Calculate the dots showing on each die with theexpressiondots=(int)(6.0randomnumber+1), where random number is between 0 and 1.)arrow_forwardWrite a program to get an integer input from the user. If the input is 25, take the length and breadth from the user and calculate the area of rectangle. [ Area of rectangle = length * breadth ] If the input is 40, get the side from the user and calculate the area of square. [ Area of square = side * side ] If the input is 65, get the radius from the user and calculate the area of circle. [ Area of circle = 3.14*r*r] Otherwise Display " Enter number 25 or 40 or 65 ".arrow_forwardWrite a python program of the following using the modification of the second picturearrow_forward
- Write a "Guess My Number Game" program. The program generates a random integer in a specified range, and the user (the player) has to guess the number. The program allows the use to play as many times as he/she would like; at the conclusion of each game, the program asks whether the player wants to play again. The basic algorithm is: 1. The program starts by printing instructions on the screen. 2. For every game: the program generates a new random integer in the range from MIN to MAX. Treat MIN and MAX like constants; start by initializing them to 1 and 100 ► loop to prompt the player for a guess until the player correctly guesses the integer for each guess, the program prints whether the player's guess was too low, too high, or correct at the conclusion (when the integer has been guessed): ➤ print the total number of guesses for that game print a message regarding how well the player did in that game (e.g., the player took way too long to guess the number, the player was awesome,…arrow_forwardYou are working on a ticketing system. A ticket costs $10. The office is running a discount campaign: each group of 5 people is getting a discount, which is determined by the age of the youngest person in the group. You need to create a program that takes the ages of all 5 people as input and outputs the total price of the tickets. Sample Input: 55 28 15 38 63 Sample Output: 42.5 The youngest age is 15, so the group gets a 15% discount from the total price, which is $50 - 15% = $42.5 The given code is declaring an array of 5 elements and taking them from input using a loop.arrow_forwardIn order to discourage excess electric consumption, an electrical company charges its customers a lower rate of P75 for the first 250 kilowatt-hours and a higher rate of P8.5 for each additional kilowatt-hour. In addition, a 10% surtax is added to the final bill. Write a program that calculates the electrical bill given the number of kilowatt-hours consumed as input. At the end, print the number of kilowatt- hours consumed and the computed bill. For example: Input Result 200 Kilowatt -hours: 200 Electric bill: Php 82.50 260 Kilowatt-hours: 260 Electric bill: Php 176.00arrow_forward
- Sometimes we write similar letters to different people. For example, you might write to your parents to tell them about your classes and your friends and to ask for money; you might write to a friend about your love life, your classes, and your hobbies; and you might write to your brother about your hobbies and your friends and to ask for money. Write a program that prints similar letters such as these to three people of your choice. Each letter should have at least one paragraph in common with each of the other letters. Your main program should have three method calls, one for each of the people to whom you are writing. Try to isolate repeated tasks into methods.arrow_forwardWrite a program to calculate the grade point average (GPA) of a student by getting their grades for all their subjects. Grades and their grade points areGrade S 10 pointsGrade A 9 pointsGrade B 8 pointsGrade C 7 pointsGrade D 6 pointsGrade E 5 pointsGrade F 0 pointsThe program should input the number of subjects, followed by the grade obtained in each subject. The program should calculate the average of the grade points and print it.arrow_forwardA piece of wire is to be bent in the form of a rectangle to put around a picture frame. The length of the picture frame is 1.5 times the width. Write a program that prompts the user to input the length of the wire and outputs the length and width of the picture frame.arrow_forward
- A mass m is attached to the end of a rope of length r 3 meters. The rope can only be whirled around at speeds of 1, 10, 20, or 40 meters per second. The rope can with stand a maximum tension of T = 60 Newtons. Write a program where the user enters the value of the mass m, and the program determines the greatest speed at which it can be whirled without breaking the rope. Assume that the mass m is less than 100 kg. Hint: T = mv2 /r. Drop Your Code here: #Set the rope length #Set the maximum tension #Set the message #Read the mass value #Set a list of possible rotation speed #Set the size of the list Drag your statements from the following choices: length = 3 max_tension = 60 message = "The greatest speed without breaking the rope is:" mass = float(input(">>>Enters the value of the mass m: ")) rotation_speed - [1. 10, 20, 40] N= len(rotation_speed) pos - N-1 for i in range (N): tension = mass"rotation_speed[i)*2/length if tension>max tension: pos i-1 break…arrow_forwardplease solve this in pythonarrow_forward...arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr