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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education