Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

objects that contain the values ' 0 ' . ' 0 ' BigDecimal ( String value ) - This constructor will parse the string,g taking

objects that contain the values '0'.'0'
BigDecimal(String value)- This constructor will parse the string,g taking each digit,
putting it into a new Cha,r and adding the Char to the container.
Your BigDecimal class should also contain the following mutators
void setValue(char ch)- A char that contains a digit
void setValue(String value)- This does the same as the overloaded constructor that
takes a string
BigDecimal add(BigDecimal)- Adds the values together and returns the result as a
Big Decimal
BigDecimal sub(BigDecimal)- Subtracts the two values and returns the result as a
BigDecimal
Note: If you are using C++, feel free to use the + operator instead of the add function.
I am going to let you off the hook for multiplying and dividing, but it should be easy to
implement.
Accessors
double toDouble()- Returns the value stored in the container as a double
String toString()- Returns the value store in the container as a string
Char at(int index )- Returns the value at the particular index as a Char
Caveat:
If you are using C++ your container must hold pointers to the Char type. This means
when you push something back, you need to do the following:
v.push_back(new Char('A');
Java you will use references but the principle is the same. Simpy add a new Char to
whatever container you are using.
al.add(new Char('A'));
Other requirement
Before adding anything to your container, you must determine if the value is actually a
digit. If it is not then simply stop processing characters at that point. You are also to
make sure that not more than one decimal is placed. Basically, I am asking you to have a
container that has a well-formed number
Step 3 File 10
Make a change to your BigDecimal class to add the following functions (methods)
int wholeNumber()- Returns only the whole number portion of the decimal
number as an int
double fraction()- Returns the fractional portion of the number as double
File IO
Attached at this link is a text file called Numbers.txt that contains several numbers.
You are to read in each of these numbers and store them in your BigDecimal class.
Basically you are going to need a BigDecimal class for each number that is in the file.
Store each BigDecimal in some kind of container like a vector or an ArrayList.
Once you have all of the numbers loaded use a loop to write out all of the numbers
into two separate text files. One file called wholeNumbers.txt will hold the whole
number portion of the number. The other file call fraction.txt will hold the fractional
portion of the number. Make sure you include the decimal point.
Open each of the files in Notepad and make sure that you have one number per line.
Step 4 Exceptions
Create an exception class called CharException to be thrown in the setChar function
that takes an int as a parameter. You should check the range of the int to make sure it is
a valid readable character. Basically if the parameter is less than 32 or greater than 127
you want to throw a CharException with the message "Invalid Character".
Java:
Use inheritance to extend your class from Exception. Create a constructor that takes
the message to be set. You are going to have to call the super constructor to make sure
the message is set properly. Use the getMessage method to display the error message
you set. Here is a code example that shows main and the output: AB
A In Hex: 41
A In Decimal 65
Try to set 140 as character
Invalid Character
Press any key to continue ...
Finally
Create a BigDecimalException class that is derived from the CharException class. You
should throw this exception anytime that a character is being set that is not a valid
character (a digit or a decimal). You should also throw this exception if more than one
decimal is being set.
At this point, I am not going to give you many specifics on how to implement this. I will
only say that you are to use inheritance. No matter how you implement this class,
please have good reasoning for doing so. It is time for all of us to start using what we
have learned to formulate our own ideas.
Important:
For this assignment I expect that you will use good coding practices. This means that
whenever possible you should create one code path. Having code duplications will be
frowned upon and may result in a point reduction in your grade.
Required
You must follow the style guide to the letter for all projects submitted for grading if you
have not read the style guide, it can be found here.
C++ please show me step by step I wanna learn I am new to this Also show me how to fill up i know how to create the files that are required like the char.h and the other ones they ask what I am having trouble with is filling them up with there right codes
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

List three benefits of using a to-do list.

Answered: 1 week ago

Question

=+ ^ What is the budget for this project?

Answered: 1 week ago

Question

=+What information is needed?

Answered: 1 week ago