mardi 30 juin 2015

Why won't my input Scanner and the rest of my program work?

Could someone help me to fix my code to get it to work. In the console it doesn't allow me to type anything. Could someone test the code on their computer and send me a comment with the fixed code? If not could you just tell me the problem with my code?

String yes= "yes";

    System.out.println("Do you have gym this semester?");
    input.nextLine();
    if (input.equals(yes)){

        int Gym;
        double GymGpa = 0;
        System.out.println("Gym = ");
        Gym= input.nextInt();
        input.close();
        if (Gym >100){
            System.out.println("You have mistyped something");
        }
        if (Gym >= 94 && Gym < 101){
            System.out.println("You have an A");
            GymGpa = 4.0;
            System.out.println(GymGpa);
        }
        if (Gym < 94 && Gym >=90){
            System.out.println("You have an A-");
            GymGpa = 3.7;
            System.out.println(GymGpa);
        }
        if (Gym < 90 && Gym >=87){
            System.out.println("You have a B+");
            GymGpa = 3.3;
            System.out.println(GymGpa);
        }
        if (Gym < 87 && Gym >=80){
            System.out.println("You have a B");
            GymGpa = 3.0;
            System.out.println(GymGpa);
        }
        if (Gym < 80 && Gym >=77){
            System.out.println("You have a B-");
            GymGpa = 2.7;
            System.out.println(GymGpa);
        }
        if (Gym < 77 && Gym >=73){
            System.out.println("You have a C+");
            GymGpa = 2.3;
            System.out.println(GymGpa);
        }
        if (Gym < 73 && Gym >=70){
            System.out.println("You have a C");
            GymGpa = 2.0;
            System.out.println(GymGpa);
        }
        if (Gym < 70 && Gym >=67){
            System.out.println("You have a C-");
            GymGpa = 1.7;
            System.out.println(GymGpa);
        }
        if (Gym < 67 && Gym >=67){
            System.out.println("You have a D+");
            GymGpa = 1.3;
            System.out.println(GymGpa);
        }
        if (Gym < 67 && Gym >=63){
            System.out.println("You have a D");
            GymGpa = 1.0;
            System.out.println(GymGpa);
        }
        if (Gym < 63 && Gym >=60){
            System.out.println("You have a D-");
            GymGpa = 0.7;
            System.out.println(GymGpa);
        }
        if (Gym < 60){
            System.out.println("You have a F");
            GymGpa = 0.0;
            System.out.println(GymGpa);
        }//End of Gym
    }else if (input.equals("no")){

    }

Aucun commentaire:

Enregistrer un commentaire