Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions