So I have a final coming up and she gave us a practice test and there are two programming questions that I need help with. The first is
MyArray Class (You can either use an array or an arrayList)
Create a class called LastNameFirstNameMyArray according to the UML diagram. This class will allow a user to enter 5 integer values into an array(or object of ArrayList<Integer>). It contains methods to find min and max values and calculate the mean for the data set.
LastNameFirstNameMyArray - data[ ] : int (or data : ArrayList<Integer> )
- min : int
- max: int
- mean : double + LastNameFirstNameMyArray()
+ findMin() : void
+ findMax() : void
+ calculateMean(): void
+ toString() : String
Attributes:
• data[]—the array which will contain the values
or data<Integer>—the arraylist which will contain the values
• min—the minimum value among the values in the arraylist
• max—the maximum value among the values in the arraylist
• mean—the arithmetic average of the values
Methods:
You need to implement the constructor LastNameFirstNameMyArray(), which populates 5 values. In addition, the constructor should call findMin() and findMax(), and also calculateMean().
Methods:
• LastNameFirstNameMyArray()—the constructor. It will allocate memory for the array (or arraylist) of size 5. Use a for loop to repeatedly display a prompt for the user which should indicate that user should enter value 1, value 2, etc. Note: The computer starts counting with 0, but people start counting with 1, and your prompt should account for this. For example, when the user enters value 1, it will be stored in indexed variable 0. The constructor should populate 5 integer values, call findMin() and findMax(), and also calculateMean().
• findMin()—this is a method that uses a for loop to access each data value in the array (or arraylist) and finds the minimum value. The minimum value is stored into min.
• findMax()—this is a method that uses a for loop to access each data value in the array (or arraylist) and finds the maximum value. The maximum value is stored into max.
• calculateMean()—this is a method that uses a for loop to access each data value in array (or arraylist) and add it to a running total. The total divided by the number of values (use the length of the array), and the result is stored into mean.
• toString()—returns a String containing data, min, max, and the mean.
Task #2 TestMyArray
1. Create a LastNameFirstNameTestMyArray class. This class only contains the main method. The main method should declare and instantiate a LastNameFirstNameMyArray object.
2. Compile, debug, and run the program. Then, it should print out the contents, the min, max, and mean of the data.
and the second is
A theater seating chart is implemented as two-dimensional array of ticket prices, like this:
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 20 20 20 20 20 20 10 10
10 10 20 20 20 20 20 20 10 10
10 10 20 20 20 20 20 20 10 10
20 20 30 30 40 40 30 30 20 20
20 30 30 40 50 50 40 30 30 20
30 40 50 50 50 50 50 50 40 30
Write a program that prompts the users to pick either a seat or price. Mark sold seats by changing the price the 0. When a user specifies a seat, make sure it is available. When a user specifies a price, find any seat with that price.
Note: Assume that if the user enters 1 for the row and 1 for the seat, the yellow marked sit will be sold.
I was hoping someone could sorta walk me through these two questions and help me out like do a step by step.