Java - Assigning User Input to Variable / Change Counter

前端 未结 1 1821
清酒与你
清酒与你 2021-01-24 10:08

I\'m quite new to java, although I have a fairly basic knowledge of C++. For my assignment I am counting change and sorting it into American currency (i.e., if you had 105 cents

相关标签:
1条回答
  • 2021-01-24 10:50

    Change this line :

    Scanner input new Scanner(System.in);
    

    To :

    Scanner input = new Scanner(System.in);
    

    And this should be after line below not before:

    System.out.println("Enter the amount of money in cents.");
    

    And as you did , the line below will read from input int value and assign it to your variable money :

    int money = input.nextInt();
    
    0 讨论(0)
提交回复
热议问题