I am have some issues trying to get this code to work. Im not sure what Im doing wrong. the program is suppose create objects one, two & three under the class Number. assign a value and then display it in integer, us style and eruo style.
(us and euro stlye is the integer converted to string and add punctuation 3 positions in from the end. ( , for US and . for EURO
Header (content between curly brases has been provided and cannot be changed.
# ifndef number_H
#define number_H
#include <string>
#include <sstream>
#include <iostream>
usingnamespace std;
class Number {
public:
// Default constructor without any initial value.
// Initial value will be set to 0.
// Value of integer is 0.
// Value of US is “0”.
// Value of EURO is “0”.
Number();
// Constructor with initial value.
Number(int);
// Returns int as a string in US style.
string get_US_style()const;
// Returns int as a string in Euro style.
string get_EURO_style()const;
// Returns the int.
int get_number()const;
// Sets the value of int, US, and EURO.
void set_number(int);
private:
// A decimal number less than 4000.
int number;
// A string represent number in US style.
string US;
// A string representing number in EURO style.
string EURO;
// converting int to string in US style
void int_to_US();
// converting int to string in EURO style
void int_to_EURO();
};
#endif
#include <string>
#include <sstream>
#include <iostream>
#include "number.h"
usingnamespace std;
int Number::Number(int);
string EURO;
string US;
int Number::number()
{
set_number(0);
number(get_number)
return 0;
}
// convert number to US Style
string Number::get_US_style() {
return US;
}
// convert number to EURO style.
string Number::get_EURO_style () const
{
return EURO;
}
int Number::get_numner() const
{
return number;
}
//
void Number::set_number (int a) {
number = a;
return 0;
}
//************************************** Private Functions
void int_to_EURO
// convert number to string.
stringstream b;
b << number << endl;
EURO = b.str();
//determine if string length needs punctuation and where to put it.
int point = 0;
if (EURO.length > 3)
{
ponit = EURO.length - 3;
}
if (point > 1)
{
EURO.insert(point,1,'.');
void int_to_US()
// convert number to string.
stringstream b;
b << number << endl;
US =b.str();
//determine if string length needs punctuation and where to put it.
int point = 0;
if (US.length > 3)
{
ponit = US.length - 3;
}
if (point > 1)
{
US.insert(point,1,',');
}