138. Basic Arrays 0 - Link
- Task
- Answer
Create an array that can hold ten integers. Fill up each slot of the array with the number -113. Then display the contents of the array on the screen.Do not use a loop. Also, do not use any variable for the index; you must use literal numbers to refer to each slot.Sample Output
139. Basic Arrays 1 - Link
- Task
- Answer
Create an array that can hold ten integers. Fill up each slot of the array with the number -113. Then display the contents of the array on the screen.This time, you must use a loop, to put the values in the array and also to display them. Also, in the condition of your loop, you should not count up to a literal number. Instead you should use the
length field of your array.Sample Output140. Basic Arrays 2 - Link
- Task
- Answer
Create an array that can hold ten integers. Fill up each slot of the array with a random number from 1 to 100. Then display the contents of the array on the screen. You must use a loop.And, like last time, you must use the
length field of your array and not a literal number (like 10) in the condition of the loop.Sample Output141. Basic Arrays 3 - Link
- Task
- Answer
Create an array that can hold 1000 integers. Fill the array with random numbers in the range 10-99. Then display the contents of the array on the screen. You must use a loop.If you’re careful to only pick random numbers from 10 to 99 and you put two spaces after each number, then your output will line up like mine.And if you’ve forgotten how to pick random numbers in a certain range, you can check out my random ranges visualizer.Sample Output
142. Copying Arrays - Link
- Task
- Answer
Write a program that creates an array of ten integers. It should put ten random numbers from 1 to 100 in the array. It should copy all the elements of that array into another array of the same size. Then display the contents of both arrays. To get the output to look like mine, you’ll need a several
for loops.Create an array of ten integers- Fill the array with ten random numbers (1-100)
- Copy the array into another array of the same capacity
- Change the last value in the first array to a -7
- Display the contents of both arrays
143. Grades in an Array and a File - Link
- Task
- Answer
Prompt the user for a first and last name, and the name for a file. Randomly choose five grades for that person from 1 to 100 and store them in an array that can hold five integers. Then output the first and last name and those five grades to the specified file.Sample OutputLater, if you look in “ettu.txt” (or whatever you called your file), you should see values like this:
ettu.txt
144. Finding a Value in an Array - Link
- Task
- Answer
Create an array that can hold ten integers, and fill each slot with a different random value from 1-50. Display those values on the screen, and then prompt the user for an integer. Search through the array, and if the item is present, say so. It is not necessary to display anything if the value was not found. If the item is in the array multiple times, it’s okay if the program prints the message more than once.Sample Output
145. How Many Times? - Link
- Task
- Answer
Create an array that can hold ten integers, and fill each slot with a different random value from 1-50. Display those values on the screen, and then prompt the user for an integer. Search through the array, and count the number of times the item is found.Sample Output
146. Is It There or Not? - Link
- Task
- Answer
Create an array that can hold ten integers, and fill each slot with a different random value from 1-50. Display those values on the screen, and then prompt the user for an integer. Search through the array, and if the item is present, say so. If the value is not in the array, display a single message saying so. Just like the previous assignment, if the value is present more than once, you may display the message as many times as necessary.Sample Output
147. Where Is It? - Link
- Task
- Answer
Create an array that can hold ten integers, and fill each slot with a different random value from 1-50. Display those values on the screen, and then prompt the user for an integer. Search through the array, and if the item is present, give the slot number where it is located. If the value is not in the array, display a single message saying so. If the value is present more than once, you may either display the message as many times as necessary, or display a single message giving the last slot number in which it appeared.Sample Output
148. Finding the Largest Value in an Array - Link
- Task
- Answer
Write a program that creates an array which can hold ten values. Fill the array with random numbers from 1 to 100. Display the values in the array on the screen. Then use a linear search to find the largest value in the array, and display that value.Sample Output
149. Locating the Largest Value in an Array - Link
- Task
- Answer
Write a program that creates an array which can hold ten values. Fill the array with random numbers from 1 to 100. Display the values in the array on the screen. Then use a linear search to find the largest value in the array, and display that value and its slot number.Sample Output
150. Giving an Array a Bunch of Values at Once - Link
- Task
- Answer
Write a program that creates an array which can hold ten values. Fill the array with random numbers from 1 to 100. Display the values in the array on the screen. Then use a linear search to find the largest value in the array, and display that value and its slot number.Files NeededSample OutputAfter you add in the code you’re supposed to, you should see something more like this:
151. Parallel Arrays - Link
- Task
- Answer
Create three arrays to store data about five people. The first array should be
Strings and should hold their last names. The next array should be doubles and should hold a grade average (on a 100-point scale). The last array should be ints, should hold their student id numbers.Give each of the arrays values (using array initializers). Then print the values of all three arrays on the screen.Finally, ask the user for an ID number to lookup. Search through the ID array until you find that ID, and then print out the values from the same slot number of the other two arrays.Sample Output152. Tic-Tac-Toe - Link
- Task
- Answer
Code an interactive, two-player game of Tic-Tac-Toe. You’ll use a two-dimensional array of chars.Starter CodeSample Output
153. Hangman - Link
- Task
- Answer
Write a program to play a word-guessing game like Hangman.
- It must randomly choose a word from a list of words.
- It must stop when all the letters are guessed.
- It must give them limited tries and stop after they run out.
- It must display letters they have already guessed (either only the incorrect guesses or all guesses).