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...
Trending nowThis is a popular solution!
Chapter 15 Solutions
Problem Solving with C++ plus MyProgrammingLab with Pearson eText-- Access Card Package (9th Edition)
- answer shoul avoid using AI and should be basic and please explainarrow_forwardNode A is connected to node B by a 2000km fiber link having a bandwidth of 100Mbps. What is the total latency time (transmit + propagation) required to transmit a 4000 byte file using packets that include 1000 Bytes of data plus 40 Bytes of header.arrow_forwardanswer should avoid using AI and should be basic and explain pleasearrow_forward
- answer should avoid using AI (such as ChatGPT), do not any answer directly copied from AI would and explain codearrow_forwardanswer should avoid using AI (such as ChatGPT), do not any answer directly copied from AI would and explain codearrow_forwardWrite a c++ program that will count from 1 to 10 by 1. The default output should be: 1, 2, 3, 4, 5, 6 , 7, 8, 9, 10 There should be only a newline after the last number. Each number except the last should be followed by a comma and a space. To make your program more functional, you should parse command line arguments and change behavior based on their values. Argument Parameter Action -f, --first yes, an integer Change place you start counting -l, --last yes, an integer Change place you end counting -s, --skip optional, an integer, 1 if not specified Change the amount you add to the counter each iteration -h, —help none Print a help message including these instructions. -j, --joke none Tell a number based joke. So, if your program is called counter, counter -f 10 --last 4 --skip 2 should produce 10, 8, 6, 4 Please use the last supplied argument. If your code is called counter, counter -f 4 -f 5 -f 6 should count from 6. You should…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr