Problem Solving with C++ Plus MyLab Programming with Pearson eText -- Access Card Package (10th Edition)
10th Edition
ISBN: 9780134710747
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 12, Problem 1PP
Program Plan Intro
Percentage Calculation
Program Plan:
ADT interface filename: “Percent.h”
- Include required header files.
- Define a class “Percent”.
- Declare function for overload operator “==” and “<”.
- Declare default constructor for “Percent” class.
- Declare a constructor for “Percent” class with one integer parameter.
- Declare function for input overload operator and output overload operator.
- Declare function for binary overload operators “+”, “-” and “*”.
- Declare a member variable “value”.
ADT implementation filename: “Percent.cpp”
- Include required header files.
- Define default constructor for “Percent” class.
- Here assign the value of “value” to “0”.
- Define constructor for “Percent” class with one integer parameter “percentValue”.
- In this constructor, assign “value” to “percentValue”.
- Define a function for overload operator “<”.
- This function is used to check whether the first percent is less than second percent or not.
- Define a function for overload operator “==”.
- This function is used to check whether the two percent’s are equal or not.
- Define a function for input operator “>>”.
- Define a function for input operator “<<”.
- Define a function for binary overload operator “+” to compute the sum of two percentages.
- In this function, create an object “sum”.
- Then compute the addition of two percent’s.
- Finally returns the result of addition.
- Define a function for binary overload operator “-” to compute the subtraction of two percentages.
- In this function, create an object “s”.
- Then compute the subtraction of two percent’s.
- Finally returns the result of subtraction.
- Define a function for binary overload operator “*” to compute the multiplication of one percent and an integer value.
- In this function, create an object “m”.
- Then compute the multiplication of one percent and an integer value.
- Finally returns the result of multiplication.
Application filename: “main.cpp”
- Include required header files.
- Define main function.
- Create two objects “percent1” and “percent2” from “Percent” class.
- Create an object “percent3” with one integer parameter “10”.
- Declare an integer variable “intValue”.
- Read the percentage 1 and percentage 2 from user.
- Check the two percentages using “==” operator.
- Check the two percentages using “<” operator.
- Create an object “sumPercent” from “Percent” class.
- Then compute and display sum of two percentages.
- Create an object “subPercent” from “Percent” class.
- Then compute and display difference of two percentages.
- Display percentage 3 from assigned value.
- Read an integer from user to multiply with a percentage 3.
- Finally compute and display the multiplication of “percent3” and a user entered integer value.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Can it be ignored if a Master File has information that will be there for quite some time?
In this post, we will be discussing file extensions as well as the programs that are responsible for their creation. The provision of examples is absolutely necessary.
is it possible to just join both files together and for it to compile correctly?
Chapter 12 Solutions
Problem Solving with C++ Plus MyLab Programming with Pearson eText -- Access Card Package (10th Edition)
Ch. 12.1 - Suppose that you are defining an ADT class and...Ch. 12.1 - Which of the following files has a name that ends...Ch. 12.1 - Prob. 3STECh. 12.1 - Suppose you define a class in separate files and...Ch. 12.1 - Suppose you want to change the implementation of...Ch. 12.1 - What is the difference between an ADT you define...Ch. 12.2 - Consider the program shown in Display 12.5. Could...Ch. 12.2 - In Self-Test Exercise 7, we saw that you could not...Ch. 12.2 - Prob. 9STECh. 12.2 - Prob. 10STE
Ch. 12.2 - Consider the following function declarations from...Ch. 12.2 - Would the program in Display 12.8 behave any...Ch. 12.2 - Prob. 13STECh. 12.2 - In Display 12.7 there are two groupings for the...Ch. 12 - Add the following member function to the ADT class...Ch. 12 - Prob. 3PCh. 12 - Redo Practice Programs 2 from Chapter 11, but this...Ch. 12 - This Practice Program explores how the unnamed...Ch. 12 - Prob. 1PPCh. 12 - Redo (or do for the first time) Programming...Ch. 12 - Prob. 3PP
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 difference between static and extern storage class ? give suitable example in support of your answer,arrow_forwardWrite a program to read two file names from the command line. If the number of arguments in the command line are more than or less than two, then the program should terminate with an appropriate error message. Otherwise, it should open the first file and copy its contents into the second file, in effect overwriting its contents, if any.arrow_forwardWhat other extended file properties are there besides "cannot be changed"?arrow_forward
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