Starting Out with C++: Early Objects
8th Edition
ISBN: 9780133360929
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 5, Problem 20PC
Triangle Display
Write a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Python
The month of February typically has28 days except when it is a leap year, in which case February has 29 days.Write a program that asks the user to enter a year. The program should then display the number of days in February that year. Use the following criteria to identify leap years:
The program shall loop back to ask the user to enter another year. The program shall NOT display the original display message explaining what the program does
If the user enters an invalid year, the program willdisplay an error message to the user and prompt for a year
If the user enters 0 or hits return for the year, then the program terminates
A for loop is a ______ loop.
Select one:
a. Limit-controlled
b. Function-controlled
c. Range-controlled
d. Count-controlled
Budget Analysis (Running Total)Write a program BudgetAnalysis.py) that asks the user to enter the amount of money that he or she has available to spend on electronics this year. A loop should then prompt the user to enter each of his or her expenses for electronics and keep a running total. When the loop finishes, the program should display the total amount that the user spent, and analyse if there is still money to buy more electronics.
Here are two test runs of the program:
Enter your available amount for electronics in 2020: 1500
Enter your expense (-1 for stop): 340
Enter your expense (-1 for stop): 450
Enter your expense (-1 for stop):
-1
So far you spent $ 790.0
You can buy more electronics.
>>>
========= RESTART: C: \Users \Rita \Desktop \Lab5-1 B BudgetA
Enter your available amount for electronics in 2020: 900
Enter your expense (-1 for stop): 730
Enter your expense (-1 for stop): 290
Enter your expense (-1 for stop):
-1
So far you spent $ 1020.0
No more electronics in…
Chapter 5 Solutions
Starting Out with C++: Early Objects
Ch. 5.1 - How many lines will each of the following while...Ch. 5.1 - Prob. 5.2CPCh. 5.3 - What will each of the following program segments...Ch. 5.5 - Prob. 5.4CPCh. 5.5 - Write a program segment with a do-while loop that...Ch. 5.5 - Revise your answer to Question 5.8 to use the...Ch. 5.6 - What three expressions appear inside the...Ch. 5.6 - You want to write a for loop that displays I love...Ch. 5.6 - Prob. 5.9CPCh. 5.6 - Write a for loop that displays your name 10 times.
Ch. 5.6 - Write a for loop that displays all of the odd...Ch. 5.6 - Write a for loop that displays every fifth number,...Ch. 5.8 - Prob. 5.13CPCh. 5.8 - Write a for loop that sums up the squares of the...Ch. 5.8 - Write a for loop that sums up the squares of the...Ch. 5.8 - Write a for loop that repeats seven times, asking...Ch. 5.8 - Write a for loop that calculates the total of the...Ch. 5.8 - Prob. 5.18CPCh. 5.8 - Write a sentinel-controlled while loop that...Ch. 5.11 - Which loop (while, do-while, or for) is best to...Ch. 5.11 - How many total stars will be displayed by each of...Ch. 5.11 - What will the following program segment display?...Ch. 5.12 - Prob. 5.23CPCh. 5.12 - What header file must be included in a program to...Ch. 5.12 - What five steps must be taken when a file is used...Ch. 5.12 - What is the difference between a text file and a...Ch. 5.12 - Prob. 5.27CPCh. 5.12 - What type of file stream object do you create if...Ch. 5.12 - What type of file stream object do you create if...Ch. 5.12 - Prob. 5.30CPCh. 5.12 - Assume you have an output file named numbers.txt...Ch. 5 - To _______ a value means to increase it by one.Ch. 5 - To _______ a value means to decrease it by one.Ch. 5 - Prob. 3RQECh. 5 - Prob. 4RQECh. 5 - The statement or block that is repeated is known...Ch. 5 - Each repetition of a loop is known as a(n)...Ch. 5 - A loop that evaluates its test expression before...Ch. 5 - A loop that evaluates its test expression after...Ch. 5 - A loop that does not have a way of stopping is...Ch. 5 - A(n) ______ is a variable that counts the number...Ch. 5 - Prob. 11RQECh. 5 - A(n) ________ is a variable that is initialized to...Ch. 5 - A(n) ______ is a special value that marks the end...Ch. 5 - The ________ loop is ideal for situations that...Ch. 5 - The _____ loop always iterates at least once.Ch. 5 - The _______and ______ loops will not iterate at...Ch. 5 - Inside the for loops parentheses, the first...Ch. 5 - A loop that is inside another is called a(n)...Ch. 5 - The _________ statement causes a loop to terminate...Ch. 5 - The _____ statement causes a loop to skip the...Ch. 5 - What header file do you need to include in a...Ch. 5 - What data type do you use when you want to create...Ch. 5 - What happens if you open an output file and the...Ch. 5 - What data type do you use when you want to create...Ch. 5 - What is a files read position? Where is the read...Ch. 5 - What should a program do when it is finished using...Ch. 5 - Write code that lets the user enter a number. The...Ch. 5 - Write a do-while loop that asks the user to enter...Ch. 5 - Write a for loop that displays the following set...Ch. 5 - Write a loop that asks the user to enter a number....Ch. 5 - Write a nested loop that displays the following...Ch. 5 - Write a nested loop that displays 10 rows of #...Ch. 5 - Rewrite the following code, converting the while...Ch. 5 - Rewrite the following code, replacing the do-while...Ch. 5 - Convert the following whi1e loop to a for loop:...Ch. 5 - Convert the following for loop to a while loop:...Ch. 5 - Prob. 37RQECh. 5 - Prob. 38RQECh. 5 - What will each of the following program segments...Ch. 5 - int x = 1 ; while (x 10) x++; cout x;Ch. 5 - Prob. 41RQECh. 5 - Prob. 42RQECh. 5 - Each of the program segments in this section has...Ch. 5 - A) // This code should use a loop to raise a...Ch. 5 - A) // This code should display the sum of two...Ch. 5 - Prob. 46RQECh. 5 - Characters for the ASCII Codes Write a program...Ch. 5 - Sum of Numbers Write a program that asks the user...Ch. 5 - Distance Traveled The distance a vehicle travels...Ch. 5 - Celsius to Fahrenheit Table In one of the Chapter...Ch. 5 - Prob. 5PCCh. 5 - Ocean Levels Assuming the level of the Earths...Ch. 5 - Pennies for Pay Write a program that calculates...Ch. 5 - Prob. 8PCCh. 5 - Prob. 9PCCh. 5 - Random Number Guessing Game Write a program that...Ch. 5 - Random Number Guessing Game Enhancement Enhance...Ch. 5 - The Greatest and Least of These Write a program...Ch. 5 - Prob. 13PCCh. 5 - Prob. 14PCCh. 5 - Population Write a program that will predict the...Ch. 5 - Math Tutor Version 3 This program started in...Ch. 5 - Hotel Suites Occupancy Write a program that...Ch. 5 - Rectangle Display Write a program that asks the...Ch. 5 - Diamond Display Write a program that uses nested...Ch. 5 - Triangle Display Write a program that uses nested...Ch. 5 - Arrowhead Display Write a program that uses nested...Ch. 5 - Sales Bar Chart Write a program that asks the user...Ch. 5 - Savings Account Balance Write a program that...Ch. 5 - Using FilesTotal and Average Rainfall Write a...Ch. 5 - Using FilesPopulation Bar Chart Write a program...Ch. 5 - Using FilesStudent Line Up Modify the Student...Ch. 5 - Using FilesSavings Account Balance Modification...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Describe the three types of anomalies that can arise in a table and the negative consequences of each.
Modern Database Management (12th Edition)
__________ languages are close to the level of humans in terms of readability.
Starting Out with C++ from Control Structures to Objects (8th Edition)
A contractor uses a blueprint to build a set of identical houses. Are classes analogous to the blueprint or the...
Starting Out with Java: Early Objects (6th Edition)
What two general capabilities does an object have?
Starting out with Visual C# (4th Edition)
What common programming language statement, in your opinion, is most detrimental to readability?
Concepts of Programming Languages (11th Edition)
Why is the study of database technology important?
Database Concepts (7th Edition)
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
- (Mathematical functions) Write a program that calculates and displays values for y when y=xz/(xz) Your program should calculate y for values of x ranging between 1 and 5 and values of z ranging between 2 and 6. The x variable should control the outer loop and be incremented in steps of 1, and z should be incremented in steps of 1. Your program should also display the message Function Undefined when the x and z values are equal.arrow_forward(Misc. application) Four experiments are performed, and each experiment has six test results. The results for each experiment are given in the following list. Write a program using a nested loop to compute and display the average of the test results for each experiment. 1stexperimentresults:23.23116.92725.428.62ndexperimentresults:34.845.227.936.833.439.43rdexperimentresults:19.416.810.220.818.913.44thexperimentresults:36.93949.245.142.750.6arrow_forward/*random number guessing game with while loopscreate a program (or adapt the guessing game program that's posted in moodlea couple of weeks ago) that asks the user to guess a random number between one and sixteen,and compares their guess with the computer's number.save this program as guessLoops.cppThe program should display one of four messages:if your guess is higher than the computer's number: "Your guess is too high."if your guess is lower than the computer's number: "Your guess is too low."if your guess is the same as the computer's number: "That is correct!"if your guess is less than one or greater than sixteen: "Invalid guess."If it's the last one, invalid guess, prompt the user, by using a loop, to guess again.If your guess is too high or too low, ask the user if they'd like to guess again (if theanswer is 'y' for yes, repeat the statements that asks for a guess.Then, repeat statement on line #6-#9 above.If the answer is 'n' for no (meaning the user doesn't want to guess…arrow_forward
- C++ programming Write a program that reads the grades of 3 students in three different courses and displays the average grade of each student in these three courses, as well as the average grade of all students. You can use any loop method of your preference. (Hint: This is a nested loop technique)arrow_forwardc++ looping and decision making Write a program that can be used by a student to help with basic math problems. The program should display a menu which allows the student to choose one of the following math problems: addition subtraction multiplication division – DO NOT allow division by 0. the final selection should let the user quit the program 1. The math problem selected should allow the student to enter the appropriate inputs and after they press the [Enter] key, the program should display the correct answer. 2. After the user has finished the math problem, the program should display the menu again. This process is repeated until the user chooses to quit the program. Input Validation: If the user selects an item not on the menu, display an error message and display the menu again.arrow_forwardC++Celsius to Fahrenheit Table. This program uses a for loop to display a Celsius to Fahrenheit temperature conversion table. Tips: Pretty headers not required but can be good practice FORMULA: fahrenheit = ((9.0/5.0) * celsius) + 32; FOR LOOP: for (int celsius = 0; celcius <= 3-; celsius++)arrow_forward
- C++ Programming: Instructions The program in Example 5-6 implements the Number Guessing Game. However, in that program, the user is given as many tries as needed to guess the correct number. Rewrite the program so that the user has no more than five tries to guess the correct number. Your program should print an appropriate message, such as “You win!” or “You lose!”. Code Given: //Flag-controlled while loop. //Number guessing game. #include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { int num; //variable to store the random number int guess; //variable to store the number guessed by the user bool isGuessed; //boolean variable to control the loop srand(time(0)); num = rand() % 100; isGuessed = false; while (!isGuessed) { cout << "Enter an integer greater" <<" than or equal to 0 and " <<"less than 100: "; cin >> guess; cout << endl; if (guess == num) { cout << "You win! " <<…arrow_forward02 Use for loops to construct a program that displays a shape of Xs on the screen. The shape should look like this: x x X x x x X x x x x x x x x x x x x X x x x xarrow_forwardJava coding platformarrow_forward
- c++ prob. paste indented codearrow_forwardExercise#1: Number Sequence Using nested loops, continue and break, write a program that prompts the user to input data for five students. Each student's data contains student first name and test scores. The program should accept positive integers only for test scores and ignore non-positive integers. Each student may has a different number of test scores; the program should receive input for test scores until input "0". Finally, the program outputs each student name with the sum of his/her marks. Sample Input/Output: Enter Student name: Khaled 65 78 -40 56 -25 89 0 The student 'Khaled' has the total marks = 288 Enter Student name: Kamal 37 55 44 -77 22 18 56 26 0 The student 'Kamal' has the total marks = 258 Enter Student name: Ali 66 33 87 66 87 -25 25 39 78 0 The student 'Ali' has the total marks = 481 Enter Student name: Taher 72 67 -33 0 The student 'Taher' has the total marks = 139 Enter Student name: Ahmed 75 68 84 -18 90 0 The student 'Ahmed' has the total marks = 317…arrow_forwardQ4: - Write visual Basic program using Do Until Loop to find the summation of student's marks, and it's average, assume the student have 8 marks. Use InputBox function to read marks.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
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,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Control Structures - while loop - do-while loop - for loop - Goto - break - continue statements; Author: EzEd Channel;https://www.youtube.com/watch?v=21l11_9Osd0;License: Standard YouTube License, CC-BY