Implement the default constructor with one parameter

Assignment Help C/C++ Programming
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

Reference no: EM13938085

Questions Cloud

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 ..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd