STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 3.7, Problem 3.22CP
Write cout statements with stream manipulators that perform the following:
A) Display the number 34.789 in a field of nine spaces with two decimal places of precision.
B) Display the number 7.0 in a field of five spaces with three decimal places of precision. The decimal point and any trailing zeroes should be displayed.
C) Display the number 5.789e+12 in fixed-point notation.
D) Display the number 67 left-justified in a field of seven spaces.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write code that performs the following input operations:
• Read an int from the keyboard and assign it to a variable named k. (Do
not print a prompt. Use the input() function without a prompt-string to
read the input.)
• Read a float from the keyboard and assign it to a variable named d.
(Do not print a prompt. Use the input() function without a prompt-
stringto read the input.)
• Read a string from the keyboard and assign it to a variable named s.
(Do not print a prompt. Use the input() function without a prompt-
string to read the input.)
After you have performed the input, on one line, print these variables in
reverse order (s followed by d, followed by k) with exactly one space in
between each. On a second line, print them in the original order (k followed by
d, followed by s) with one space in between them.
Write C code that calculates and prints the volumes of different shapes (Sphere and Frustum ). The program asks the user to read a character (ch). Every time ch is entered, the program does the following: - if ch is 's', then the program asks the user to enter a float (d) and prints the volume of the sphere. vol. Sphere - if ch is 'f', then the program asks the user to enter three floats (h, b ,and d) and prints the volume of the frustum. vol. Frustum -- Notes: - consider straight pi space equals space 3.14 - entered characters are case insensitive ( example: to quit you can enter q or Q) - entered floats should be strictly positive (zeros and negatives are not acceptable, and the user should be informed with a message (invalid number)). - if the user enters a value of ch other than the one specified, the program should print (invalid choice)
Write C code that calculates and prints the volumes of different shapes (Sphere and Frustum ). The program asks the user to read a character (ch). Every time ch is entered, the program does the following: - if ch is 's', then the program asks the user to enter a float (d) and prints the volume of the sphere. V = Id3 6. - if ch is 'f', then the program asks the user to enter three floats (h, b ,and d) and prints the volume of the frustum. V = IT h 12 Vdb +
Chapter 3 Solutions
STARTING OUT WITH C++ MPL
Ch. 3.1 - Prob. 3.1CPCh. 3.1 - What is the symbol called?Ch. 3.1 - Where does cin read its input from?Ch. 3.1 - Prob. 3.4CPCh. 3.1 - Assume value is an integer variable. If the user...Ch. 3.1 - A program has the following variable definitions....Ch. 3.1 - The following program will run, but the user will...Ch. 3.1 - Complete the following main function so that it...Ch. 3.2 - In each of the following cases, tell which...Ch. 3.2 - Complete the following table by writing the value...
Ch. 3.2 - Prob. 3.11CPCh. 3.2 - Study the following program code and then complete...Ch. 3.2 - Complete the following program skeleton so that it...Ch. 3.3 - Assume the following variable definitions: int a =...Ch. 3.3 - What will the following program code display if a...Ch. 3.3 - What will the following program code display? int...Ch. 3.5 - Prob. 3.17CPCh. 3.5 - Complete the following program code segment so...Ch. 3.6 - Write a multiple assignment statement that assigns...Ch. 3.6 - Write statements using combined assignment...Ch. 3.6 - What will the following program segment display?...Ch. 3.7 - Write cout statements with stream manipulators...Ch. 3.7 - The following program segment converts an angle in...Ch. 3.8 - Will the following string literal fit in the space...Ch. 3.8 - If a program contains the definition string name;...Ch. 3.8 - Prob. 3.26CPCh. 3.10 - Use a mathematical library function with a cout...Ch. 3.10 - Assume the variables angle1 and angle2 hold angles...Ch. 3.10 - To find the cube root (the third root) of a...Ch. 3.10 - Write a statement that produces a random number...Ch. 3 - Prob. 1RQECh. 3 - Prob. 2RQECh. 3 - Prob. 3RQECh. 3 - Assume the following variables are defined: int...Ch. 3 - What header files must be included in the...Ch. 3 - Prob. 6RQECh. 3 - Prob. 7RQECh. 3 - Complete the following table. Expression Value of...Ch. 3 - Write C++ expressions for the following algebraic...Ch. 3 - Assume a program has the following variable...Ch. 3 - Prob. 11RQECh. 3 - Assume that qty and salesReps are both integers....Ch. 3 - Rewrite the following variable definition so the...Ch. 3 - Complete the following table by writing statements...Ch. 3 - Write a multiple assignment statement that can be...Ch. 3 - Write a pair of multiple assignment statements...Ch. 3 - Replace the following statements with a single...Ch. 3 - Is the following code legal? Why or why not? const...Ch. 3 - Write a cout statement that uses stream...Ch. 3 - Write a cout statement that uses stream...Ch. 3 - What header file must be included A) to perform...Ch. 3 - Pet World offers a 15 percent discount to senior...Ch. 3 - A bowling alley is offering a prize to the bowler...Ch. 3 - A retail store grants its customers a maximum...Ch. 3 - Little Italy Pizza charges 14.95 for a 12-inch...Ch. 3 - Trace the following program segments and tell what...Ch. 3 - A) (Assume the user enters George Washington.)...Ch. 3 - Each of the following program segments has some...Ch. 3 - A) const int number1, number2, product; cout ...Ch. 3 - Soft Skills Often programmers work in teams with...Ch. 3 - Miles per Gallon Write a program that calculates a...Ch. 3 - Stadium Seating There are three searing categories...Ch. 3 - Housing Costs Write a program that asks the user...Ch. 3 - How Much Insurance? Many financial experts advise...Ch. 3 - Batting Average Write a program to find a baseball...Ch. 3 - Test Average Write a program that asks for five...Ch. 3 - Average Rainfall Write a program that calculates...Ch. 3 - Male and Female Percentages Write a program that...Ch. 3 - Vacation Days Write a program that prompts the...Ch. 3 - Box Office A movie theater only keeps 80 percent...Ch. 3 - How Many Widgets? The Yukon Widget Company...Ch. 3 - How many Calories? A bag of cookies holds 30...Ch. 3 - Ingredients Adjuster A cookie recipe calls for the...Ch. 3 - Celsius to Fahrenheit Write a program that...Ch. 3 - Currency Write a program that will convert U.S....Ch. 3 - Monthly Sales Tax A retail company muse file a...Ch. 3 - Property Tax Madison County collects property...Ch. 3 - Senior Citizen Property Tax Madison County...Ch. 3 - Math Tutor Write a program that can be used as a...Ch. 3 - Interest Earned Assuming there are no deposits...Ch. 3 - Monthly Payments The monthly payment on a loan may...Ch. 3 - Pizza Slices Joe's Pizza Palace needs a program to...Ch. 3 - How Many Pizzas? Modify the program you wrote in...Ch. 3 - Angle Calculator Write a program that asks the...Ch. 3 - Stock Transaction Program Last month Joe purchased...
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
- Design c++ code for below input. Screenshot and code is mustarrow_forwardWrite code that performs the following input operations: Read an int from the keyboard and assign it to a variable named k . (Do not print a prompt. Use the input() function without a prompt-string to read the input.) Read a float from the keyboard and assign it to a variable named d . (Do not print a prompt. Use the input() function without a prompt-string to read the input.) Read a string from the keyboard and assign it to a variable named s . (Do not print a prompt. Use the input() function without a prompt-string to read the input.) After you have performed the input, on one line, print these variables in reverse order ( s followed by d , followed by k ) with exactly one space in between each. On a second line, print them in the original order ( k followed by d , followed by s ) with one space in between them.arrow_forwardCreate a function that calculates the following mathematical expression: z = 3x + r +y* +em(x)arrow_forward
- Please do not give solution in image format thanku In C++arrow_forwardUsing c++ Basic student grade encoding program instructions: 1. Create a simple program that would let the user input a student's basic info and grades on 3 subjects. 2. The program should accept the following fields: - Full Name (should accept spaces for first and last name) - Year and Section (accept spaces as well) - Grade on 1st Subject (should accept numbers w/ decimals) - Grade on 2nd Subject (should accept numbers w/ decimals) - Grade on 3rd Subject (should accept numbers w/ decimals) 3. The Expected Output should: - Show all inputted information (same as expected output). - Then compute the average score from all of the inputted grade by adding all the grades and dividing the sum by 3. Store the value on a variable named aveGrade, it should be displayed with 2 decimals only. - And display the grade result based from the following criteria/conditions attached using else if statement 4. Make sure to test averaging if correct and all criteria/condition is set correctly.arrow_forward2. Create a function that will input 10 numbers and will perform the following 1. Display all even numbers 2. Display all the numbers 3. Display all odd numbers 4. Exitarrow_forward
- Function strlen() takes a string as an argument and returns the number of characters in the string, Which of the following is the correct answer to fill the above statement with it? Select one: a. Spaces are not included in the length calculation b. Null character is not included in the length calculation c. Numbers are not included in the length calculation d. Null character is included in the length calculationarrow_forward3. Intermediate CodeThe following statement is known:A = - A * (A + B ) - (B – C) / DPlrase make: c. Triplesarrow_forward(Numerical) Using the srand() and rand() C++ library functions, fill an array of 1000 floating-point numbers with random numbers that have been scaled to the range 1 to 100. Then determine and display the number of random numbers having values between 1 and 50 and the number having values greater than 50. What do you expect the output counts to be?arrow_forward
- 2. Test Scores File: test_scores.py Write pseudocode for the main() part of a program that asks the user to enter 4 test scores between 0 and 100, then displays a JCU grade for each score and also the average test score. When you have written the pseudocode for main, implement your solution in Python code and test it with a range of meaningful data. Remember that we've done the JCU grades question before, so copy your function from that practical code file. Sample Output Score: 3 Score: 50.5 Score: 66 Score: 100 Score 3.0, which is N Score 50.5, which is P Score 66.0, which is C Score 100.0, which is HD The average score was 54.875 Enhancements When you have that working... We asked for 4 scores. Have a look at your code... did you use 4 as a numeric literal or a constant?Change 4 to 3... Did you have to change the program in more than one place?If so, then you've missed one of the things we've taught...As a strong guideline: if you need to use the same literal more than once, you…arrow_forwardUse pythonarrow_forwardP3arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Algebraic Expressions – Algebra Basics; Author: TabletClass Math;https://www.youtube.com/watch?v=U-7nq7OG18s;License: Standard YouTube License, CC-BY
Python Tutorial for Beginners 3 - Basic Math, Mathematical Operators and Python Expressions; Author: ProgrammingKnowledge;https://www.youtube.com/watch?v=Os4gZUI1ZlM;License: Standard Youtube License