Reference no: EM13938085
Complete and test this exercise. Implement the default constructor and the constructor with one int parameter. Overload the + and - operators to add and subtract percents. Also, overload the * operator to allow multiplication of a percent by an integer.
Write a program to test all the member functions and overloaded operators in your class definition.
#include <iostream>
using namespace std;
class Percent
{
public:
friend bool operator ==(const Percent& first, const Percent& second);
friend bool operator <(const Percent& first, const Percent& second);
Percent();
Percent(int percent_value);
friend istream& operator >>(istream& ins, Percent& the_object);
// Overloads the >> operator to input values of type
// Percent.
// Precondition: If ins is a file input stream, then ins
// has already been connected to a file.
friend ostream& operator <<(ostream& outs, const Percent& a_percent);
// Precondition: If ins is a file input stream, then ins
// has already been connected to a file.
friend ostream& operator <<(ostream& outs, const Percent& a_percent);
// Overloads the << operator for output values of type
// Percent.
// Precondition: If outs is a file output stream, then
// outs has already been connected to a file.
private:
int value;
};
// Uses iostream:
istream& operator >>(istream& ins, Percent& the_object)
{
char percent_sign;
ins >> the_object.value;
ins >> percent_sign; // Discards the % sign.
return ins;
}
// Uses iostream:
ostream& operator <<(ostream& outs, const Percent& a_percent)
{
outs << a_percent.value << '%';
return outs;
}
Attachment:- percent.zip
Technical requirements for specific business contexts
: demonstrate the capacity to communicate clearly with stakeholders a range of options that should be considered by a business in an online environment and the ability to apply appropriate structure and referencing formats
|
Prepare the amortization table using effective interest rate
: Thornwood Lanes bought a service vehicle for $25,000 by issuing a 6 percent installment note on December 31, 2009. Prepare the amortization table using the effective interest rate method.
|
How would animal life be affected by this atmospheric change
: How would the composition of the earth's atmosphere change if green plants and other autotrophs disappeared? Explain why in term of your knowledge of photosynthesis.
|
Excel file for further analysis
: Then after naming each test on the program, the test was executed. After the test was completed, the data obtained was exported to an excel file for further analysis.
|
Implement the default constructor with one parameter
: Complete and test this exercise. Implement the default constructor and the constructor with one int parameter. Overload the + and - operators to add and subtract percents. Also, overload the * operator to allow multiplication of a percent by an in..
|
Salvage value-what is the net present value of the asset
: Management is considering purchasing an asset for $50,000 that would have a useful life of 5 years and no salvage value. For tax purposes, the entire original cost of the asset would be depreciated over 5 years using the straight-line method. What is..
|
Reactions by giving the major products
: A solution containing 0.96 g of 2-bromooctane in 10 mL ether solution gave an observed rotation of -1.8° in a 10 cm cell at 20 °C. Calculate the specific rotation of this solution.
|
How much of the first payment is interest expense
: If the monthly payment is $2,571.53, how much of the first payment is interest expense and how much is principal repayment?
|
Capital structure weight of equity on market value basis
: Filer Manufacturing has 10.6 million shares of common stock outstanding. The current share price is $52, and the book value per share is $6. Filer Manufacturing also has two bond issues outstanding. What is Filer's capital structure weight of equity ..
|