Write a class named HorseRace. The HorseRace class should have two parallel arra
ID: 3528100 • Letter: W
Question
Write a class named HorseRace. The HorseRace class should have two parallel arrays: one called names for the names of the horses and one called position for the position of the horses. The program should ask the user for the number of horses in the race and the names of the horses. The names of the horses should be stored in the names array. All the horses should be the race at position zero so the position array should be initialized to 0. After all the names have been entered, the race begins. The race is run by adding a random integer between 1 and 5 to each horseExplanation / Answer
read carefully import java.util.Scanner ; import java.util.Math; class HorseRace { public static void main (String args []){ int i=0,flag=0,k=0; Scanner input = new Scanner(system.in); system.out.println("Enter number of Horse : "); int number = input.nextInt(); int position[] = new int[number]; int match[] = new int[number]; String name[] = new String[number] ; for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.