Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Please Programming Task 1, CS110 Review, 50 points We've all heard that the odds in gambling are always in the favor of the casino.

Java Please

image text in transcribedimage text in transcribedimage text in transcribed

Programming Task 1, CS110 Review, 50 points We've all heard that the odds in gambling are always in the favor of the casino. But is it true? And what does that mean? For this programming task, you'll apply many of the concepts that you have learned in CS110, to "simulate playing 3000 slot machines, and you'll tally how many of them result in a win. If you are not familiar with slots, they are machines with three or more reels which spin when a button is pushed (Figure 1a). The reels have numbers or pictures of fruits written/drawn on them, and the goal is to have the reels spin, and stop, such that at least one of the 3 visible rows of numbers among the three reels are the same. For this homework problem, you will simulate a slot machine by writing a class, Slot Machine, that has 3 fields that are arrays of three integers (Figure 1b). Your class Slot Ma- chine should have a method gambleMachine, which uses the Random class to generate random num- bers and place them into the three arrays. The method is Winner will determine if any of the three arrays have three identical entries (a winning play is shown in figure 1c). SLOT MACHINE 1 5 8 2 4 9 3 3 4 1 5 8 6 8 9 4 4 la. A slot machine 1b. Three arrays representing the three visible rows for three reels lc. Three arrays, the bottom of which is a "winner." To start, create twojava files, Slot Machine.java and Play3000Slot Machines.java, in the IDE of your choice. Slot Machine is the class whose UML diagram is shown below. Each of the fields rowl, row2, and row 3 should be an array that contains three integers. The non-default constructor should invoke the gamble Machine method. Slot Machine -rowl : int[] - row 2 : int[] - row 3 : int[] + Slot Machine () + gambleMachine () + isWinner() : boolean : void The file Play3000Slot Machines.java should contain a main method that creates an array of 3000 items, each an instantiated object of type Slot Machine. Use a for-loop in your main method to create each of the 3000 slot machines. Designate a counter variable to tally how many of the 3000 slot machines are "winners. The last thing that your main method should do is print to the screen the number of winning slot machines. For example: From 3000 slot machines, 25 were winners This first programming task is meant to be a review. If you find yourself writing extensive code, then stop, and ask for help. The SlotMachine class file can be written so that it has fewer than 50 lines of code, and the file Play3000SlotMachines.java can be written in fewer than 20 lines of code (excluding comments) Check the rubric at the bottom of this assignment to see a breakdown of the points for the first pro- gramming task. Programming Task 2, Static Class Members - 50 points Complete the first programming challenge, Area Class: Write a class that has three overloaded static methods for calculating the areas of the following geometric shapes: . circles rectangles cylinders Here are the formulas for calculating the area of the shapes. Area of a circle: where it is Math.PI and r is the circle's radius Area = ar2 Area of a rectangle: Area = Width x Length Area of a cylinder: Area= 27tr2 + 2trh where it is Math.PI,r is the radius of the cylinder's base, and h is the cylinder's height Because the three methods are to be overloaded, they should each have the same name, but dif- ferent parameter lists. Demonstrate the class in a complete program. In your main routine, you must invoke the static methods in the Area class. Do not create an in- stance of type Area. As with the first programming portion of this homework, this programming task should help you get back into the habit of coding, especially if it's been a while since you completed CS110. Note that the class file can be written in fewer than 30 lines (excluding comments), and the java file with the main method can be written with fewer than 20 lines. In your program where you use the methods of the Area class, also write to the screen the areas that are computed using the static methods. For example: The area of a circle with a radius of 20.0 is 1256.64 The area of a rectangle with a length of 10 and width of 30 is 300.00 The area of a cylinder with radius 10.0 and height 15.0 is 1570.80 Rubric Programming Task 1: Main method contains array of 3000 slot machines Slot Machine class Good Variable Names Adequate Comments/ Indenting Program Compiles Correct Output 10 10 5 5 10 10 Programming Task 2: Area.java has 3 overloaded static methods Program.java invokes Area's static methods Good Variable Names Adequate Comments /Indenting Program Compiles Correct Output 10 10 5 5 10 10 Total 100

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions