Spaces

  • 10
  • Locked
The first parameter of the main method is a file name. Display the ratio of the number of spaces to the number of all characters. For example, 10.45. 1. Count all the characters (n1). 2. Count the spaces (n2). 3. Display n2/n1*100, rounding to 2 decimal places. 4. Close the streams.
You can't complete this task, because you're not signed in.
Comments (4)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
ayhem bouabid
Level 25 , Tunis, Tunisia
20 June 2021, 16:04
funny fact: the result when using FileInpustStream will be different than the one with BufferedInputStream.
Nyerges Ferenc
Level 23 , Bükkábrány, Hungary
3 November 2020, 21:09
That was a tricky one, and perfect to recall what we've learned about conversions. Nice task :-)
Switch/Cypher
Level 25 , Bexleyheath, United Kingdom
5 October 2020, 19:21
ALL CHARACTERS. Not just letters.
Tony Roy
Level 41 , Victorville, United States
28 March 2020, 15:23
It may help to recognize that they are asking for the *percent* of characters that are spaces, not the *ratio* of characters to spaces.