Concept explainers
Many treadmills output the speed of the treadmill in miles per hour (mph) on the console, but most runners think of speed in terms of a pace. A common pace is the number of minutes and seconds per mile instead of mph.
Write a
intValue = static_cast<int>(dblVal);
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (8th Edition)
Starting Out with C++: Early Objects
C Programming Language
Software Engineering (10th Edition)
Concepts of Programming Languages (11th Edition)
Digital Fundamentals (11th 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_forwardflowchart of Many treadmills output the speed of the treadmill in miles per hour (mph) on the console, but most runners think of speed in terms of a pace. A common pace is the number of minutes and seconds per mile instead of mph. You want to solve this problem by developing a program. Your program startswith a quantity in mph and converts the quantity into minutes and seconds per mile. As an example, the proper output for an input of 6.5 mph should be 9 minutes and 13.8 seconds per mile.arrow_forward4. Write a Phyton program that computes the speed of sound (a) in air of a given temperature T (°F ). Use the formula 5T+2297 2457 a = 10861arrow_forward
- In 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_forwardWrite a program that asks you to input an integer. After you input the integer, it should ask if you want to input another integer. If you answer y, it should allow you to input a second integer and then output the sum of the two integers you entered. If you answer n or some character other than y, it should output the integer you input before. For example: if you input 4, answer y and then input 3, it should output 7 if you input 4 and answer n, it should output 4arrow_forwardYou are to write a program to tell you how many months it will take to pay off a loan, as well as the total amount of interest paid over the life of the loan. You have just purchased a stereo system that costs $1000 on the following credit plan: No down payment, an interest rate of 18% per year (and hence 1.5% per month), and monthly payments of $50. The monthly payment of $50 is used to pay the interest and whatever is left is used to pay part of the remaining debt. Hence, the first month you pay 1.5% of $1000 in interest. That is $15 in interest. So, the remaining $35 is deducted from your debt which leaves you with a debt of $965.00. The next month you pay interest of 1.5% of $965.00, which is $14.48. Hence, you can deduct $35.52 (which is $50 - $14.48) from the amount you owe. Write a program that will tell you how many months it will take you to pay off the loan, as well as the total amount of interest paid over the life of the loan. Use a loop to calculate the amount…arrow_forward
- A driver will be fined P500 if his speed goes beyond 80 kph and P800 if it goes beyond 100 kph. Make a program that would input the car's SPEED and output his FINE. For example: Input Result 20 0.00 90 500.00 120 800.00arrow_forwardWrite a program that reads an integer and displays its first five multiples. For example, if the input integer is 10, the output should be as follows: 10, 20, 30, 40, 50.arrow_forwardA bullet train slows from a speed of 200 mi/hr to 150 mi/hr in one minute. Write a computer program that calculates the bullet train’s constant rate of acceleration and determines how long the bullet train will take to come to rest, given an initial speed of 200 mi/hr. (Hint: Use the equation a = vf - vi t where a is acceleration, t is time interval, vi is initial velocity, and vf is final velocity.) Write and call a function that displays instructions to the program user and a function that computes a, given t, vf, and vi. using c programming languagearrow_forward
- Write a program that reads a Celsius degree from the console and converts it to Fahrenheit and displays the result. The formula for the conversion is as follows:fahrenheit = (9 / 5) * celsius + 32arrow_forward. Write a program that generates and prints 50 random integers, each between 3 and 6. .Write a program that generates a random number, x, between 1 and 50, a random number y between 2 and 5, and computes x". .Write a program that generates a random number between 1 and 10 and prints your name that many times. .Write a program that generates a random decimal number between 1 and 10 with two decimal places of accuracy. Examples are 1.23, 3.45, 9.80, and 5.00.arrow_forwardAn instructor gives a series of exams during the semester in her math class. At the end of the semester she drops each student's lowest test score before averaging the scores. She has asked you to design a program that will read a student's test scores as input and calculate the average with the lowest score dropped. Here is the algorithm that you developed: Get the student's test scores. Calculate the total of the scores. Find the lowest score. Subtract the lowest score from the total. This gives the adjusted total. Divide the adjusted total by 1 less than the number of test scores. This is the adjusted average. Display the average. The test scores are in a text file named scores.txt and contains the following: Mickey, 71.0, 42.0, 83.0 Donald, 94.0, 73.0, 72.0, 81.0 Minnie, 95.0, 85.0, 45.0, 55.0, 65.0 A sample run is as follows: Enter a file containing floating point numbers: scores.txt Test scores for Mickey: ['71.0', '42.0', '83.0'] Removed the lowest score of 42.0 for Mickey The…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr