Task 1
The following array stores the names of 10 employees in a company:
employees = ["Harry", "Judi", "Max", "Alexander", "Shasha", "Pony", "Erland", "Billy", "Walter", "Vsevolod"]
Write a program which follows the following algorithm:
- Input the name of an employee
- Search the array for the name
- If the name is found, display the index of the element in the array which stores the name.
- If the name is not found, display a message Employee absent!
Task 2
A computer game program stores the names of players in one array and the score of each player in another array. Eg:
players = ["Jason", "Jennifer", "Ping", "Su", "Jesse"]
scores = [87, 67, 91, 87, 71]
We can see that Jason scores 87 and Jesse scored 71.
Write a program that:
- inputs the name of a player
- Searches the players array for the name.
- If the name is found the program outputs the name of the player and their score.
- If the name is not found, the program displays a message Player not found!
Task 3
A computer program stores the ID, name and address of students in a school. The data is stored in 3 seperate arrays eg:
ids = ["ss01", "ss11", "ss06", "ss04", "ss21","ss11"]
name = ["Henry", "Sally", "Col", "Alison", "Kerry","Belinda"]
address = ["123 York Road", "1a Salford Avenue", "3 Market Square", "Flat 4a 9 Jepson Road", "323 Colombus Ravine","62 Marchmont Road"]
Use the following algorithm to write a computer program:
- The program will ask the user to enter an ID.
- The program will do a length validation check: if the data entered is not 4 characters long, it will keep asking for an ID.
- Once a valid ID has been entered, the program will search the ids array for the ID.
- If it finds the ID, it will display the id, name and address of the student the same number of times as the last number in the id eg if the id is "ss04", the program will display the message 4 times.
- If it does not find the ID, it will display Student not found! 10 times.