Write a program that simulates a lottery. The program should have an array of five integers named lottery and should generate a random number in the range of 0 through 9 for each element in the array.
The user should enter five digits, which should be stored in an integer array named user. The program is to compare the corresponding elements in the two arrays and keep a count of the digits that match. For example, the following shows the lottery array and the user array with sample numbers stored in each. There are two matching digits (elements 2 and 4).
lottery array: 7 4 9 1 3
user array: 4 2 9 7 3
The program should display the random numbers stored in the lottery array and the number of matching digits. If all of the digits match, display a message proclaiming the user as a grand prize winner.
Input Validation: Do not accept a negative value for lottery number. Also keep track of array size.
Implement a class named RandNum. The class should have a 5x5 2D array of 25 integers. The constructor should use the random() function to generate a random number in the range of 1 to 100 for each element in the array. Implement a method to calculate the minimum, maximum and average of the 25 values. Implement a method to display the values of the array, minimum, maximum and average of the 25 values
1111#Bill#Jones#55895.25
1234#Mary#Smith#95875.50
2222#Andile#Makanda#67892.00
2223#Susan#Stofberg#43569.35
3345#Lihle#Tshabalala#88795.75
2323#Steve#Adams#55890.80
4333#Siya#Mlenga#64290.50
3445#Khaya#Poswa#27850.55
5677#Jimmy#Davis#57860.95
1. Open and read the input txt file, StaffData.txt.
2. Create an object of type Staff representing each input line.
3. Add each Staff object to an arraylist.
4. Close the input file.
5. Open an output txt file.
6. Sort the objects in the arraylist in alphabetical order of surname.
7. Loop thru your arraylist and write all the staff objects with a salary exceeding
R50 000 to the output file. Use the printToFile () method.
Include appropriate headings.
Include a count of the number of staff members written to the file at the end of the report.
8. Close the output file.
What is the output of this program and can you answere me that where and how they (0*000),(1500.99),(1000),(1BM) came?
Build a class PetShop with the following data members Name: String Address: String Inventory: ArrayList 1. Provide constructor and do appropriate initialization 2. Provide a method addPet(Pet p) that adds the pet object p to the inventory 3. Provide a method Pet getPetByID(String id) that searches in the inventory for the given pet and returns its instance 4. Provide a method boolean isThePetDead(String id) that searches for the pet with given id in the inventory and returns a true if the pet is dead or false othewise. 5. Provide the toString method that gives all details about the shop and the inventory.
Program breadth-first search, depth-first search, iterative deepening and A* Search in the Java Programming
language. Your program should be interactive. Allow the users to input the number of elements in the search space and the number of edges in the graph, then you create a graph for that. Let the user then input the search goal and the algorithm to use for the searching. Use the goal and traverse to give the user the desired output.
Compute the running time for each algorithm after the search is complete.
Create a class named 'Rectangle' with two data members 'length' and 'breadth' and two methods to print the area. Then create a class named ‘Square’ with data member radius and method to print the area. Print the area of a rectangle and a square with Uses A relationship by creating another class Shape_of_rectangle.
by CodeChum Admin
Looping a number and taking away each digit of it is so much fun, but I wanted to try out a much more complex task: getting the largest digit among them all.
Think you can handle the job?
Instructions:
Input
A line containing an integer.
214
Output
A line containing an integer.
4
by CodeChum Admin
Manipulating values from a series of numbers is fun, but let's try exploring the use of loops a little more.
How about printing out each digit of a number starting from its rightmost digit, going to its leftmost digit?
Instructions:
Input
A line containing an integer.
214
Output
Multiple lines containing an integer.
4
1
2
Write a program that will determine the best Second year student.
Create a front-end class SecondYears that will determine the best first year student.
The class has the following data members:
-an array of ten student objects named myStudents.
The class has the following methods
-enterStudentValues that prompts and reads the values that the each student has to be set to, and sets it accordingly.
-sortStudents that will sort the Students object in descending sequence of the overall average.
-Display that will display all the students in the array.
when you run it must show these:
Write a main() program that:
-Instantiates a SecondYears object
-Read in values into the SecondYears object students array using its enterStudentValues method.
-Display all the students using the objects display method.
-Sort the students in descending sequence of their overall average.
-Display again to show the best student.