At Westonci.ca, we provide clear, reliable answers to all your questions. Join our vibrant community and get the solutions you need. Discover detailed solutions to your questions from a wide network of experts on our comprehensive Q&A platform. Our platform provides a seamless experience for finding reliable answers from a network of experienced professionals.
Sagot :
Answer:dddd
Explanation:
//The code is all written in Java and here are the three classes in order ReportDriver, RaceReport, and Race
class ReportDriver {
public static void main(String[] args) {
boolean continueRace = true;
Scanner in = new Scanner(System.in);
ArrayList<ArrayList<Integer>> races = new ArrayList<>();
while (continueRace == true) {
System.out.println("Would you like to enter into a race? Y or N");
char answer = in.next().toLowerCase().charAt(0);
if (answer == 'y') {
Race race = new Race();
races.add(race.Race());
} else {
break;
}
}
for (int x = 0; x <= races.size()-1; x++) {
RaceReport report = new RaceReport();
report.RaceReport(races.get(x));
report.printRange();
report.printAverage();
}
}
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
package sample;
import java.util.ArrayList;
public class RaceReport {
int range, average;
String first, second, third;
public void RaceReport(ArrayList<Integer> times) {
if (times.get(2) == times.get(1)) {
if (times.get(2) == times.get(0)) {
System.out.println(first = "Times tied for first place are " + times.get(2) + " and " + times.get(1) + " and " + times.get(0));
} else {
System.out.println(first = "Times tied for first place are " + times.get(2) + " and " + times.get(1));
System.out.println(second = "Second place time is " + times.get(0));
}
} else if (times.get(1) == times.get(0)) {
System.out.println(first = "First place time is " + times.get(2));
System.out.println(second = "Times tied for Second place are " + times.get(1) + " and " + times.get(0));
} else {
System.out.println(first = "First place time is " + times.get(2));
System.out.println(second = "Second place time is " + times.get(1));
System.out.println( third = "Third place time is " + times.get(0));
}
range = Math.abs(times.get(0) - times.get(2));
average = (times.get(2) + times.get(1) + times.get(0) / 3);
}
public void printRange() {
System.out.println("The range of the race was " + range);
}
public void printAverage() {
System.out.println("The average of the race was " + average);
}
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
package sample;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Race {
Scanner in = new Scanner(System.in);
ArrayList<Integer> times = new ArrayList<>();
public ArrayList<Integer> Race() {
System.out.println("Input time 1:");
times.add(in.nextInt());
System.out.println("Input time 2:");
times.add(in.nextInt());
System.out.println("Input time 3:");
times.add(in.nextInt());
Collections.sort(times);
return times;
}
}
We hope you found what you were looking for. Feel free to revisit us for more answers and updated information. Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. Thank you for visiting Westonci.ca. Stay informed by coming back for more detailed answers.