COMP 14-090 Summer I 2000
Assignment 3: A Simple Calculator
Assigned: Tuesday, May 30
Due: Thursday, June 1
Worth: 45 points
Description
Write a program that implements a simple calculator. This calculator
should be able to add, subtract, multiply, and divide two numbers. It should
also be able to determine the minimum and maximum values given two numbers.
Use the SimpleCalculator class you developed in your groups on Tuesday. You
must use methods in solving this assignment. Prompt the user for two numbers,
then display the results of each operation to the user. The user interface
(i.e. what prompts you use and how you format the output) is up to you. The
only requirement is that the results of the operations should be rounded
to two decimal places.
What to Turn In
- A printout of your Java source code.
- A disk with your Java source code (SimpleCalculator.java) and bytecode
(SimpleCalculator.class).
- An image of the output window. Make sure you see "==> End of job" before
you capture the image. (You may include the output window image in the same
document as your memo instead of turning in a separate printout of the output
window.)
- A memo describing the problem and your solution of it. Include any
problems you encountered or comments you may have about the assignment. Also,
include an estimate of the total amount of time you spent working on this
assignment.
- Your disk should contain the following files:
- SimpleCalculator.java your Java source code
- SimpleCalculator.class your Java bytecode
Steps to Follow
- Follow the instructions in Getting Started with
Visual J++ under "Creating a New
Project." Use Assignment3 as your project name.
- Follow the instructions under "Adding
a New Class." Name your class SimpleCalculator.
- Enter or copy the text of the program outline from the course web page (SimpleCalculator.java under "Sample Code"). To copy from the web, bring up
the web page, select Select All from the Edit menu. Then select
Copy from the Edit menu. Then go back to the Visual J++ program
text window and select Select All from the Edit menu and then
select Paste from the Edit menu. That should put the program
text into your Visual J++ window.
- Fill in your name, program description, input, and output.
- Build and run your program to make sure you copied everything correctly.
It should just print out
"==> End of job" and wait for you to hit Enter.
- Replace the comments "// Insert your code here" with your code to solve
the problem given above.
- Save often!
Notes
- Test your program with various numbers as input. The program should
not crash or report errors when given valid numerical inputs.
- Don't forget to comment your program! If there are no
comments, you will lose at least 25% of the points.
- Don't forget to virus check and label your disk according to the
instructions in Turning in Assignments on Disk.
- Don't forget to sign the pledge on the printout of your source code.
- Extra credit will be given for programs that include a loop.
(This will only count if we go over loops on Wednesday.)
The following output window is just an example (including extra credit).
You don't have to use the same formatting. To get black text on a white
background, I pasted the captured image into the Paint program and inverted
the colors.
Michele Clark
clark@cs.unc.edu