x.øi5nt face=”Times New Roman” size=”3″>Lookin for a little help to get this.

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Order a Similar Paper HERE Order a Different Paper HERE

x.øi5nt face=”Times New Roman” size=”3″>Lookin for a little help to get this to stay open. My little entry that normally works isn't working for this program. Andit looks like in that split second before the program closes, it is indicating the error for the illegal form of money.

Any ideas or help is appreciated as always.

Thanks in advance!

//
// Program defines and tests a Money class that will overload
// >, >=, >>, and
//

#include
#include
#include
using namespace std;

//Class for amounts of money in USD.
class Money
{
public:

friend bool operator >(const Money&amount1, const Money&amount2);
friend bool operator

friend bool operator >=(const Money&amount1, const Money&amount2);
friend bool operator

Money(long dollars, int cents);

Money(long dollars);

Money( );

Money percent(int percent_figure) const { return Money(0);};

friend istream&operator >>(istream&ins, Money&amount);
//Overloads >> operator in order to be used to input values of type Money.
//Notation for inputting negative amounts is as in -$100.00.
//Precondition: If ins is a file input stream, then ins has already been
//connected to a file.

friend ostream&operator
//Overloads
//Precedes each output value of type Money with a dollar sign.
//Precondition: If outs is a file output stream,
//then outs has already been connected to a file.

private:
long all_cents;
};

int digit_to_int(char c);
//Used in definition of overloaded input operator >>.
//Precondition: c is one of the digits '0' through '9'.
//Returns the integer for the digit; for example, digit_to_int('3') returns 3.

int main( )
{
Money amount1, amount2;
int percent;

//
// Get two money inputs from user to use for testing.
// Note that program will exit (from >>) if format is incorrect
//

cout
cout

cout
cin >> amount1;
cout
cin >> amount2;

//
// Test > and >=
//

if (amount1 > amount2)
cout << amount1 << " > ”
else if (amount1 >= amount2)
cout
else
cout

//
// Test percent
//

cout
cin >> percent;
cout
cout

}

//Uses iostream, cctype, cstdlib:
istream&operator >>(istream&ins, Money&amount)
{
char one_char, decimal_point,
digit1, digit2; //digits for the amount of cents
long dollars;
int cents;
bool negative;//set to true if input is negative.

ins >> one_char;
if (one_char == &#39;-&#39;)
{
negative = true;
ins >> one_char; //read &#39;$&#39;
}
else
negative = false;
//if input is legal, then one_char == &#39;$&#39;

ins >> dollars >> decimal_point >> digit1 >> digit2;

if ( one_char != &#39;$&#39; || decimal_point != &#39;.&#39;
|| !isdigit(digit1) || !isdigit(digit2) )
{
cout
exit(1);
}

cents = digit_to_int(digit1)*10 + digit_to_int(digit2);

amount.all_cents = dollars*100 + cents;
if (negative)
amount.all_cents = -amount.all_cents;

return ins;
}

int digit_to_int(char c)
{
return ( int(c) – int(&#39;0&#39;) );
}

//Uses cstdlib and iostream:
ostream&operator
{
long positive_cents, dollars, cents;
positive_cents = labs(amount.all_cents);
dollars = positive_cents/100;
cents = positive_cents%100;

if (amount.all_cents
outs
else
outs

if (cents
outs
outs

return outs;
}

Money::Money(long dollars, int cents)
{
if(dollars*cents
{
cout
exit(1);
}
all_cents = dollars*100 + cents;
}

Money::Money(long dollars) : all_cents(dollars*100)
{
//Purposely left blank.
}

Money::Money( ) : all_cents(0)
{
//Purposely left blank.
}

bool operator
{
return (amount1.all_cents
}

bool operator
{
return ((amount1.all_cents
}

bool operator > (const Money&ú mx.øi5nst Money&amount2)
{
return (amount1.all_cents > amount2.all_cents);
}

bool operator >= (const