Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int antal;
- public static void main(String[] args){
- double[] tid = new double[100];
- inTid(tid);
- utTid(tid);
- snabbastTid(tid);
- }
- public static void inTid(double[] tid){
- Scanner input = new Scanner(System.in);
- System.out.println("Skriv in tiderna. Avsluta med 0.");
- antal = 0;
- double temp = input.nextDouble();
- while (temp != 0) {
- tid[antal] = temp;
- antal++;
- temp= input.nextDouble();
- }
- }
- public static void utTid(double[] tid){
- System.out.print("Tiderna är: ");
- for (int i = 0; i < antal; i++) {
- System.out.print(" " + tid[i]);
- }
- System.out.println();
- }
- public static void snabbastTid(double[] tid)
- {
- double temp = tid[0];
- for (int i = 0; i < tid.length; i++) {
- if(temp > tid[i] && tid[i] != 0)
- temp = tid[i];
- }
- System.out.print(temp + " är den snabbaste tiden");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement