+ 1

How to retrieve multiple keyboard input in code playground?

I tried below code, it works on IntelliJ. But when I run it on Sololearn, it doesn't work (looks like the problem is keyboard input). I've been looking for solution for awhile. So, can anyone suggest me to figure out this problem? Thank you in advance Code: import java.util.Scanner; public class Main { public static double keyboardInputDouble(){ Scanner scanner = new Scanner(System.in); double doubleNumber = scanner.nextDouble(); return doubleNumber; } public static int keyboardInputInteger(){ Scanner scanner = new Scanner(System.in); int integerNumber = scanner.nextInt(); return integerNumber; } public static double calculateInterest (double amount, double interestRate){ return (amount*interestRate/100); } public static void main(String[] args) { System.out.println("Enter amount: "); int amount = keyboardInputInteger(); for (int i = 0; i <3; i++) { System.out.println("Enter "+(i+1)+" interest rate (%): "); double interest = keyboardInputDouble(); System.out.println((i+1)+" interest rate is "+interest+" %."); System.out.println("Amount "+amount+" at "+interest+" % interest = "+(int)calculateInterest(amount,interest)); } } }

8th Sep 2017, 3:03 PM
arunsawat preedathawan
arunsawat preedathawan - avatar
2 ответов
+ 2
on sololearn here, the code playground except for "web" and "php", doesn't give you multiple pop up box for multiple call to input. ...so you have to hit "enter" the same number of times you added (System.in).
8th Sep 2017, 3:16 PM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
+ 1
thank you for your suggestion. I will try it again.
8th Sep 2017, 3:26 PM
arunsawat preedathawan
arunsawat preedathawan - avatar