Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

File 1: https://drive.google.com/file/d/1pXRj4brpuY5QI_yCICOPwOqMP8SvNgsq/view?usp=sharing File 2: https://drive.google.com/file/d/1XFBGmLL071XD7Pa_qcRh-EcDnV_dObR7/view?usp=sharing This program will search a user-selected txt file for any integer the user provides. The only valid file names

image text in transcribedimage text in transcribedimage text in transcribedFile 1: https://drive.google.com/file/d/1pXRj4brpuY5QI_yCICOPwOqMP8SvNgsq/view?usp=sharing

File 2: https://drive.google.com/file/d/1XFBGmLL071XD7Pa_qcRh-EcDnV_dObR7/view?usp=sharing

This program will search a user-selected txt file for any integer the user provides. The only valid file names are numbers1.txt and numbers2.txt, both of which are automatically included in the Mimir project. In addition to the search results, the program will provide some interesting statistics about the numbers in that file. The file itself contains a bunch of integers (0 to 9) organized into an unknown number of rows. However, each row contains exactly 10 integers. *NOTE: Be sure to download the two files above for testing in your CLion project. Use the output below as a guide for the code you need to write. The first screenshot clearly shows all of the validation you need to perform, as well as all of the prompts and output. The second screenshot shows what happens if the user's number happens to be the last number in the file (check the last line of output). Example 1 (numbers1.txt) This program will search a file for your number and provide some statistics on the numbers in the file Enter the name of the file you wish to search (numbers1.txt OR numbers2.txt): something.txt Invalid file name. Please try again. Enter the name of the file you wish to search (numbers1.txt OR numbers2.txt): numbers1.txt Enter the integer that you wish to search for (o to 9): -1 You must enter an integer (whole number) from 0 to 9. Please try again. Enter the integer that you wish to search for (@to 9): 10 You must enter an integer (whole number) from 0 to 9. Please try again. Enter the integer that you wish to search for (o to 9): You must enter an integer (whole number) from 0 to 9. Please try again. Enter the integer that you wish to search for (o to 9): 5 There are 950 integers in the file, organized into 95 rows The sum of all integers in the file: 4303 The sum of the integers located at the end of each row: 408 Your number was found 97 times The number 3 was the last number in the file Example 2 (numbers2.txt) This program will search a file for your number and provide some statistics on the numbers in the file Enter the name of the file you wish to search (numbers1.txt OR numbers2.txt): numbers2.txt Enter the integer that you wish to search for ( to 9): 6 There are 1340 integers in the file, organized into 134 rows The sum of all integers in the file: 6003 The sum of the integers located at the end of each row: 540 Your number was found 148 times Fun fact: Your integer was the last number in the file! Submitting Since I already included the two text files in the Mimir project, you only need to submit your main.cpp file. 40% Hints: 1) My program has 84 lines of nicely spaced and commented code 2) Pretend that this program had 50 different text files that the user could choose from. Whether there are 2 or 50 files, the logic of your program should be the same (except for the validation of the filenames, of course). This program will search a user-selected txt file for any integer the user provides. The only valid file names are numbers1.txt and numbers2.txt, both of which are automatically included in the Mimir project. In addition to the search results, the program will provide some interesting statistics about the numbers in that file. The file itself contains a bunch of integers (0 to 9) organized into an unknown number of rows. However, each row contains exactly 10 integers. *NOTE: Be sure to download the two files above for testing in your CLion project. Use the output below as a guide for the code you need to write. The first screenshot clearly shows all of the validation you need to perform, as well as all of the prompts and output. The second screenshot shows what happens if the user's number happens to be the last number in the file (check the last line of output). Example 1 (numbers1.txt) This program will search a file for your number and provide some statistics on the numbers in the file Enter the name of the file you wish to search (numbers1.txt OR numbers2.txt): something.txt Invalid file name. Please try again. Enter the name of the file you wish to search (numbers1.txt OR numbers2.txt): numbers1.txt Enter the integer that you wish to search for (o to 9): -1 You must enter an integer (whole number) from 0 to 9. Please try again. Enter the integer that you wish to search for (@to 9): 10 You must enter an integer (whole number) from 0 to 9. Please try again. Enter the integer that you wish to search for (o to 9): You must enter an integer (whole number) from 0 to 9. Please try again. Enter the integer that you wish to search for (o to 9): 5 There are 950 integers in the file, organized into 95 rows The sum of all integers in the file: 4303 The sum of the integers located at the end of each row: 408 Your number was found 97 times The number 3 was the last number in the file Example 2 (numbers2.txt) This program will search a file for your number and provide some statistics on the numbers in the file Enter the name of the file you wish to search (numbers1.txt OR numbers2.txt): numbers2.txt Enter the integer that you wish to search for ( to 9): 6 There are 1340 integers in the file, organized into 134 rows The sum of all integers in the file: 6003 The sum of the integers located at the end of each row: 540 Your number was found 148 times Fun fact: Your integer was the last number in the file! Submitting Since I already included the two text files in the Mimir project, you only need to submit your main.cpp file. 40% Hints: 1) My program has 84 lines of nicely spaced and commented code 2) Pretend that this program had 50 different text files that the user could choose from. Whether there are 2 or 50 files, the logic of your program should be the same (except for the validation of the filenames, of course)

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

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

6. Vanguard

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago