0

Hi! I'm a beginner in java. How do you use a scanner if you need to input two different variables?

The problem is like this "Design a program to input number of hours worked and the rate per hour. " And I don't have any idea how to do it. Please help. Thank you

23rd Nov 2020, 10:18 PM
kmmy
kmmy - avatar
5 Antworten
+ 3
You only need to use 1 Scanner object. Remove; Scanner estela = new Scanner(System.in); and just reuse the 1st scanner (kim) in place of estela. Using more than 1 Scanner that utilizes the same input stream doesn't work usually, because they will interfere with each other when accessing the stream. https://code.sololearn.com/cfPZRhgN9vjK/?ref=app
23rd Nov 2020, 11:02 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
You just use the scanner to get the next input and store it in a variable. Review below, give it a shot and if you're still having issues share a link to your code in the playground with a description of the specific issue you're having or what you don't understand so we can help you further. https://www.sololearn.com/learn/Java/2220/
23rd Nov 2020, 10:25 PM
ChaoticDawg
ChaoticDawg - avatar
0
Well uhm This is the whole problem Design a program to input number of hours worked and the rate per hour. The program calculates the amount of income( hours times rate) and the net income( amount of income - tax). The tax is calculated as 10% from the amount of income.
23rd Nov 2020, 10:35 PM
kmmy
kmmy - avatar
0
http://www.sololearn.com/app/java/playground/ckI0DhMmAYt6/ here's the link and I don't really know if I'm doing the right thing🤦
23rd Nov 2020, 10:36 PM
kmmy
kmmy - avatar