C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 2, Problem 2PE
Program Plan Intro
Implementation of
Program Plan:
Write a C++ program with a main function and the required set of output statements using cout and >> operators inside the main function
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Question:
A country charges income tax as follows based on one's gross salary. No tax is charged on the
first 20% of salary. The remaining 80% is called taxable income. Tax is paid as follows:
10% on the first $15,000 of taxable income;
20% on the next $20,000 of taxable income;
25% on all taxable income in excess of $35,000;
Write a program to read a value for a person's salary and print the amount of tax to be paid in
dollars.
.
●
.
Additionalind.
What is the output of the statements below?
x=3
while x
Exercise 4:
Write a program that reads two pieces of information: the hourly wages and the number of hours worked by the employee.
The program should then calculate the net salary of the employee and display the results as shown in Figure 4. Note that:
the net salary of the employee is the sum of the basic wages (which is number of hours worked times the hourly wages)
minus the Social Security fees; where the Social Security fees represent 10% of the Basic wages.
Name your program Lab3_Id_ex4.py, where Id is your university Id. Include the design of your solution as comments at
the beginning of your program. Test your solution with different input data.
Please enter the employee hourly wages?
10
please enter the number of hours worked?
40
Basic Salary
Hourly
Wages
Number of
Social
Net Salary
Hours
Security
****
10.000
40.00
400.000
40.000
360.000
****
Figure 4: Exercise 4 Sample Run
Chapter 2 Solutions
C++ Programming: From Problem Analysis to Program Design
Ch. 2 - 1. Mark the following statements as true or...Ch. 2 - Prob. 2MCCh. 2 - Which of the following is not a reserved word in...Ch. 2 - Prob. 4SACh. 2 - 5. Are the identifiers quizNo1 and quiznol the...Ch. 2 - 6. Evaluate the following expressions. (3,...Ch. 2 - If int x = 10;, int y = 7;, double z = 4.5;, and...Ch. 2 - Prob. 8CPCh. 2 - 9. Suppose that x, y, z, and w are int variables....Ch. 2 - Prob. 10SA
Ch. 2 - Which of the following are valid C++ assignment...Ch. 2 - Write C++ statements that accomplish the...Ch. 2 - Write each of the following as a C++ expression....Ch. 2 - Prob. 14SACh. 2 - Suppose x, y, and z are int variables and wandt...Ch. 2 - 16. Suppose x, y, and z are int variables and x =...Ch. 2 - Suppose a and b are int variables, c is a double...Ch. 2 - 18. Write C++ statements that accomplish the...Ch. 2 - Which of the following are correct C++ statements?...Ch. 2 - Give meaningful identifiers for the following...Ch. 2 - 21. Write C++ statements to do the following....Ch. 2 - Prob. 22SACh. 2 - The following program has syntax errors. Correct...Ch. 2 - Prob. 24SACh. 2 - Prob. 25SACh. 2 - Preprocessor directives begin with which of the...Ch. 2 - 27. Write equivalent compound statements if...Ch. 2 - 28. Write the following compound statements as...Ch. 2 - 29. Suppose a, b, and c are int variables and a =...Ch. 2 - Suppose a, b, and sum are int variables and c is a...Ch. 2 - Prob. 31SACh. 2 - Prob. 32SACh. 2 - Prob. 33SACh. 2 - Prob. 34SACh. 2 - 1. Write a program that produces the following...Ch. 2 - Prob. 2PECh. 2 - Prob. 3PECh. 2 - 4. Repeat Programming Exercise 3 by declaring...Ch. 2 - Prob. 5PECh. 2 - Prob. 6PECh. 2 - 7. Write a program that prompts the user to input...Ch. 2 - Prob. 8PECh. 2 - 9. Write a program that prompts the user to enter...Ch. 2 - 10. Write a program that prompts the user to input...Ch. 2 - 11. Write a program that prompts the capacity, in...Ch. 2 - 12. Write a C++ program that prompts the user to...Ch. 2 - 13. To make a profit, a local store marks up the...Ch. 2 - 14. (Hard drive storage capacity) If you buy a 40...Ch. 2 - 15. Write a program to implement and test the...Ch. 2 - 16. A milk carton can hold 3.78 liters of milk....Ch. 2 - 17. Redo Programming Exercise 16 so that the user...Ch. 2 - Prob. 18PECh. 2 - 19. Write a program that prompts the user to input...Ch. 2 - 20. For each used car a salesperson sells, the...Ch. 2 - 21. Newton's law states that the force, , between...Ch. 2 - 22. One metric ton is approximately 2,205 pounds....Ch. 2 - 23. Cindy uses the services of a brokerage firm to...Ch. 2 - 24. A piece of wire is to be bent in the form of a...Ch. 2 - 25. Repeat Programming Exercise 24, but the wire...Ch. 2 - 26. A room has one door, two windows, and a...Ch. 2 - Prob. 27PECh. 2 - 28. In an elementary school, a mixture of equal...Ch. 2 - 29. A contractor orders, say, 30 cubic yards of...
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
- What is the output of the following code segment?inta=3,b=4;if(a==b);Write(X);Write(Y); X Y XY nothingarrow_forward[Using program 'Flowgorithm']: A gallon of paint covers 422 square feet and costs $29.85. Using flowgorithmdetermine and display the amount of paint it will take to paint a fence of aspecified height and length, the fence is solid not rails. Your program shouldperform the following tasks: Declare all required variables Declare constants and initialize them Prompt for the input of the fence height Prompt for the input of the fence length Calculate the total square feet to be painted Calculate the required number of gallons of paint required withoutusing a partial gallon of paint Display the total square feet to be painted,the number of gallons of paint needed and the total cost of the paint Ask if a second estimate needs to be made (keep program running until toldto stop)I have the basic steps complete, but am struggling to create a program which continues to run until told to stop. Suggestions on loop elements are hugely appreciated!arrow_forwardplease give the output of this programarrow_forward
- Please can you type and execute all four programs and give output for all the programs.arrow_forwardmake a flowchart for this problem:Create a program that swaps 2 numbers value.arrow_forwardWrite a wholly creative quiz program that consists of three original questions that you make up according to these specifications: One question should require user input of type int One question should require user input of type float One should require a string input The quiz should be scored by using a counter variable that has an initial value of zero and is incremented by one for every correct answer. Provide feedback to the user for each question, and report the total score when the quiz has finished. Example runs not shown. It's a creative exercise. def main():points = 0states = int(input('How many states in the USA? '))if states == 50:points +=1print('Correct. Good job!')else:print('Sorry, the answer is 50') points = 0capital = input('What is the capital of England? ')if capital == "London":points+=1print('Correct. Well done.')else:print('Sorry, the answer is London .') points = 0points = float(input('How many points does a pentagram have? '))if points == 10:points…arrow_forward
- -Write a program that asks the user to enter a person's age. The Problem 2: Age Classifier program should display a message indicating whether the person is an infant, a child, a teenager, or an adult. These are the guidelines: If the person is 1 year or less, he or she is an infant If the person is older than 1 year, but younger than 13 years, he or she is a child. If the person is at least 13 years old, but less than 20 years old, he or she is a teenager. If the person is at least 20 years old, he or she is an adult.arrow_forward2. Write a program that generates a number randomly by using rand ( ) function and user will have to guess that number. (Note: If the number is greater or smaller than user-entered number, your program should tell that the entered number is greater or smaller than computer-generated number and your program should terminate after correct number is guessed). sample program run is shown in the picture.arrow_forwardI need helparrow_forward
- Please write the code that meets the requirements in the picture.(Beginner Level Python)arrow_forwardPROBLEM: Write a program that prompts the user to input three positive angle values in degrees to determine which type of triangle it is (acute, right, obtuse). SPECIFICATIONS: - You may only use the codes that we studied under our lectures - All lines of codes should have a comment. - Save your cpp file as Surname - PE (Example: Pangaliman - PE.cpp) TEST CASES: If a user inputs three valid angle values: Enter the first angle in degrees: 60 Enter the second angle in degrees: 30 Enter the third angle in degrees: 90 Result: You have a right trianglel If a user inputs any negative angle values: Enter the first angle in degrees: 45arrow_forwardneed help!arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr