This week’s assignments deal with files and nested loops. Input: The program prompts for the name of an input file and the name of an output file. The input file contains two positive (non-zero) integers, m and n, each less than 20, followed by a character. Output: A file containing an m × n rectangle made using the specified character. For example, if the input file contained the numbers 4 and 6 and the character ⋆ as shown below, 4 6* the output file would show 4 lines of 6 stars each, as shown below: ****** ****** ****** ******

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 10PE
icon
Related questions
Question

This week’s assignments deal with files and nested loops.
Input: The program prompts for the name of an input file and the name of an output file. The
input file contains two positive (non-zero) integers, m and n, each less than 20, followed by a
character.
Output: A file containing an m × n rectangle made using the specified character.
For example, if the input file contained the numbers 4 and 6 and the character ⋆ as shown below,
4 6*
the output file would show 4 lines of 6 stars each, as shown below:
******
******
******
******
This program will start by opening the input file and reading the numbers and the specified charac-
ter. Thereafter a nested for loop will generate the pattern. The following questions are designed
to step you through the process of creating the nested loop.
Pre-lab component: Question 1: Using Raptor, create a flowchart for the following process:
write a specified character (denoted ch) n times on the output stream and move the cursor to the
beginning of the next line. (In Raptor, the character must be put in double quotes. When writing,
uncheck the “end current line” box to stay on the same line; write an empty string with the box
checked to go to the next line.)
Pre-lab component: Question 2: Created a nested loop in Raptor. The outer loop will run the
inner loop a specified number of times. The result will be rectangular block of characters. Example
for constructing a nested Raptor loop can be found here. Note that when you draw the nested loop
1

 
 

in Raptor, the outer loop is created first, and the inner loop is placed inside it.
Question 3: Implement your algorithm in C++ using the for loops. (See the programs in In
CourseInfo/Files/ in CourseFiles for help with opening files.) Create three sample data files. In
a script session, do the following:
1. cat the program file and compile it using g++.
2. For each data file you created, display the file, run the program and display the resulting output
file.

Expert Solution
Step 1

“Since you have asked multiple questions, we will solve the first question for you. If you want any specific question to be solved, then please specify the question number or post only that question.”

The C++ language is developed by Bjarne Stroustrup. The C++ language is used to develop system software. C++ provides different ways of programming such as functional, object-oriented, procedural, and so on.

 

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT