Question: 2. Write a function that takes, as an argument, a positive integer n, and creates a file, named eightBits.txt, containing n randomly generated eight-bit binary

2. Write a function that takes, as an argument, a positive integer n, and creates a file, named eightBits.txt, containing n randomly generated eight-bit binary strings, each on its own line. Examples of eight-bit binary strings include 10001111 and 00110011. Name this function eightBitStrings(n).

3. Write a function that takes, as an argument, a positive integer n, and creates a file, named nLinesOfText.txt, containing n lines of text obtained through keyboard input. In other words, the function should prompt the user to enter text n times, and it should write that information to a file. Name this function userInput(n).

4. Write a function that involves no arguments, named getAllTheText(), that prompts the user to enter text. If the user enters the word QUIT (in all uppercase), the function ends (closing any files that were opened at any point during this functions operation). If the text entered is not QUIT, the function writes the text entered to a file named unlimitedText.txt.

5. Write a function that involves no arguments, named makeStrings(), that prompts the user to enter three pieces of information: the number of bits in each binary string (k), the number of binary strings to create (n), and the name of the file. The function should then create a file with the specified name, and then proceed to create n randomly generated kbit binary strings and write them to the file, with each k-bit binary string on its own line. At the end of the function, the file should be closed.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!