You are on page 1of 4

Planning Sheet

Leenza Thompson and Lucas Veryzer

We are creating a calculator application. It will include some parts of a scientific calculator (but
not everything, as that may be too hard to do, and take forever to complete)
The buttons that we intend on including are:
- Numbers 0-9
o Should be able to create double digit numbers (or higher). Need to find a way that
the numbers will go together like this
o Code needs to link the button with the value (eg. Button that says 1 needs to have
the number 1 associated with it)
- Decimal point
o Needs to make all digits after the decimal button is pressed to appear as decimal
places
o Code needs to make the computer recognize that this is a double (has decimal
places) and act appropriately
- +, -, x,
o Need to find out how to code these math operations
o Find a way to take the first number inserted into the calculator and the do the
appropriate operation with the second number inserted
-
o Possibly an if statement could be used here. It could say if this button is pressed,
take whatever is in the display and turn it into a negative (or a positive if it is
already a negative)
-
o This button will display the value of pi. We could use the Math.Pi method to
obtain this value
- %
o Will be very similar to the divide button. All we have to do is take the number that
the person inputs and divide it by 100
- Sin, cos, tan (and inverse)
o This may be a tricky part. We need to find a way that will distinguish between
radian and degrees (and if we are overly ambitious grads)
o We will also need a way to determine whether the shift button has been pressed
and do the opposite if the shift button is pressed
o There are methods for this in the math api
- ! (factorial)
o This will use a while loop
o The function of this button is to take a number and multiply it by every number
below it until 1 is reached (ex. 5! = 5x4x3x2x1)
o This is discussed in more detail below
- Average button
o We could use a counter to see how many numbers have been entered

o This could also incorporate an arraylist or file I/O to store each value entered
o We may need an additional button that will add the number in the display into the
above mentioned arraylist (similar to the add contact button in our previous
assignment)
Backspace button
o This could include substring or we could create an array list and remove the last
element
o Need to find a way to delete more than one
o Could be challenging to erase both the number and the operation before it (if it is
required)
Brackets
o Need to find a way to include order of operations (do the brackets first)
o Probably need two buttons (close bracket and open bracket)
o Need to find a way that when this button is pressed, that an actual bracket is
shown in the display (probably setText = ( )
Shift button
o Use an if statement to see if the button is pressed
o Could use a toggle button instead of a normal button in Netbeans. This could be
so that the user can easily see if the button is pressed or not
o Could see if it is possible to change the text on a button when the shift button is
pressed. For example: the sine button when the shift button is not pressed the
button could have the text sin on it. When the shift button is pressed the text could
change to sin-1. If this is not possible we could just write the second function
above the button
Exponent
o From what we understand, there is no exponent method in java, so this will be
like the multiplication button
o The code will say something like take the first number and multiply it by itself the
number of times that is required (the second number). This could possibly be
accomplished by a for loop with the limit being the second number
Square root
o There is a method called sqrt (double a) in the math api. This will most likely be
used in the code for this button
1/x
o This code will be very similar to the division button code. All we will have to do
is take one and divide it by the number that the user inputs and display the answer
Memory buttons
o These buttons could be a bit tricky to code
o Need to have file I/O or an arraylist to store the values that the user wants stored
o We will also need a button/method that will recall these stored values
Log/ 10x or ln /e

o There are method in java including E, exp (double a), log10 (double a), and
log(double a) that will be useful for these buttons
Mod
o % operator
o Use similar code to the exercise we did in class to find prime numbers

There will be no additional classes that will be needed (at least we dont think so). All that will
be needed in the main class where we code what each button on the calculator does. If multiple
classes are a requirement, then perhaps we could create a class with methods and refer to those
methods throughout the main class.
Making a calculator will allow us to incorporate many things that we have learned over the
semester. These include:
Counters
This could be used to calculate the average of a set of numbers. The user
could enter a list of numbers and a counter could keep track of how many
numbers have been entered. Then the sum of the numbers entered could be
divided by the value of the counter
File I/O or
File I/O or arraylists could be used in the memory buttons. The previous
Arraylists
calculations that the person has done could be stored here and could be
accessed later. File I/O would be the better choice if we want the information
to still be there after the program closes. We could also have a screen like on
a graphing calculator that shows each calculation that the person has done.
We will need a text area for this, and will display that calculation that will be
stored in an arraylist
While/ for loops We could use a for or while loop (not sure which one yet, as they are very
similar and accomplish similar tasks) to calculate the factorial of a number.
We could start at the number that the user enters (the one they want to find
the factorial of). Then our while/for loop could subtract one from the value
and multiply the original value by the value subtract one. It could keep going
through this loop until one is reached
While or for loops could also be used in anything that has to be repeated over
and over, to simplify our code
Arraylists
We could also use an arraylist, or specifically the split method for proper
order of operations. If the user inputs a long multistep equation, we could
store it in an arraylist and then break it up and then find the operations that
need to be done first and do then before other operations that need to be done
later
If statements
We could use an if statement when determining the sine, cosine or tangent of
an angle. The if statement could be used to determine the answer based on
whether the person is in degrees or radians. We could say if it is in degrees,
solve the problem this way, or if it is in radians, do it another way.
We could also use an if statement for the shift button. This will allow for
more functions to be on the calculator without adding more buttons. We
could have code that says if the shift button isnt pressed, then do one
function (ex. Sin) but if the shift button is pressed, then do another function
(ex. Sin-1)

Srings/substring
s
Int / double

We could use strings and substring to make a backspace button. We could


make a substring that includes all of the numbers except for the last one and
work with that substring to find the answer without that last number
An integer or double could be used to hold the value of the number

http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Math.html#E (shows all methods in the


math api. This link will be very useful to us)
In the beginning of our coding, we will be designing how the calculator will look as well as get
the basic functions working together. After we are happy with that we will break off and each of
us will work on getting the different buttons and more complicated functions to work properly.
At this point we do not know who will be coding what, but will make this decision after we get
the basics implemented. However, we do know that each person will be responsible for exactly
half of the buttons.
We will most likely run into a few challenges while doing this project. Probably a big challenge
will be coding the math functions, such as trig functions and logarithms. We have not learned this
is class so it will require us to do some research. Another challenge we might face is putting
everything together into one working product. To make this as smooth as possible, we should
probably discuss name of variables and things like that before we break off separately. Finally,
another challenge we could face is actually getting it completed. This is a very busy time in the
semester and we will need to set goals during this project in order to finish on time. For example,
we could create due dates for ourselves within the project and say we will get a certain portion
of the project done by this day.

You might also like