public class Marathon {
int x = 0;
public static void main(String[] args) {
String[] names = new String[]{"Jessabel", "Jerome", "Kristine", "Rodel", "Grajen", "Reymart", "Kevin",
"Sherwin", "Orniel", "John", "Kirk", "Jovert", "Rhea", "Mariella","Melart", "Michael"};
double[] times = new double[]{341.0, 273.0, 278.0, 329.0, 445.0, 402.0, 388.0, 275.0, 243.0, 334.0, 412.0,
393.0, 299.0, 343.0, 317.0, 265.0};
int t = 0;
for (int i = 0; i < times.length; i++){
System.out.println(names[i] + ": " + times[i]);
}
for(int i = 0;i< times.length; i++)
{
for (int j = i + 1; j < times.length; j++)
if (times[i] > times[j])
{
t = (int)times[i];
times[i] = times[j];
times[j] = t;
}
}
System.out.println("The Winners for 1st and 2nd fastest runner");
for (int i = 0; i < 2; i++){
for (int x = 0; x < 1; x++){
System.out.println(names[8] + "\t");
System.out.println(names[15] + "\t");
System.out.println(": " + times[i]);
}}}}
What did I do wrong?
The part highlighted with red at the bottom is my problem, I can't print it with its corresponding time please help
this is my output:
Jessabel: 341.0
Jerome: 273.0
Kristine: 278.0
Rodel: 329.0
Grajen: 445.0
Reymart: 402.0
Kevin: 388.0
Sherwin: 275.0
Orniel: 243.0
John: 334.0
Kirk: 412.0
Jovert: 393.0
Rhea: 299.0
Mariella: 343.0
Melart: 317.0
Michael: 265.0
The Winners for 1st and 2nd fastest runner
Orniel
Michael
: 243.0
Orniel
Michael
: 265.0
This is my second code, this is located above highlighted with red(codes)
System.out.println("The Winners for 1st and 2nd fastest runner");
for (int i = 0; i < 2; i++){
for (int x = 0; x < 1; x++){
System.out.println(names[8] +": " + times[i]);
System.out.println(names[15] +": " + times[i]);
Its Output:
The Winners for 1st and 2nd fastest runner
Orniel: 243.0 <<< this is one is fine
Michael: 243.0 <<<<<