fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. try{
  13. Scanner sc = new Scanner(System.in);
  14. String [] name = new String[4];
  15. double [] price = new double[4];
  16.  
  17. for (int i =0; i<name.length; i++) {
  18. System.out.println("name"+i);
  19. name[i] = sc.nextLine();
  20.  
  21. System.out.println("price"+i);
  22. price[i] = sc.nextDouble();
  23.  
  24. if(i<name.length-1)
  25. sc.nextLine();
  26. }
  27. System.out.println("your product: " + Arrays.toString(name) + Arrays.toString(price));
  28. }catch(Exception e){
  29. System.out.println(e);
  30. }
  31. }
  32. }
Success #stdin #stdout 0.15s 321088KB
stdin
as
21
aw
44
vg
47
jk
77
stdout
name0
price0
name1
price1
name2
price2
name3
price3
your product: [as, aw, vg, jk][21.0, 44.0, 47.0, 77.0]