i need to create a program for this but i don't know how to do ..
PLEASE help ...
Thanks ...
would appreciate if any kind soul help ...
|
|
|
import java.io.*;
class TriathlonTiming {
public static void main (String [] args) throws Exception{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader bf = new BufferedReader(isr);
String[] names = new String[10];
int[][] time = new int [9][10];
int choiceNo=0;
while (choiceNo != 4)
{
System.out.println("*************Triathlon Timing*************");
System.out.println("1) Enter Participant's timing");
System.out.println("2) Display all participant's timing");
System.out.println("3) Display the Winner");
System.out.println("4) Exit Program");
System.out.println("******************************************");
System.out.print("Please select your choice (1-4) : ");
choiceNo=Integer.parseInt(bf.readLine());
System.out.println("******************************************");
System.out.println();
if (choiceNo > 0 && choiceNo <= 4)
{
if (choiceNo == 1)
{
System.out.print("Enter No of Participants (max 10): ");
int participantsNo=Integer.parseInt(bf.readLine());
for (int count=0; count < participantsNo; count++ )
{
System.out.print("Enter athlate's name: ");
String[] athlate = new String [participantsNo];
names[count] = (bf.readLine());
System.out.println("Enter timing for Swim : ");
System.out.print(" No of hours : ");
time[0][count]=Integer.parseInt(bf.readLine());
System.out.print(" No of minutes : ");
time[1][count]=Integer.parseInt(bf.readLine());
while (time[1][count] > 59)
{
System.out.println(" Can't be more than 60, Please re-enter: ");
System.out.print(" No of minutes : ");
time[1][count]=Integer.parseInt(bf.readLine());
}
System.out.print(" No of seconds : ");
time[2][count]=Integer.parseInt(bf.readLine());
while (time[2][count] > 59)
{
System.out.println(" Can't be more than 60, Please re-enter: ");
System.out.print(" No of seconds : ");
time[2][count]=Integer.parseInt(bf.readLine());
}
System.out.println("Enter timing for Bike : ");
System.out.print(" No of hours : ");
time[3][count]=Integer.parseInt(bf.readLine());
System.out.print(" No of minutes : ");
time[4][count]=Integer.parseInt(bf.readLine());
while (time[4][count] > 59)
{
System.out.println(" Can't be more than 60, Please re-enter: ");
System.out.print(" No of minutes : ");
time[4][count]=Integer.parseInt(bf.readLine());
}
System.out.print(" No of seconds : ");
time[5][count]=Integer.parseInt(bf.readLine());
while (time[5][count] > 59)
{
System.out.println(" Can't be more than 60, Please re-enter: ");
System.out.print(" No of seconds : ");
time[5][count]=Integer.parseInt(bf.readLine());
}
System.out.println("Enter timing for Run : ");
System.out.print(" No of hours : ");
time[6][count]=Integer.parseInt(bf.readLine());
System.out.print(" No of minutes : ");
time[7][count]=Integer.parseInt(bf.readLine());
while (time[7][count] > 59)
{
System.out.println(" Can't be more than 60, Please re-enter: ");
System.out.print(" No of minutes : ");
time[7][count]=Integer.parseInt(bf.readLine());
}
System.out.print(" No of seconds : ");
time[8][count]=Integer.parseInt(bf.readLine());
while (time[8][count] > 59)
{
System.out.println(" Can't be more than 60, Please re-enter: ");
System.out.print(" No of seconds : ");
time[8][count]=Integer.parseInt(bf.readLine());
}
}
}
else if (choiceNo==2)
{
System.out.println("****************************************************************");
System.out.println("Name\t\tSwim\t\tBike\t\tRun");
System.out.println("****************************************************************");
for (int i=0; i<10; i++)
{
if (names[i] != null)
{
System.out.print(names[i] + "\t\t" + time[0][i] + ":" + time[1][i] + ":" + time[2][i] + "\t\t" + time[3][i] + ":" + time[4][i] + ":" + time[5][i] + "\t\t" + time[6][i] + ":" + time[7][i] + ":" + time[8][i]);
System.out.println();
}
}
}
}
else
System.out.print("Selection should be 1 to 4 : ");
System.out.println();
System.out.println();
}
}
}