Hi so I'm doing a simple assignment but I'm really a newbe so please don't be too harsh. To the issue, in my schools compiling programme it says something like it cannot execute the commands, command failed
So the error message
Ange ditt val här:
[IN:register new dog]
Detta är inte ett giltigt val // the error code is shown for some reason after the enter your choice
Välkommen till mitt hunddagis
[1] register new dog
[2] list dogs
[3] increase age
[4] remove dog
[5] exit
Ange ditt val här:
[IN:exit]
Detta är inte ett giltigt val
Välkommen till mitt hunddagis // repeating
[1] register new dog
[2] list dogs
[3] increase age
[4] remove dog
[5] exit
Ange ditt val här:
[TEST TIMED OUT WHILE: waiting for program to close. Most likely this is caused by a previous error, so start by looking for one above.] // so I just feel retarded right now, me and a few people have looked at this without being able to sort it out.
The code
import java.util.Scanner; import java.util.ArrayList; public class ProgHundDagis { private static Scanner myscan; public static void main(String[] args) { ArrayList<Hund> doglist = new ArrayList<Hund>(); myscan = new Scanner(System.in); boolean running = true; while (running) { System.out.println("Välkommen till mitt hunddagis"); System.out.println("\n[1] register new dog"); System.out.println("[2] list dogs"); System.out.println("[3] increase age"); System.out.println("[4] remove dog"); System.out.println("[5] exit"); System.out.println("\nAnge ditt val här: "); String option = myscan.nextLine(); switch (option) { case "1": System.out.println("register new dog"); System.out.println("Name:"); String name = myscan.nextLine(); System.out.println("Race:"); String race = myscan.nextLine(); System.out.println("Age:"); int age = myscan.nextInt();// myscan.nextLine(); System.out.println("Weight:"); double weight = myscan.nextDouble();// myscan.nextLine(); doglist.add(new Hund(name, race, age, weight)); break; case "2": System.out.println("list dogs"); break; case "3": System.out.println("increase age"); break; case "4": System.out.println("remove dog"); break; case "5": System.out.println("exit"); myscan.close(); running = false; break; default: System.out.println("Detta är inte ett giltigt val"); } } } }