-5

How can I store float value in an array from command line and when user input character "q" then system stop inputting values from command line.

Beau Grantham
  • 3,339
  • 5
  • 29
  • 43
user1703737
  • 523
  • 1
  • 11
  • 25

1 Answers1

0

I haven't tested it, but wrote using Scanner docs

Scanner sc = new Scanner(System.in);
while(sc.hasNext()) {
  String next = sc.next();
  if("q".equals(next)) break;

  float value = new Float(next);
  System.out.println("Float: "+value);
}
mprivat
  • 20,572
  • 4
  • 51
  • 62