undefined

Bonus task | Lesson 11 | Level 8

Java Core
Level 8 , Lesson 11
Available

"Hey, soldier!"

"Good day, Captain!"

"I've got awesome news for you. Here are some exercises to reinforce your skills. Do them every day and your skills will grow at an insane speed. They were created especially for IntelliJ IDEA."

"Those previous exercises were for rookies. I've added some more advanced bonus exercises for the old-timers. Just for veterans."

undefined
10
Task
Java Core, level 8, lesson 11
Locked
ABCs
The first parameter of the main method is a file name. Count the letters in the file. Display the number of letters. Close the streams.
undefined
10
Task
Java Core, level 8, lesson 11
Locked
Spaces
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.
undefined
10
Task
Java Core, level 8, lesson 11
Locked
Two in one
Read 3 file names from the console. Write the contents of the second file to the first file, and then append the contents of the third file to the first file. Close the streams.
undefined
10
Task
Java Core, level 8, lesson 11
Locked
Combining files
Read 2 file names from the console. Write the contents of the second file to the beginning of the first file so that the files are combined. Close the streams.
undefined
20
Task
Java Core, level 8, lesson 11
Locked
Rounding numbers
Read 2 file names from the console. The first file contains real (fractional) numbers, separated by spaces. For example, 3.1415. Round the numbers to integers and write them, separated by spaces, to the second file. Close the streams. The rounding should work like this: 3.49 => 3 3.50 => 4 3.51 => 4
undefined
20
Task
Java Core, level 8, lesson 11
Locked
Symbol frequency
The program is started with one argument: the name of a file that contains text. Calculate how often each symbol is encountered. Sort the results by increasing ASCII code (read about it online). Example: ','=44, 's'=115, 't'=116. Display the sorted results: [symbol1] frequency1 [symbol2] frequency2
undefined
20
Task
Java Core, level 8, lesson 11
Locked
Finding data inside a file
Read a file name from the console. Search the file for information related to the specified id. Display it in the format used in the file. The program is started with one argument: id (an int). Close the streams. The file data is separated by spaces and stored in the following order: id productName
undefined
20
Task
Java Core, level 8, lesson 11
Locked
Threads and bytes
Read file names from the console until the word "exit" is entered. Pass the file name to the ReadThread thread. The ReadThread thread should find the byte that occurs most frequently in the file, and add it to resultMap, where the String parameter is the file name and the Integer parameter is the re
undefined
10
Task
Java Core, level 8, lesson 11
Locked
Files and exceptions
Read file names from the console. If the file does not exist (i.e. an invalid file name is given), then catch the FileNotFoundException, display the invalid file name, and exit the program. Close the streams. Don't use System.exit();
undefined
20
Task
Java Core, level 8, lesson 11
Locked
Building a file
Let's build a file from various pieces. Read file names from the console. Each file has a name: .partN. For example, Lion.avi.part1, Lion.avi.part2, ..., Lion.avi.part37. The file names are supplied in random order. The word "end" is used to stop reading in file names. In the folder where
undefined
10
Task
Java Core, level 8, lesson 11
Locked
Encryption
Come up with an encryption/decryption mechanism. The program runs with one of the following sets of arguments: -e fileName fileOutputName -d fileName fileOutputName where: fileName is the name of a file to be encrypted/decrypted. fileOutputName is the name of the file where you need to write the re
undefined
20
Task
Java Core, level 8, lesson 11
Locked
Prices
CrUD for a table inside a file. Read a file name for CrUD operations from the console. The program is started with the following arguments: -c productName price quantity Argument values: where id is 8 characters. productName is 30 characters. price is 8 characters. quantity is 4 characters. -c adds
undefined
20
Task
Java Core, level 8, lesson 11
Locked
Prices 2
CrUD for a table inside a file Read a file name for CrUD operations from the console The program runs with one of the following sets of arguments: -u id productName price quantity -d id Argument values: where id is 8 characters productName is 30 characters price is 8 characters quantity is 4 charact
Comments (27)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Jurij Thmsn Level 22 Flensburg Germany
16 April 2021
Skyrocketing difficulty 🤯 I'd love to have an overview when to use which reader/writer. And which one does exactly what. I know and used FileInputStream, FileOutputStream, FileWriter, FileReader, ByteArrayInputStream, ByteArrayOutputStream, BufferedInputStream, BufferedReader, BufferedWriter, InputStreamReader (...) But I am really confused about the differences, return types and when to use which. before doing the exercises, I recommend to look further into String.format. e.g. here: https://www.youtube.com/watch?v=moQ3Kr8ouiU And how to use TreeSet and substring, too. And make sure not to write and read from the same file at the same time! Keep going!
Chandan Thapa Level 22 Dubai United Arab Emirates
5 January 2021
It was hard! But learned a lot by doing this! Feels so awesome after completing all!! You can do it!
Agent Smith Level 38
6 September 2020
Good tasks. Moving on.
Lawson Level 29 Lagos Nigeria
3 September 2020
The task were good tho... but it has shown me that i have to read more on files sha Thanks
Baurzhan Konurbayev Level 40 United States
14 August 2020
This is so helpful to grow coding muscles. Thank you so much for this opportunity!
Blaise Level 20 London United Kingdom
14 June 2020
Rounding numbers (task1820): There might not be a space after the last number in your file, so make sure you process the "leftover" as well. Also, use Math.round(). System.out.printf() rounds negative numbers in a different way. Symbol frequency (task1821): First of all, what do they mean by "symbols"? In this case any ASCII character is a symbol. This can be solved with a simple Array: int[] chars = new int[256]; (128 should be enough though.) Less than 20 lines of code. No need to sort anything, just print the array with for-loop. Finding data inside a file (task1822): "display information related to the specified id passed" Above requirement could have been a bit more specific. I passed this with printing the whole line that starts with the id. No need to convert/cast to String/int/double. Good luck :)
Manish Sinha Level 26 london United Kingdom
3 May 2020
task 1825 took me 3 hrs to solve it, But am glad I solved it in two attempts.
MaGaby2280 Level 31 Guatemala City Guatemala
2 March 2020
The last two tasks were hard... LinkedHashMaps really do help to solve them! I am glad it's over jajaja
Justin Johnson Level 31 Clearwater United States
13 February 2020
Prices...that was a tough one. Congrats to everyone who has made it this far.
Seb Level 41 Crefeld Germany
2 January 2020
Well, those exercises took a little while - and some tasks were a little crunchy indeed - but in a good way. So yeah, very happy with this ending of level 18. Keep at it, guys! ;-) :-) And thanks a lot for this whole quest, Captain Squirrels. :-)