|
| |
Data in Lists – Sample
Lab Exercises
-
To
use the “speed dial” feature of your home phone you must first store
each of the phone numbers that you wish to use. Each phone number is
accessed by entering the speed-dial number, from 0 to 9, used for storing
the number. Write a program that will help you remember who’s phone number
you have stored with each speed dial number. Your program must use an array
to store the list of names. The user enters a number from 0 to 9 and is
shown the name of the person that would be called if you entered that speed
dial code into the phone. Store the data from the array in a sequential
file.
-
Write
a program that allows the user to enter up to 20 numbers to be stored in an
array. When the user has finished entering numbers, calculate and display
the sum of the numbers, the mean (arithmetic average) of the numbers, and
the largest and smallest values entered.
-
Create
a program that reads a list of no more than 100 names from a sequential file
into an array. The names are stored in the file in the form “last_name,
first_name.” Allow the user to display the list; add, modify, and delete
names; and save the modified list in a sequential file with the same name.
-
Write
a program to simulate rolling two dice together 100 times. Count the number
of times each result (i.e., total of the two dice) occurs and print out the
results. Note that rolling two dice together is not the same as picking a
number from 2 to 12!! (If you really turn on your problem-solving skills,
this program can be most easily done WITHOUT AN IF STRUCTURE!!)
Source:
Public
and
Catholic
District School Board Writing
Partnership,
Course
Profile: Computer
and Information Science,
Grade 11, University/College
Preparation ICS3U,
Queen’s Printer for Ontario, 2001, adapted.
|