java program

profileajaytiwari
CMPS161Assignment1.pdf

CMPS 161

Fall 2017

Programming Assignment 1

“Drunken” Calculator

DUE OCT 16TH BY 11:59 PM

Your assignment is to create the drunken calculator. This calculator has been on the sauce for a bit too

long and has some trouble remembering things at times, but can still do his operations correctly. For

this assignment, we will only be covering the basic mathematical operations of addition, subtraction,

multiplication, division. See the full write up and sample output for more details below.

Must Haves:

1. Comments: Both at the top of the program that include your name, class, section, date, and a

short description of the program and what it does and in-line comments at any point you feel is

necessary.

2. Good Writing Style: Remember the programming style notes and tips we took during class? Put

them into practice here with proper indentations, spacing, line breaks, etc.

3. Make sure to name your class DrunkenCalculator.

4. The calculator does “forget” one user input, but you must still take in two. Which you forget is

up to you.

5. You must make use of the Math.random() function to generate the second “forgotten” input.

We looked at how to use the API, all functions are now fair game. I said the calculator is

forgetful, so he just comes up with a random number between 0 and 90 for the replacement.

6. Use of the if, else if, else statements to take care of all the cases of input. Assign each operation

a number (For example “for addition enter a 1”) and that should make it easier for the boolean

tests we have gone over.

7. Include a case for doing nothing and just exiting, this shouldn’t be within your “catch all”.

8. Your program doesn’t have to repeat operation, it can just terminate after one operation for

this assignment.

Submission:

Submit ONLY your .java file on Moodle to the assignment when you are completely finished.

Make sure your program compiles and runs to completion on all operations before submitting it. If you

have any questions before submission, please ask in class or in email to me.

Sample Output:

Program Start(Note the colored numbers are input from the user):

Woold you like to calcumulate somethin? *hic*

Enter a 1 for additon, 2 for subtraction, 3 for multiplication, 4 for division, or 0 to leave:

1

Whaaat too numbersssss would you like to add? Lemme have the first number now.

52

WHOA slow down, a 52 what’s the other one?

10

Alrighty! Then your answer is... umm... 60! Cause your first number was 52 and your second

number was 8.

What do you mean tha second numbers not right? I'm the calculator here an you told it to meh!

Get out!

