WhatsApp
Hi there 👋
Struggling with Assignments?

Our experts can help you!
Get Quote

We are here to help.

Chat with our expert writers on WhatsApp

for any kind of assignment queries.

Click to chat!
Struggling with Assignments? WhatsApp Us
sample banner

188 Downloads

Question

It is a handy feature if a word processor can convert and display numbers in various formats. To mimic that feature, you are asked to write an application.

Answer

#include"Binary.h"
#include
#include
Binary::Binary() : Roman()
{
  int_to_Binary();
}
Binary::Binary(int n) : Roman(n)
{
  int_to_Binary();
}
void Binary::int_to_Binary()
{
  binary = bitset(get_number()).to_string();
}
string Binary::get_Binary_style()
{
  int_to_Binary();
  return binary;
}
#ifndef BINARY_H
#define BINARY_H
#include"roman.h"
class Binary : public Roman
{
  private:
  string binary;
  void int_to_Binary(); // converting int to string Roman Numeral
  public:
  Binary();
  Binary(int n);
  string get_Binary_style();
};
#endif
#include"Number.h"
#include
#include
#include
#include
#include
Number::Number()
{
  number = 0;
  int_to_EURO();
  int_to_US();
}
Number::Number(int n)
{
  number = n;
  int_to_US();
  int_to_EURO();
}
void Number::int_to_US()
{
  stringstream ss;
  ss.imbue(locale(""));
  ss << fixed << number;
  US = ss.str();
}
void Number::int_to_EURO()
{
  stringstream ss;
  ss.imbue(locale(""));
  ss << fixed << number;
  EURO = ss.str();
  replace(EURO.begin(), EURO.end(), ',', '.');
}
string Number::get_US_style() const
{
  return US;
}
// Returns int as a string in Euro style.
string Number::get_EURO_style() const
{
  return EURO;
}
// Returns the int.
int Number::get_number() const
{
  return number;
}
// Sets the value of int, US, and EURO.
void Number::set_number(int n)
{
  number = n;
  int_to_US();
  int_to_EURO();
}
#ifndef NUMBER_H
#define NUMBER_H
#include
using namespace std;
class Number
{
  public:
  // Default constructor without any initial value.
  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
Download Full Sample Here
HIRE EXPERT
Email ID *
Subject
Pages
Deadline