C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 5.2, Problem 6E
(Practice) An automobile travels at an average speed of 55 mph for 4 hours. Write a C++
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(C PROGRAMMING ONLY)
6. Deal or No Deal?by CodeChum Admin
When I was a kid, I used to watch this TV game show, Deal or No Deal? In the game, there are different brief cases, each labeled with a number. Inside each brief case is an amount in Pesos and the goal is to guess which briefcase contains the smallest amount.
In this program, instead of just finding the smallest amount, your task is to ask the user for an integer input and print the values in the array smaller than the inputted integer.
Instructions:
In the code editor, you are provided with an array with 100 elements.Your task is to ask the user for an integer input and then print all the elements in the array whose value is lesser than the inputted integer.Input
1. Inputted integer
Output
Enter value: 6132450351503022244
(C++ OOP)
We have a house with 3 rooms.We need the user to enter 1 integer as the window number, 2 doubles as depth and width of the room, 1 double as the useless area, 1 boolean as the door's opening direction (e.g. 0 is outward).Program will compute and print the air condition as a string and the total useful area of the house as a double.
Calculating the air condition: Name it air_c. Divide the useful area by the window number. If air_c >20, output "bad". If air_c <11 output "good". If 11<=air_c<=20, output "ideal".
Attention: If the window number is 0, air condition is bad.
Calculating the useful area of room: Width*Depth-(useless area)if the door is inward;Width*Depth-(useless area)-0.8The worst air condition of the 3 is the final air condition of house.
---
1)The information about the home must be all private within a class.2)The class must get these inputs within constructor func.3)Calculating the useful area of a room must be done within a function of a class.4)Air…
2.
(Guess the Number) Write a C program that plays the game of "guess the number" as fol-
lows: Your program chooses the number to be guessed by selecting an integer at random in the range
1 to 1000. The program then types:
5.32
I have a number between 1 and 1000.
Can you guess my number?
Please type your first guess.
The player then types a first guess. The program responds with one of the following:
1. Excellent! You guessed the number!
Would you like to play again (y or n)?
2. Too low. Try again.
3. Too high. Try again.
If the player's guess is incorrect, your program should loop until the player finally gets the number
right. Your program should keep telling the player Too high or Too low to help the player “zero in"
on the correct answer. [Note: The searching technique employed in this problem is called binary
search. We'll say more about this in the next problem.]
Chapter 5 Solutions
C++ for Engineers and Scientists
Ch. 5.1 - (For review) List the three repetition statements...Ch. 5.1 - Prob. 2ECh. 5.1 - (For review) a. What’s the difference between a...Ch. 5.2 - (Practice) Rewrite Program 5.1 to print the...Ch. 5.2 - (Practice) Rewrite Program 5.4 to produce a table...Ch. 5.2 - (Conversion) Write a C++ program that converts...Ch. 5.2 - (Practice) An automobile travels at an average...Ch. 5.2 - (Numerical analysis) a. The following is an...Ch. 5.2 - Prob. 9ECh. 5.3 - Prob. 1E
Ch. 5.3 - (Conversion) a. Write a C++ program to convert...Ch. 5.3 - (Misc. application) a. The data in the following...Ch. 5.4 - (Practice) Write a for statement for each of the...Ch. 5.4 - (Desk check) Determine the value in total after...Ch. 5.4 - Prob. 5ECh. 5.4 - (Conversion) Write a C++ program to convert...Ch. 5.5 - (cin within a loop) Write and run a C++ program...Ch. 5.5 - Prob. 4ECh. 5.5 - Prob. 5ECh. 5.5 - Prob. 7ECh. 5.5 - (Program) Write a program that tests the...Ch. 5.5 - Prob. 14ECh. 5.5 - (Program) Write a program to simulate the rolling...Ch. 5.6 - (Misc. application) Four experiments are...Ch. 5.6 - (Electrical eng.) a. An electrical manufacturer...Ch. 5.6 - (Mathematical functions) Write a program that...Ch. 5.6 - Prob. 6ECh. 5.7 - (Practice) a. Using a do statement, write a...Ch. 5.7 - (Misc. application) a. Write a program that...Ch. 5.7 - (Misc. application) a. Write a program to reverse...Ch. 5.7 - Numerical analysis) Given a number, n, and an...Ch. 5.7 - (Numerical analysis) Here’s a challenging problem...Ch. 5 - (Probability) The probability that a phone call...Ch. 5 - (Mechanics) The deflection at any point along the...Ch. 5 - (Physics) A golf ball is dropped from an airplane....
Knowledge Booster
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
- (C++) Question: Write a function string middle(string str)that returns a string containing the middle character in str if the length of str is odd, or the two middle characters if the length is even. For example, middle("middle") returns "dd". I'm not getting the correct output. What am I doing incorrectly?arrow_forwardInstructions(C++) A company hired 10 temporary workers who are paid hourly and you are given a data file that contains the last name of the employees, the number of hours each employee worked in a week, and the hourly pay rate of each employee. You are asked to write a program that computes each employee’s weekly pay and the average salary of all employees. The program then outputs the weekly pay of each employee, the average weekly pay, and the names of all the employees whose pay is greater than or equal to the average pay. If the number of hours worked in a week is more than 40, then the pay rate for the hours over 40 is 1.5 times the regular hourly rate. Use two parallel arrays: a one-dimensional array to store the names of all the employees (Name) a two-dimensional array of 10 rows and 3 columns to store the number of hours an employee worked in a week (Hrs Worked), the hourly pay rate (Pay Rate), and the weekly pay (Salary). Your program must contain at least the following…arrow_forward(C prog. language)arrow_forward
- (Drawing Patterns with Nested for Loops) Write a c++ program that uses for statements to print the following patterns separately, one below the other. Use for loops to generate the patterns. All asterisks (*) should be printed by a single statement of the form cout « '*'; (this causes the asterisks to print side by side). [Hint: The last two patterns require that each line begin with an appropriate number of blanks. Extra credit: Combine your code from the four separate problems into a single program that prints all four patterns side by side by making clever use of nested for loops.arrow_forward(use C++ program) Note: Write the defining diagram first, the solution (written either in pseudocode or flowchart) and the last one is the C++ program. 1. Write a program for asking for a quiz score. The program then will display a remark if FAILED or PASSED. The passing score is 50. 2. Write a program for comparing two input numbers if which of the two is greater.arrow_forward(Pass or fail) Write a c++ program that prompts a student to enter a score.If the score is greater or equal to 60, display “you pass the exam”; otherwise, display “you don’t pass the exam”.Your program ends with input -1.Here is a sample run:Enter your score: 80You pass the exam.Enter your score: 59You don’t pass the exam.Enter your score: -1No numbers are entered except 0arrow_forward
- ( C PROGRAMMING ONLY) 2. Solving a Person's Lonelinessby CodeChum Admin It's been 1,245 years and our sole Person is getting lonelier each day. This Person definitely needs a partner! Thus, we need to update our Person's design to have a gender as well and there shall be male and female! Instructions: In the code editor, you are provided with the definition of a struct Person. This struct needs an integer value for its age. Furthermore, you are provided with a displayPerson() function which accepts a struct Person as its parameter.Your task is to first update the struct Person so that it can have a gender as well. For this program, we shall represent a gender with a single character: 'M' for male and 'F' for female.Then, create a Person, take in an integer user input and a character user input, and then set them as the Person's age and gender respectively.Finally, call the displayPerson() function and pass that Person you created.Input 1. The age of the Person 2. The gender of…arrow_forward(use Python)Write if/else code that adds one to the variable adults if the value of age is greater or equal to 18, and adds one to the variable minors otherwise. For example: Test Result adults=3 minors=3 age=18 adults = 4 minors = 3arrow_forward(c++) Write a program that takes user input describing a playing card with the following shorthand: A = Ace 2...10 card values J = Jack Q = Queen, etc. D = Diamonds S = Spades. etc. Ex. if the user enters QS then your program responds with Queen of Spadesarrow_forward
- 1. (Functions with Loop and Branches) Write a C program that uses the function, PrintShampoo Instructions(), with int parameter numCycles, and void return type. If numCycles is less than 1, print "Too few.". Else If more than 4, print "Too many.". Else, print "N: Lather and rinse." for numCycles times, where N is the cycle number, followed by "Done.". End with a new line. [hint: use "for" loop from 1 to numCycles times to get desired display] Example output with input 0: Too few Example output with input 5: Too many Example output with input 4: 1: Lather and rinse. 2: Lather and rinse. 3: Lather and rinse. 4: Lather and rinse. Done. #include /* Your user-defined function goes here */ int main(void) { int user Cycles; scanf("%d", &userCycles); PrintShampoo Instructions (user Cycles); return 0; }arrow_forward(Don't copy) Write C++ program to find as many prime Fibonacci numbers as you can. It is unknown whether there are infinitely many of these. Find out the times taken to find first 10, 20, 30, 40…up to 200 and draw a graph and see the pattern.arrow_forward(C PROGRAMMING ONLY) 1. Dealing With Monthsby CodeChum Admin We're done dealing with days. It's time to step up and now deal with months! Instructions: In the code editor, you are provided with a code in the main() which has 12 printf's. Each printf prints a month with its corresponding value. For this program, January is 1, February is 2, March is 3, and so on. When you run the initial code, you will encounter errors because these month names that have been printed don't exist yet.Your task is to create an enum data type which contains these month names as values so that when we run the code, there will be no more error.Do not edit anything in the main(). Output January = 1February = 2March = 3April = 4May = 5June = 6July = 7August = 8September = 9October = 10November = 11December = 12arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Boolean Algebra - Digital Logic and Logic Families - Industrial Electronics; Author: Ekeeda;https://www.youtube.com/watch?v=u7XnJos-_Hs;License: Standard YouTube License, CC-BY
Boolean Algebra 1 – The Laws of Boolean Algebra; Author: Computer Science;https://www.youtube.com/watch?v=EPJf4owqwdA;License: Standard Youtube License