i need help making this C++ code.
Lab #2 Assignments: Numbers Class that translate whole dollar amounts in the range 0 through 9999 into an English description of the number.
Numbers Class
Design a class numbers that can be used to translate whole dollar amounts in the range 0 through 9999 into an English description of the number. For example, the number 713 would be translated into the string seven hundred thirteen, and 8203 would be translated into eight thousand two hundred three. The class should have a single integer member variable:
int number;
and a state array of string objects that specify how to translate key dollar amounts into the designed format. For example, you might use static strings such as
string lessthan20[20] = {"zero", "one", .........., "eighteen", "nineteen"};
string hundred = "hundred";
string thousand = "thousand";
The class should have a constructor that accepts a nonnegative 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 the main program that asks the user to enter a number in the proper range then prints out its English description.
REQUIREMENT:
1. Decomposition requirement report. Include your name in
the decomposition report file.
2. UML Diagram to show classes, member variables and member
functions (methods)
3. Source code for all the programs solutions
4. Screenshots for all the test cases to demonstrate a successful
completion of the project requirements
5. Test Data Listing for test cases
Given below is the code for the question. Please do rate the answer if it helped. Thank you.
#include <iostream>
using namespace std;
class Numbers{
private:
int num;
public:
Numbers(int n){
num = n;
}
void print(){
string
lessthan20[20] = {"zero", "one", "two", "three", "four", "five"
,"six" ,"seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen",
"fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
string
twentyPlus[] = {"", "", "twenty", "thirty", "fourty", "fifty",
"sixty", "seventy", "eighty", "ninety"};
string hundred =
"hundred";
string thousand
= "thousand";
int thousands =
num / 1000;
int hundreds =
(num % 1000) / 100;
int remaining =
num % 100;
if(thousands !=
0)
cout << lessthan20[thousands] << " "
<< thousand << " ";
if(hundreds !=
0)
cout << lessthan20[hundreds] << " "
<< hundred << " ";
if(remaining
< 20)
cout << lessthan20[remaining];
else{
int tens = remaining / 10;
int ones = remaining % 10;
cout << twentyPlus[tens] << "
";
if(ones != 0)
cout <<
lessthan20[ones];
}
cout <<
endl;
}
};
int main(){
int num;
cout << "Enter a number in the range 0-9999:
";
cin >> num;
Numbers n(num);
n.print();
return 0;
}
==================
output
============
Enter a number in the range 0-9999: 713
seven hundred thirteen
Enter a number in the range 0-9999: 8203
eight thousand two hundred three
i need help making this C++ code. Lab #2 Assignments: Numbers Class that translate whole dollar...
Using C++ Design a class called Numbers that can be used to translate integers in the range 0 to 9999 into an English description of the number. The class should have a single integer member variable: int number; and a static array of string objects that specify how to translate the number into the desired format. For example, you might use static string arrays such as: string lessThan20[20] = {"zero", "one", ..., "eighteen", "nineteen"}; string hundred = "hundred"; string thousand...
About Classes and OOP in C++ Part 1 Task 1: Create a class called Person, which has private data members for name, age, gender, and height. You MUST use this pointer when any of the member functions are using the member variables. Implement a constructor that initializes the strings with an empty string, characters with a null character and the numbers with zero. Create getters and setters for each member variable. Ensure that you identify correctly which member functions should...
I need help implementing 3 function prototypes with using operator overloading in a class. I have bolded the section I need help with since the cpp file is bigger than I expected. Any comments throughout would be extremely helpful. Time.cpp file #include "Time.h" #include #include #include // The class name is Time. This defines a class for keeping time in hours, minutes, and AM/PM indicator. // You should create 3 private member variables for this class. An integer variable for...
I need help implementing class string functions, any help would be appreciated, also any comments throughout would also be extremely helpful. Time.cpp file - #include "Time.h" #include <new> #include <string> #include <iostream> // The class name is Time. This defines a class for keeping time in hours, minutes, and AM/PM indicator. // You should create 3 private member variables for this class. An integer variable for the hours, // an integer variable for the minutes, and a char variable for...
Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of...
I need code in java
The Student class:
CODE IN JAVA:
Student.java file:
public class Student {
private String name;
private double gpa;
private int idNumber;
public Student() {
this.name = "";
this.gpa = 0;
this.idNumber = 0;
}
public Student(String name, double gpa, int
idNumber) {
this.name = name;
this.gpa = gpa;
this.idNumber = idNumber;
}
public Student(Student s)...
I need some help doing this Java project. 1.Implement the MySort class with the following operations. a.bubbleSort(MyArrayList arraylist) – conduct bubble sort on the elements contained in a MyArrayList object. b.selectionSort(MyArrayList arraylist) – conduct selection sort on the elements contained in a MyArrayList object. 2.Implement the MySearch class with the following operations. a.binarySearch(MyArrayList arraylist, Comparable target) – conduct binary search on sorted elements contained in a MyArrayList object. b.linearSearchSorted (MyArrayList arraylist, Comparable target) – conduct linear search on sorted elements...
Need help writing beginner C# program, I will make sure to
provide feedback to whoever can help me figure it out!
No public or global variables should be used. You need to
consider passing arguments between the methods according to the
ways described in the lecture. i.e. all variables should be
declared inside the methods and passed to other methods by
value/ref/out as needed
Description: We want to design a Date class to represent a date using three integer numbers...
I need java code...
Background Suppose you're working on the next great cligital assistant to compete with the likes of Siri, Cortana Alexa, and the lameless Google Assistant. An important part of your assistant is a text-10-speerlingine, You've managed to get your assistant to pronounce Englisli words, but you've hit a sag! The resistant is unable to pronounce numbers. When it sees 6243, it just says "six two four three insteud of the proper "six thousand two hundred forty three."...
I need help finding the error in my code for my Fill in the Blank (Making a Player Class) in C++. Everything looks good to me but it will not run. Please help... due in 24 hr. Problem As you write in your code, be sure to use appropriate comments to describe your work. After you have finished, test the code by compiling it and running the program, then turn in your finished source code. Currently, there is a test...