ECPI School Portfolio

Ted DeJong

Java II

PRG114 Programming II

This course used Java How to Program, 6th ed., by Harvey M. Deitel and Paul J. Deitel. It built upon experience in the previous Java programming class. I liked this course and enjoyed the assignments. In fact, I had a difficult time narrowing it down to what is listed here.

Please Note

All of my Java programs require that you have Java Virtual Machine installed on the computer you are using. Starting these programs is a little technical. Please click Help for more detail on this process and help setting up and using these project files.

VariableInterest

VariableInterest calculates compound-interest rates using loops to repeat the calculations for each year and to vary the interest rate in the calculations. I went on to tweak the precise format of the tables so that everything is very tidy.

The instructor wanted students to add an outer for loop, stepping through each rate.

The scenario for this problem is that a person invests $1,000 in a savings account with 5% interest. Assuming that all the interest is left on deposit, it calculates and prints the amount of money in the account at the end of each year for 10 years.

RoundHundredTest

My RoundHundredTest program will gather input and then run methods to calculate rounding to the nearest integer, tenth, hundredth, and thousandth.

The instructor wanted students to have a loop for multiple inputs using other figures from the text as models of method design.

For this problem, I was to write an application that defines 4 methods for rounding numbers: to the integer, the tenth, the hundredth, or the thousandth.

For each value, read my program needs to display the original value and each rounding.

RandomBullseyeTest

This program creates a set of 2 random colors. Then it uses the colors to draw ovals that represent a bullseye. It also uses window dimensions to base the size and position of the bullseye.

Notice that each time the window is resized or uncovered, the drawing method is called and it changes the image.

The instructions were to draw a bull's-eye that alternates between 2 random colors and use the constructor "Color( int r, int g, int b )" with random arguments to generate random colors.

RandomShapesTest

RandomShapesTest creates 10 randomly placed, sized, colored, and shaped objects in a window. The shapes coordinates are based on the window size, and none of the shapes are any larger than half the size of the window.

Notice that each time the window is resized or uncovered, the drawing method is called and it changes the image.

The assignment was to create a program that draws 10 random shapes in random colors and in random positions using a loop. Each iteration of the loop would determine if the shape is a rectangle or oval, what color it is, its location, and dimensions. The coordinates should be based on the window's dimensions. The height or width of each shape should be no more than half the size of the window.

ComissionsArray

ComissionsArray calculates employees' salaries based off of their weekly gross sales. It then keeps totals of how many employees earned different ranges of salaries and finally displays the results in a tabular format. Arrays are used to count the number of employees in each range and to help format the tabular output.

The instructor wanted students to map the amount to an index 2-10.

A company pays its salespeople on a commission basis and the salespeople receive at least $200 per week in addition to 9% of their sales for that week. For example, an employee with $5000 in gross sales in a week receives $200 plus 9% of $5000, or a total of $650.

DuplicateElimination

This application accepts 5 numbers, then determines which are duplicate entries, if any, and prints the set of unique numbers entered. Numbers that are duplicate are not displayed. The numbers must be between 10 and 100, inclusive. The complete set of unique values are displayed after each input. If a number outside of the 10 - 100 range is entered, the user is prompted on the correct input range and is allowed to try entering a value to that location again.

The instructor wanted students to try to init a 5 element array to zero.

Write an application that inputs 5 numbers, each of which is between 10 and 100, inclusive. After each input, display the numbers input, unless the number is duplicate. Use the smallest possible array to solve the problem. Display the complete set of unique values after each input.

FiveMaxMin

This application will accept exactly 5 integers from the command line, and then it prints the maximum number, the minimum number, and the average.

This means that when you run this program you include the integers along with the command as in:

java FiveMaxMin 5 456 23 6 12

RandNumGen

This application generates random numbers with values ranging from 1 to 50. It will generate as many numbers as the user specifies.

Write a program that requests a number from the user, then generates that many random numbers from 1 through 50, inclusive.

DrawPyramidTest

This one was not assigned to me. During lab time in class, when I wasn't working on a program, or helping another student when I was finished with my own program, I would have a little free time. In these rare moments, I would do other assignments in the textbook that I found interesting. DrawPyramidTest is one of them. What can I say, I really enjoyed this course.

Draws 15 fanning lines from each corner on a panel to form a pyramid. Image changes dynamically depending on the size of the window.

This called to use loops and control statements to create the design in Fig. 4.21 of the textbook. This design draws lines from each corner and the lines from opposite corners should intersect along the middle. The figure should scale accordingly as you resize the window.

Counter