will take the output file name as an argument (args [1]). You are free to explore the input and output methods as you develop the solution to the assignment; but before the submission, you have to prepare all the programs to take the input from a file in (args [0]) and print the output to the file in (args [1]).

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16SA
icon
Related questions
Question

Guidelines

 

  • The input and the output of the program will be from & to files.
  • For the input file: o The program will take the file name as an argument (args [0]).
  • For the output file: o The program will take the output file name as an argument (args [1]).
  • You are free to explore the input and output methods as you develop the solution to the assignment; but before the submission, you have to prepare all the programs to take the input from a file in (args [0]) and print the output to the file in (args [1]).
  • Attached to this assignment are sample input and output files for each question. Those files have the same format as the files that your program will be tested through. So, please adhere to the format in those files, and make sure that your code can read and write the data given in that format.

 

Question 2 (20 + 20 = 40 Marks)
You are asked to take as input a list of integers that went through several reverse
operations, and your task is to retrieve the original list, you may use java.util.Stack and
java.util.LinkedList as helpers.
The operations were as follows:
Select each subpart of the list that contain even integers only.
For example, if the list was {5,20,8,7,12,18}, then the selected subparts will
be {20,8}, {12,18}.
Reverse the selected subpart such as {8,20} and {18,12}.
The output should be the original list.
| Sample Input
Sample Output
9
24 18 2 35 7 9 12 6
2 18 24 357 96 12
As it is shown in the input sample, the first line will have an integer indicating the
number of the elements in the list followed by the second line which has the list of items.
In the sample input, 9 represents the number of items in the list.
As you can see, the subparts that contains only even integers in the given list are
{2,18,24} and {6,12}. The corresponding output (which is the original list) is shown in
the sample output section.
Transcribed Image Text:Question 2 (20 + 20 = 40 Marks) You are asked to take as input a list of integers that went through several reverse operations, and your task is to retrieve the original list, you may use java.util.Stack and java.util.LinkedList as helpers. The operations were as follows: Select each subpart of the list that contain even integers only. For example, if the list was {5,20,8,7,12,18}, then the selected subparts will be {20,8}, {12,18}. Reverse the selected subpart such as {8,20} and {18,12}. The output should be the original list. | Sample Input Sample Output 9 24 18 2 35 7 9 12 6 2 18 24 357 96 12 As it is shown in the input sample, the first line will have an integer indicating the number of the elements in the list followed by the second line which has the list of items. In the sample input, 9 represents the number of items in the list. As you can see, the subparts that contains only even integers in the given list are {2,18,24} and {6,12}. The corresponding output (which is the original list) is shown in the sample output section.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning