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...
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>...
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...
This laboratory assignment involves implementing a data structure called a map. A map associates objects called...
This laboratory assignment involves implementing a data structure called a map. A map associates objects called keys with other objects called values. It is implemented as a Java class that uses arrays internally. 1. Theory. A map is a set of key-value pairs. Each key is said to be associated with its corresponding value, so there is at most one pair in the set with a given key. You can perform the following operations on maps. You can test if...
(Sure, take your time. would you like me to post this again?) Thanks in advance !...
(Sure, take your time. would you like me to post this again?) Thanks in advance ! Write the following methods in java class ARM that represent state information as well as functional blocks of the ARM platform. [Go through the following 5 classes then write methods for the instructions: mov, str, ldr, add in class ARM, finally, write a print method for ARM that can display the registers and the memory locations that have been used. (make sure to make...
convert this code to accept int value instead of float values using python. Make sure to...
convert this code to accept int value instead of float values using python. Make sure to follow the same code. do not change the steps and make sure to point to what code you replaced. make sure to have 2 files Method:----------------------- #define a python user difined method def get_float_val (prompt): is_num = False str_val = input (prompt) #prming read for our while #while is_num == False: (ignore this but it works) old school while not is_num: try: value =...
Implement the following functions in the given code: def random_suit_number(): def get_card_suit_string_from_number(n): def random_value_number(): def get_card_value_string_from_number(n):...
Implement the following functions in the given code: def random_suit_number(): def get_card_suit_string_from_number(n): def random_value_number(): def get_card_value_string_from_number(n): def is_leap_year(year): def get_letter_grade_version_1(x): def get_letter_grade_version_2(x): def get_letter_grade_version_3(x): Pay careful attention to the three different versions of the number-grade-to-letter-grade functions. Their behaviors are subtly different. Use the function descriptions provided in the code to replace the pass keyword with the necessary code. Remember: Parameters contain values that are passed in by the caller. You will need to make use of the parameters that each...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input...
Using the following code perform ALL of the tasks below in C++: ------------------------------------------------------------------------------------------------------------------------------------------- Implementation: Overload input operator>> a bigint in the following manner: Read in any number of digits [0-9] until a semi colon ";" is encountered. The number may span over multiple lines. You can assume the input is valid. Overload the operator+ so that it adds two bigint together. Overload the subscript operator[]. It should return the i-th digit, where i is the 10^i position. So the first...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT