Write a program that reads the numbers.txt file and stores it into an array of integers. Use the sample functions in the text and in the notes from chapter 8 to sort the array in ascending order (low to high). You can use either method (bubble or selection sort) to accomplish this. Then store the sorted array into an output file sortedNumbers.txt.

There are algorithms in the notes and text, use them to help you write the program. The numbers.txt file follows after this assignment under A21 Data.

There are 100 values both positive and negative integers in this file.

Write a program that reads the numbers.txt file into an array and the sorted Numbers.txt file into another array. Then prompt the user to enter a number and the find the number in the unsorted array, then using a binary search find the same number in the sorted array.

Time how long it takes for each search and print out those times. Use the data file numbers.txt from assignment A21 Data and the sorted file you created from the last assignment.

The Algorithms are provided in both the text and notes from chapter 8.

Assignment #23
Write a program that validates charge account numbers read in from the file Charges.txt following this assignment (A23 Data). Use a selection sort function on the array to sort the numbers then use a binary search to validate the account numbers.

Print out the sorted list of account numbers so you can see the valid ones. Prompt the user to enter an account number and the validate that number. If the account number entered is not found, tell the user to enter a valid number.

Place this in a loop so multiple values can be checked without restarting the program. Ask the user when to quit.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

    Pseudocode (algorithm) for main function:

    Declare number of numbers and set it to 100
    Declare array of 100 numbers
    Declare input stream for file "numbers.txt"
    Declare output stream for file "sortedNumbers.txt"
    If file "numbers.txt" is open:
       Repeat 100 times:
            Read a number from the file
            Store it to the array
       Print error message
       Exit the program
    Close the file "numbers.txt"
    Print unsorted array
    Call selectionSort() to sort the array
    Print sorted array
    If file "sortedNumbers.txt" is open:
       For each number from array:
            Write it to the output file
       Print error message
       Exit the program
    Close the file "sortedNumbers.txt"

    Pseudocode (Algorithm) for selectionSort function:
    Inputs: array (array of integers), size (integer)...

By purchasing this solution you'll be able to access the following files:

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats