Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
Expert Solution & Answer
Book Icon
Chapter 15.3, Problem 11STE

Explanation of Solution

Program:

File name: sale.h

//include libraries

#ifndef SALE_H

#define SALE_H

#include <iostream>

using namespace std;

//using the namespace

namespace salesavitch

{

    //create a class

    class Sale

    {

        //define access specifier

        public:

        //declare the constructors

        Sale();

        Sale(double thePrice);

        //define required methods

        double bill() const;

        double savings(const Sale& other) const;

        //define access specifier

        protected:

        //declare required variables

        double price;

    };

    //define an overloaded method

    bool operator <(const Sale& first, const Sale&

  second);

}

#endif // SALE_H

File name: discount.h

//include libraries

#ifndef DISCOUNTSALE_H

#define DISCOUNTSALE_H

#include "sale.h"

//using the namespace

namespace salesavitch

{

    //create a class

    class DiscountSale : public Sale

    {

        //define access specifier

        public:

        //declare the constructors

        DiscountSale();

        DiscountSale(double the_price, double the_discount);

        //Discount is expressed as a percent of the price.

        virtual double bill() const;

        //define access specifier

        protected:

        //declare required variable

        double discount;

    };

}

#endif //DISCOUNTSALE_H

File name: sale.cpp

//include libraries

#include "sale.h"

//using the namespace

namespace salesavitch

{

    //define a constructor

  Sale::Sale() : price(0)

  {}

    //define a constructor

  Sale::Sale(double the_price) : price(the_price)

  {}

    //declare a method

  double Sale::bill() const

  {

        //return statement

  return price;

  }

    //declare a method

  double Sale::savings(const Sale& other) const

  {

        //return statement

  return ( bill() - other...

Blurred answer
Students have asked these similar questions
First, you need to design, code in Java, test and document a base class, Student. The Student class will have the following information, and all of these should be defined as Private: A. A first name (given name)B. A last name (family name/surname)C. Student number (ID) – an integer number (of type long)D. A date of birth (in day/month/year format – three integers) - (Create your own Date class, the Date class should be a separate class from this. Do NOT use the Date class from JAVA.)The Student class will have at least the following constructors and methods:(i) two constructors - one without any parameters (the default constructor), and one with parameters to give initial values to all the instance variables of Student. (ii) only necessary set and get methods for a valid class design. (iii) a reportGrade method, which you have nothing to report here, you can just print to the screen a message “There is no grade here.”. This method will be overridden in the respective child…
A. Writing an Interface In this problem you will first write an interface and then modify classes to implement the interface. Write an interface, GeometricSolid, which has one method, volume. The volume method takes no arguments and returns a double. You are provided with three classes: Cylinder, Sphere, and RightCircularCone Modify the classes so that they implement the GeometricSolid interface. Supply the appropriate method for each class. You can use Google search to find the formula for the volume. Make sure that you use Math.PI in your calculations. Notice in InterfaceRunner that the objects are added to an ArrayList of GeometricSolids. since I couldn't fit all images with two screen shots I left the link here link: https://codecheck.it/files/18040616319p6jy6gzkdzuq08nmlp81251t
Write a Java application for the Banking system that consists of at least three classes for Bank, Clients and Transactions. The program should be fully documented, and the following concepts should be applied: 1. Defining a constructor with and without arguments.2. Use the setter, getter and toString methods. 3. Sending an object/s to a method and returning it as a return value.4. Defining array of objects and using loop/s and Scanner object/s for data entry.5. Defining the main method that integrates the whole project.

Chapter 15 Solutions

Problem Solving with C++ (10th Edition)

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education