C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Question
Chapter 5.5, Problem 5E
Program Plan Intro
- DeclarepositiveCountand nagativeCountvariables of int type to count positive and negative.
- DeclarepositiveAvg and nagativeAvg variables of double type to determine average of positive and average of negative.
Program description:
Tomodify program 5.13 so that it displays the average of the positive and negative number.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(Bar-Chart Printing Program) One interesting application of computers is drawing graphsand bar charts. Write a program that reads five numbers (each between 1 and 30). For each numberread, your program should print a line containing that number of adjacent asterisks. For example,if your program reads the number seven, it should print *******.
Q3. (Dice Rolling) Write a program that simulates the rolling of two dice. The program
should use rand to roll the first die and should use rand again to roll the second die. The
sum of the two values should then be calculated. [Note: Each die can show an integer
value from 1 to 6, so the sum of the two values will vary from 2 to 12, with 7 being the
most frequent sum and 2 and 12 being the least frequent sums.] Figure 7.26 shows the 36
possible combinations of the two dice. Your program should roll the two dice 10,000
times. Use a one-dimensional array to tally the numbers of times each possible sum
appears. Print the results in a tabular format. Also, determine if the totals are reasonable
(i.e., there are six ways to roll a 7, so approximately one-sixth of all the rolls should be 7).
1
2
3
4
5
1
2
4
6
7
3
4
6
7
3
4
5
7
8
9
4
7
8
9
10
7
8
10
11
7
10
11
12
Row\Col
3.
(Rounding Numbers) Function floor can be used to round a number to a specific decimal place. The statementy = floor(x * 10 + 0.5) / 10;rounds x to the tenths position (the first position to the right of the decimal point). The statementy = floor(x * 100 + 0.5) / 100;rounds x to the hundredths position (the second position to the right of the decimal point). Write a program that defines fourfunctions to round a number x in various ways:A. roundToInteger(number)B. roundToTenths(number)C. roundToHundredths(number)D. roundToThousandths(number)For each value read, your program should print the original value, the number rounded to the nearest integer, the number rounded to the nearest tenth, the number rounded to the nearest hundredth and the number rounded to the nearest thousandth.
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
- (PYTHON) A nutritionist who works for a fitness club helps members by evaluating their diets. As part of her evaluation, she asks members for the number of fat grams and carbohydrate grams that they consumed in a day. Then, she calculates the number of calories that result from the fat, using the following formula: calories from fat = fat grams x 3.9 Next, she calculates the number of calories that result from the carbohydrates, using the following formula: calories from carbs = carb grams x 4 The nutritionist asks you to write a program on *PYTHON* that will make these calculations.arrow_forward(Guess the Number Modification) Modify the program of Exercise 5.32 to count the number of guesses the player makes. If the number is 10 or fewer, print Either you know the secret oryou got lucky! If the player guesses the number in 10 tries, then print Ahah! You know the secret!If the player makes more than 10 guesses, then print You should be able to do better! Why shouldit take no more than 10 guesses? Well, with each “good guess” the player should be able to eliminatehalf of the numbers. Now show why any number 1 to 1000 can be guessed in 10 or fewer tries.arrow_forward( MindTap - Cenage )Example 5-6 implements the Number Guessing Game program. If the guessed number is not correct, the program outputs a message indicating whether the guess is low or high. Modify the program as follows: Suppose that the variables num and guess are as declared in Example 5-6 and diff is an int variable. Let diff = the absolute value of (num - guess). If diff is 0, then guess is correct and the program outputs a message indicating that the user guessed the correct number. Suppose diff is not 0. Then the program outputs the message as follows: If diff is greater than or equal to 50, the program outputs the message indicating that the guess is very high (if guess is greater than num) or very low (if guess is less than num). If diff is greater than or equal to 30 and less than 50, the program outputs the message indicating that the guess is high (if guess is greater than num) or low (if guess is less than num). If diff is greater than or equal to 15 and less than 30, the…arrow_forward
- (Use DevC++) 1. Concert Tickets Sale and Charity Donation Program Design and implement a program that prompts the user to input the concert name, ticket price,number of tickets sold, and percentage of the gross amount to be donated to the charity. The sampleoutput is as shown below: Sample Output:**************************************************************************Concert Name: ………………………………..… The Concert at the ParkTicket Price: …………………………………..… P 49.75Number of Tickets Sold: ………………….…. 5,985 pcs.Gross Amount: ………………………………….. P 297, 753.75Percent of Gross Amount Donated: ……… 13.00%Amount Donated: …………………………..…. P 38, 707. 9875Net Sale: ………………………………………….. P 259, 045.7625************************************************************************** Note that the concert name such as “The Concert at the Park” must be declared as String. Input: Concert Name, Ticket Price, Number of Tickets Sold, and Percent of Gross Amount Donated Output: see sample output abovearrow_forward(Cost of driving) Write a program that prompts the user to enter the distance to drive, the fuel efficiency of the car in miles per gallon, and the price per gallon, and dis- plays the cost of the trip.arrow_forward(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: 6132450351503022244arrow_forward
- 4. (Looping statement) java Given an integer, display its reversed order. Sample Output: Enter n : 876 The reversed order of 876 is 678.arrow_forward(IN C LANGUAGE) Binary-Decimal / Decimal Binary . Between 0 and 255 a number will be decided randomly by computer. Then asks to user 3 times a random digit of binary value of the that number. If user enters wrong number for a digit program will select another random number and ask random times random digit. For example: Computer selected number as 163 ( Which is 10100011) What is the digit 2 (question 1/3) :User enter 1 CorrectWhat is the digit 4 (question 2/3) : User enter 0 CorrectWhat is the digit 7 (question 3/3) : User enter 0 CorrectUser finished the quest with 3 input .arrow_forward(python questions)arrow_forward
- (PYTHON) Write a program with a function that takes a string; if the length of a string is even, the functionshould add an asterisk at the beginning of a string; else, the function should add asterisks at the end ofa string. The function, then, capitalizes all letters and returns the new string The program should let the user enter a string and pass it to the function.arrow_forward(Rounding Numbers) Function floor may be used to round a number to a specific decimalplace. The statementy = floor(x * 10 + .5) / 10;rounds x to the tenths position (the first position to the right of the decimal point). The statementy = floor(x * 100 + .5) / 100;rounds x to the hundredths position (the second position to the right of the decimal point). Writea program that defines four functions to round a number x in various waysa) roundToInteger(number)b) roundToTenths(number)c) roundToHundreths(number)d) roundToThousandths(number)For each value read, your program should print the original value, the number rounded to thenearest integer, the number rounded to the nearest tenth, the number rounded to the nearest hundredth, and the number rounded to the nearest thousandth.arrow_forward(Geometry: area of a regular polygon) A regular polygon is an n-sided polygon in which all sides are of the same length and all angles have the same degree (i.e., the polygon is both equilateral and equiangular). The formula for computing the area of a regular polygon is n x s? Area 4 X tan Here, s is the length of a side. Write a program that prompts the user to enter the number of sides and their length of a regular polygon and displays its area. Here is a sample run:arrow_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
CPP Function Parameters | Returning Values from Functions | C++ Video Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=WqukJuBnLQU;License: Standard YouTube License, CC-BY