The program doesn't wait for user input in String

Viewed 23

im totally new to coding and been working on this very basic program but I have this problem: after running it I can enter value a and b and after that code execute itself to the end without waiting for input on c. Will be very grateful for hints and leaving my code below:

import java.util.Scanner;

public class example
{
public static void main(String[] args)
{
  Scanner scan = new Scanner(System.in);
    System.out.println("Wprowadź liczbę");
    int a = scan.nextInt();

    System.out.println("Wprowadż drugą liczbę");
    int b = scan.nextInt();

    System.out.println("Co chcesz zrobić? Wpisz odpowiednoi: dodac, odjac, podzielic, pomnozyc");
    String c = scan.nextLine();

    int d = a + b;
    int e = a - b;
    float f = a / b;
    int g = a * b;

        switch(c)
        {
            case "dodac":
                System.out.println(d);
            break;

            case "odjac":
                System.out.println(e);
            break;

            case "podzielic":
                System.out.println(f);
            break;

            case "pomnozyc":
                System.out.println(g);
            break;
        }

}
}
0 Answers
Related