Assume that you will be given a *.txt file, which in the same format of RandSource.txt(attached). The file has three numbers at each line. Numbersare separated with a space. All number are in the range of [0, 50]. The first two numbers indicate a range. The third one shows number of random numbers to be generated in the range of first two numbers. The range always given  in first < second order. If not, raise an error. For instance, 2 5 7  means that you need to generate 7 random numbers in the range of 2 - 5 (including 2 and 5). You need to develop a complete C++ program to read each line from the .txt file and print the result on screen in a formatted way. The output format will be <first number> - <second number>: <random numbers > . For the above example, the output to screen should be 2 - 5: 6 5 4 6 3 7 5The attached input file has,3 6 82 19 104 12 41 6 07 4 30 8 310 9 8Your program should generate this (or with different random numbers) output for this file3 - 6: 5 4 3 5 6 3 4 52 - 19:6 2 11 14 17 9 8 19 2 7 4 - 12:5 4 10 91 - 6:                                   // no output here since quantity is 07 - 4:error0 - 8:0 6 410 - 9: error Note that your program should any number of lines in the file. You strictly assume that all numbers are in the range of [0,50].   RandSource.txt: 3 6 82 19 104 12 41 6 07 4 30 8 310 9 8

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

Assume that you will be given a *.txt file, which in the same format of RandSource.txt(attached). The file has three numbers at each line. Numbersare separated with a space. All number are in the range of [0, 50]. The first two numbers indicate a range. The third one shows number of random numbers to be generated in the range of first two numbers. The range always given  in first < second order. If not, raise an error.

For instance,

2 5 7  means that you need to generate 7 random numbers in the range of 2 - 5 (including 2 and 5).

You need to develop a complete C++ program to read each line from the .txt file and print the result on screen in a formatted way. The output format will be <first number> - <second number>: <random numbers > . For the above example, the output to screen should be

2 - 5: 6 5 4 6 3 7 5

The attached input file has,

3 6 8
2 19 10
4 12 4
1 6 0
7 4 3
0 8 3
10 9 8

Your program should generate this (or with different random numbers) output for this file

3 - 6: 5 4 3 5 6 3 4 5
2 - 19:6 2 11 14 17 9 8 19 2 7
4 - 12:5 4 10 9
1 - 6:                                   // no output here since quantity is 0
7 - 4:error
0 - 8:0 6 4
10 - 9: error


Note that your program should any number of lines in the file. You strictly assume that all numbers are in the range of [0,50].

 

RandSource.txt:

3 6 8
2 19 10
4 12 4
1 6 0
7 4 3
0 8 3
10 9 8

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 7 steps with 7 images

Blurred answer
Knowledge Booster
Constants and Variables
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
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