Question

This programming task will be a bit different. It will be more like what you would...

This programming task will be a bit different. It will be more like what you would receive if you were a maintenance engineer working in a corporate information systems or technology department. In other words, you will have some prebuilt source code provided for you that you must alter so it will meet the given programming specification..

  • Build a program from what you have been given as a starting-point.
  • Rename the “starter code”.
  • Do not add any modules; just, use the ones provides and add the necessary code in each one.
  • In the production of your final work-product do not modify the module names or any code in a module which has the following comment block at the beginning, “Finished - Do not alter!” You can re-work any other module so you generate a validate program which meets this specification.
  • Add the appropriate code when finishing the modules that start with a comment block which says “Finish adding Code.”
  • The array has 10,000 elements, its base type is integer, and it is filled with random numbers automatically when one calls the FillTheArray() module.
  • The numbers that will fill the array is are in the range, [ 0 .. 2200 ].
  • The array is unsorted and any particular random number, such as 1320, may appear more than once.
  • Build a pair of linear searches modules.
  • The search key, which your modules will find and count, is 1320, and it is an arbitrary value selected from the range [ 0 .. 2200 ] by the problem designer.
  • The output for the program will be simple, stating only if 1320 is present in the array of 10000 random values and how many times if it is found.
  • Finish filling out the explanation in the Main() labeled “Array as an argument comment:”, explaining how the array is passed an argument, modified in the module, and the modified array is available for the main program without having it explicitly returned by FillTheArray().
  • Modules:
    • FillTheArray()
      • Parameters: Integer Array iTempArray, Integer SIZE
      • Return: Nothing
    • LinearSearchOne() – This linear search will check for the existence of the number 1320
      • Parameters: Integer Array iTempArray, Integer SIZE, Integer ENTRY
      • Return: Boolean bTempDoesItExist
    • LinearSearchTwo() – This linear search will see how many of the number 1320 actually exists in the array
      • Parameters: Integer Array iTempArray, Integer SIZE, Integer ENTRY
      • Return: Integer iHowManyExist
    • ProgramHeader() - ProgramHeader(5), where 5 is the assignment number, can also be a variable holding the “5”
      • Output: Assignment 5 programmed by Hugh Schuett, where “Hugh Schuett” will be replaced by your name
      • Called at the beginning of the main()
    • ProgramOutput()
      • Parameters: Boolean bTempDoesItExist, Integer iHowManyExist
      • Return: Nothing

Note: Because the function Random() is used when filling the array, the number of times that 1320 occurs in the array of 10000 values will be different each time. Also, desk-checking an array of 10,000 numbers is an impractical way of validating the correctness of your program. As a result, you might consider adjusting the SIZE of the array and the RANGE of values randomly generated when testing. This is so one might use the "Watch Variables" feature and validate the programs output. A SIZE of 25 and a RANGE of 5 should work reasonably well. The values for the SIZE and RANGE should be reset before the program is turnt in.

Homework Answers

Answer #1
import random
import array

def programHeader(number):
    print ('Assignment {0} programmed by xyz.'.format(number))

def fillTheArray(itemp, size):
    for i in range(size):
        arr.append(random.randint(0, itemp))

def linearSearchOne(val):
    if val in arr:
        return True

def linearSearchTwo(val):
    counter = 0
    if val in arr:
        counter = +1
        return counter

def programOutput(boolval, iHowManyTimes):
    print(boolval,iHowManyTimes)

if __name__ == '__main__':
    arr = array.array('i',)
    programHeader(1)
    fillTheArray(10000, 2200)
    a = linearSearchOne(1320)
    b = linearSearchTwo(1320)
    programOutput(a,b)
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In JAVA Find the code for sorts in your language some where online. You will copy...
In JAVA Find the code for sorts in your language some where online. You will copy code from the internet (with citation!) and modify it to test. Make a random array of integers, then perform each search on them. LINEAR SEARCH Write a linear search method to find a number in the list. Call this before each of your sort methods. Include a comment explaining how Linear Search works, when to use it, when you cannot. BINARY SEARCH Write a...
Using C++, Python, or Java, write a program that: In this programming exercise you will perform...
Using C++, Python, or Java, write a program that: In this programming exercise you will perform an empirical analysis of the QuickSort algorithm to study the actual average case behavior and compare it to the mathematically predicted behavior. That is, you will write a program that counts the number of comparisons performed by QuickSort on an array of a given size. You will run the program on a large number of arrays of a certain size and determine the average...
Assignment #4 – Student Ranking : In this assignment you are going to write a program...
Assignment #4 – Student Ranking : In this assignment you are going to write a program that ask user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’...
write a program that automates the process of generating the final student report for DC faculty...
write a program that automates the process of generating the final student report for DC faculty considering the following restrictions. Consider declaring three arrays for processing the student data: studID studName studGrade The student ID is a random number generated by the 5-digit system in the range of (10000 - 99999). Create a function to assign the student ID generated in an array of numbers. Consider the following to generate the random number: Add the libraries: #include <stdlib.h> #include <ctime>...
Build two arrays[ ] (Integer and String) and convert them to two ArrayLists and write two...
Build two arrays[ ] (Integer and String) and convert them to two ArrayLists and write two overloaded generic static search method to find the index locations of a specified value. One of the search methods applies to the array type while the other (overloaded) search method applies to the collection type. Implement the following generic linear search method and write a client program to display results: (Here is the header) public static <E extends Comparable<E>> int search(E[] list, E key)...
Write a code in c++ using linear insertion following the steps below. Comment your work. 1....
Write a code in c++ using linear insertion following the steps below. Comment your work. 1.    Ask the user for the name of a file containing data. If it does not exist, the program should display an error, then ask for a new file name. Entering an asterisk (*) as the first and only character on a line should terminate the program. 2.     You can use a statically-allocated one-dimensional array of doubles for this with length 100. You...
JAVA please Arrays are a very powerful data structure with which you must become very familiar....
JAVA please Arrays are a very powerful data structure with which you must become very familiar. Arrays hold more than one object. The objects must be of the same type. If the array is an integer array then all the objects in the array must be integers. The object in the array is associated with an integer index which can be used to locate the object. The first object of the array has index 0. There are many problems where...
Leave comments on code describing what does what Objectives: 1. To introduce pointer variables and their...
Leave comments on code describing what does what Objectives: 1. To introduce pointer variables and their relationship with arrays 2. To introduce the dereferencing operator 3. To introduce the concept of dynamic memory allocation A distinction must always be made between a memory location’s address and the data stored at that location. In this lab, we will look at addresses of variables and at special variables, called pointers, which hold these addresses. The address of a variable is given by...
C++. Write a program that draws a rocket shape on the screen based on user input...
C++. Write a program that draws a rocket shape on the screen based on user input of three values, height, width and stages. The type of box generated (i.e.. a hollow or filled-in) is based on a check for odd or even values input by the user for the box height (or number of rows). Here is the general specification given user input for the height of the box..... Draw a hollow box for each stage if the value for...
Here's the requirement. Write a client program Subset.java that takes a command-line integer k , reads...
Here's the requirement. Write a client program Subset.java that takes a command-line integer k , reads in a sequence of strings from standard input using StdIn.readString() , and prints out exactly k of them, uniformly at random. Each item from the sequence can be printed out at most once. You may assume that 0 k N , where N is the number of string on standard input. The running time of the program must be linear in the size of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT