Comp 151 Project 2

Using Arithmetic and basic Java I/O


You will use your knowledge of Arithmetic and reading from and writing to the command line in Java that you learned from lecture and from chapter 2 and apply them to this simple lab.

This lab is long enough that many of you will have to work on it for a couple of iterations so I encourage you to start early.

Due: Mon Feb 14th at 11:59pm


Create a new project in eclipse as a before. Name this one again using your first initial and last name and then Lab2. So mine would be jsantoreLab2

Again add a new class to your project in eclipse. Call this class Lab2

Your class should do the following. (your main job is to figure our how to write the code to do this.) I encourage you to look at code listing 2-27 on pages 89-90 of your book ( from the Chapter 02 folder in the sourcecode from the cd in the back of you book). This program is quite similar, though not exactly the same and the one you will do.

This lab will be a simple tip calculator for a customer with three tips to pay.

Hint: you will need at least 7 unique variables for this lab, one for the name, then one for each class's credits (for a total of three more) and one the grade points for each class(three classes so you need three more here)

your design might also need an eight variable for the output string.

An example run on the program might look like this: (program output is in black, user input is in blue)

How much is your first bill: 43.75
What percent tip do you want for that bill?: 10
How much is your second bill: 25
What percent tip do you want for that bill?: 15
How much is your third bill: 50
What percent tip do you want for that bill?: 20

The $43.75 bill has a tip of $4.375
The $25 bill has a tip of $3.75
The $50 bill has a tip of $10
Your total tip is $18.125

If you are using as a guide for this project as I suggested earlier, be aware that this project is slightly longer than that one. Expect to have anywhere from 1.5 to 2 times the code of that project.

Don't worry about having only two digits after the decimal point. If you've done Java before and know how to do it, then great, if you have not just get the input/output and math working.


again zip up your project folder and submit it to me by email. Make sure that your submitted zip file contains your first initial and last name as part of the zip file name.

Include your name somewhere in your java file in a comment.