Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134521176
Author: SAVITCH
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
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.

Blurred answer
Students have asked these similar questions
Which tool takes the 2 provided input datasets and produces the following output dataset? Input 1: Record First Last Output: 1 Enzo Cordova Record 2 Maggie Freelund Input 2: Record Frist Last MI ? First 1 Enzo Last MI Cordova [Null] 2 Maggie Freelund [Null] 3 Jason Wayans T. 4 Ruby Landry [Null] 1 Jason Wayans T. 5 Devonn Unger [Null] 2 Ruby Landry [Null] 6 Bradley Freelund [Null] 3 Devonn Unger [Null] 4 Bradley Freelund [Null] OA. Append Fields O B. Union OC. Join OD. Find Replace Clear selection
What are the similarities and differences between massively parallel processing systems and grid computing. with references
Modular Program Structure. Analysis of Structured Programming Examples. Ways to Reduce Coupling. Based on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsin⁡x Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning