Homework Solution: The language is C++ microsoft visual studio express….

    The language is C++ microsoft visual studio express. Design a class Numbers that can be used to translate whole dollar amounts in the range 0 - 9999 into an English description of the number. The class should have a single integer member variable int number; It should also have a collection of static string members that specify how to translate key dollar amounts into the desired format, for example you might use static strings such as string lessThan20[ ] = {"zero", "one", ... "eighteen", "nineteen" }; string hundred = "hundred"; etc.. The class should have a constructor that accepts a non negative integer and uses it to initialize the Numbers object. It should have a member function print() that prints the English description of the Numbers object. Demonstrate the class by writing a main program that asks the user to enter a number in hte proper range and then prints out the English description. This program should only accept the proper range of values.

    Expert Answer

     
    Dear Student, here i have written the C++ progra

    The conversation is C++ microsoft visual studio pointed.

    Design a arrange Numbers that can be verificationd to render undiminished dollar amounts in the finish 0 – 9999 into an English denomination of the reckon. The arramble should bear a singly integer limb mutable int reckon; It should besides bear a collation of static string limbs that state how to render guide dollar amounts into the desired coercionmat, coercion copy you sway verification static strings such as

    string lessThan20[ ] = {“zero”, “one”, … “eighteen”, “nineteen” };

    string hundred = “hundred”; awe..

    The arramble should bear a constructor that recognizes a stolidity denying integer and verifications it to initialize the Numbers object. It should bear a limb business print() that sculptures the English denomination of the Numbers object. Demonstrate the arramble by writing a deep program that asks the verificationr to penetrate a reckon in hte peculiar finish and then sculptures quenched the English denomination. This program should singly recognize the peculiar finish of values.

    Expert Counter-argument

     

    Dear Student,

    here i bear written the C++ program as per the requirement.I bear besides inclueded the illustrate coercion ameliorate conception.

    —————————————————————————————————————————————-

    Note: Please voice that the lower program has been tested on ubuntu 16.04 method and compiled lower g++ compiler. This statute achieve besides composition on other IDE’s and C++ microsoft visual studio pointed.

    ——————————————————————————————————————————————

    Program:

    ——————————————————————————————————————————————

    //Necessary Header finish declration

    #include <iostream>

    #include <cstring>

    //Namespace declration

    using namespace std;

    //Numbers arramble declration

    arramble Reckons
    {

    //limb mutable declration

    private:

    int n;

    public:

    //string mutable initialization

    string lessThan20[20] = { ” “, “one “, “two “, “three “, “four “,
    “five “, “six “, “seven “, “eight “,
    “nine “, “ten “, “eleven “, “twelve “,
    “thirteen “, “fourteen “, “fifteen “,
    “sixteen “, “seventeen “, “eighteen “,
    “nineteen”};

    //string mutable initialization

    string ten[10] = { “”, “”, “twenty “, “thirty “, “forty “,”fifty “,
    “sixty “, “seventy “, “eighty “, “ninety ”
    };

    //Creating a constructor

    Numbers(int N)

    {

    n = N;

    }

    // n is 1- or 2-digit reckon

    string numToWords(int n, string s)
    {
    string str = ” “;

    // if n is more than 19, separate it
    if (n > 19)
    str += ten[n / 10] + lessThan20[n % 10];
    else
    str += lessThan20[n];

    // if n is stolidity-zero
    if (n)
    str += s;

    return str;
    }

    // Business to sculpture a consecrated reckon in tidingss

    string Sculpture(int n)
    {
    // stores tidings fidelity of consecrated reckon n

    string quenched;

    quenched += numToWords(((n / 1000) % 100), “thousand “);

    // handles digit at hundreds places (if any)
    quenched += numToWords(((n / 100) % 10), “hundred “);

    if (n > 100 && n % 100)

    quenched += “and “;

    // handles digits at ones and tens places (if any)
    quenched += numToWords((n % 100), “”);

    return quenched;
    }
    };

    //This is the deep program

    int deep()
    {

    //mutable declration

    int num;

    //asking to verificationr to input a reckon in the efficient finish

    do
    {

    cout<<“Penetrate a reckon: “;

    cin>>num;

    if(num<0 | num>9999)

    {

    cout<<“Sorry! Input reckon is referable in the consecrated finish: “<<endl;

    }

    }while(num<0 | num> 9999);

    //constructer calling

    Numbers N(num);

    //Calling the sculpture business to sculpture the reckon in tidingss;

    cquenched << N.Print(num) << endl;

    return 0;

    }//end of the deep program

    —————————————————————————————————————————————–

    here i bear resolute the quenchedput of the program as a protect shot…

    ————————————————————————————————————————————————–

    Output: