Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
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
Exercise 4: Selection and loop statements
A certain professor gives 5-point quizzes that are graded on the scale 5-A, 4-B, 3-C, 2-D, 1-
F, 0-F. Write a program that accepts a quiz score as an input and prints out the corresponding
grade.
The input data must be a float numbers and between 0 and 5
Example
Input :
Quiz score: 3
Output:
The grade is C.
Exercise 4
Write an improved version of the future value program from Chapter 2. Your program will
prompt the user for the amount of the investment, the annualized interest rate, and the number
of years of the investment. The program will then output a nicely formatted table that tracks
the value of the investment year by year. Your output might look something like this:
Operation: Operation
You have been cordially invited to partake in Operation: Operation. Your mission, should you choose to accept it, is to take the two numbers and the operator given then perform the operation successfully.
Input Format
A line containing a number, operator, and another number separated by a space.
Input Sample
5 + 0.70
Output Format
A line containing a decimal/float containing two decimal places.
Output Sample
5.70
Test Cases
1. Test Case 1
-Input
1.6 - 1.4
-Expected Output
0.20
2. Test Case 2
-Input
5 * 5
-Expected Output
25.00
3. Test Case 3
-Input
5 + 0.70
-Expected Output
5.70
Note: This is C programming. All test cases must be satisfied.
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-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.
Chapter 3 Solutions
Starting Out With C++: Early Objects (10th Edition)
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 - Write C++ expressions for the following algebraic...Ch. 3 - Assume a program has the following variable...Ch. 3 - Prob. 11RQECh. 3 - Write a multiple assignment statement that can be...Ch. 3 - Write a pair of multiple assignment statements...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 - 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 - How Much Insurance? Many financial experts advise...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 - 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 - 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...
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
- Create a function that calculates the following mathematical expression: z = 3x + r +y* +em(x)arrow_forwardProgram: Food receipt Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print('{:.2f}'.format(your_value)) (1) Prompt the user to input a food item name, price, and quantity. Output an itemized receipt. (Submit for 2 points) Enter food item name: hot dog Enter item price: 2.00 Enter item quantity: 5 RECEIPT 5 hot dog @ $2.00 = $10.00 Total cost: $10.00 (2) Extend the program to prompt the user for a second item. Output an itemized receipt. (Submit for 2 points, so 4 points total) (3) Extend again to output a third receipt that adds a mandatory 15% gratuity to the total cost. Output the total cost, the cost of gratuity, and the grand total. (Submit for 3 points, so 7 points total)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_forward
- 2. 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_forwarddef f(x: float) -> int: return int(x) def g(x: str) -> float: return float(x) y = f(g("3.14")) Select all of the following statements that are true: y's inferred data type is float O y 's inferred data type is str O y's inferred data type is int There is a type error in this program None of the above are truearrow_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. Complete the function avg5 to return the average of five numbers. Use the accumulator pattern. Don't change anything outside of avg5. Save & Run 10/4/2020, 1:04:36 PM - 13 of 13 3 def avg5(num1, num2, num3, num4, num5): '''Returns the average of its parameters' pass #This statement does nothing = you can remove it #Your code here to calculate the average 4 5 use the accumulator pattern 7 avgstart=num1 8 avg5=(avgstart+num2+num3+num4+num5)/5 return avg5 9. 10 11 12 13 14 15 print(avg5(10, 13, 15, 18, 25)) 16arrow_forwardzain IQ لا توجد خدمة docs.google.com Q Using switch write a program to insert two float numbers of and an arithmetic effect that refers to the calculations used(/,* ,- ,+) # includeusing namespace std; int main (){ float a , b ; char op; cout >a>>b; cout >op ;switch (op) {case '+' cout %3D <arrow_forwardUse pythonarrow_forwardP3arrow_forwarda*a; a*a*a; d = (a); fprintf('%4u square equals %4u \r', a, b) fprintf('%4u cube equals %4u \r', a, c) fprintf('The square root of %2u is %6.4f \r', a, d) b C =arrow_forwardQ5: A/ Use input function to write a computer programming to test the weather state according to a given temperature using the conditions helow : 1-x 30 hot weather. Choose one section from the following :arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_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