Function Exe 1
Function Exe 1
Function Exe 1
The function SubString(X,Y,Z) finds a substring of X starting at position Y and Z characters long. The first
character in X is in position 1.
• extract the word fun from the string and output it.
2. The 1D array StudentName[] contains the names of students in a class. The 2D array StudentMark[]
contains the mark for each subject, for each student. The position of each student’s data in the two
arrays is the same, for example, the student in position 10 in StudentName[] and StudentMark[] is the
same.
The variable ClassSize contains the number of students in the class. The variable SubjectNo contains the
number of subjects studied. All students study the same number of subjects.
The arrays and variables have already been set up and the data stored. Students are awarded a grade
based on their average mark.
• calculates the combined total mark for each student for all their subjects
• calculates the average mark for each student for all their subjects, rounded to the nearest whole
number
– name
– average mark
– grade awarded
• calculates, stores and outputs the number of distinctions, merits, passes and fails for the whole class.
3. Ann likes to create programs. [2022 MJ]
• accept the input of a word, or the number 1 to exit. No validation of the input is required
• display all the words in the array that have the same first letter as the word that has been input
• calculate and display the number of words in the array that begin with the same letter as the word
that has been input
• display all the words in the array that contain the word that has been input
• the number of words in the array that contain the word that has been input
• the number of letters in the longest word that contains the word that has been input
• the number of letters in the shortest word that contains the word that has been input
• display
• the longest word that contains the word that has been input
• the shortest word that contains the word that has been input
• repeat until the user inputs the number 1 to exit the program.
wordArray = ["wind","leer","pushy","lade","size","sob","borrowing","list", perish","hoax","sticks",
"seed", "impel", "large", "male", "silent", "quilt","sobbed","remarkable","fantastic", "wire",
"reflective","putrid", "pushover","swing"]
The program is a guessing game about countries and their capital cities.
If a player chooses this option, then they must input a player name.
• each question can only be selected once (they must not be able to choose a number more than once)
If the user chooses this option, then the player name and score should be displayed.
questions = [1,2,3,4,5,6,7,8,9]
She wants a program to analyse the performance of her team over a number of months.
staffSales = [
["101TGY" , "George" , "Taylor" , 6009 , 5262 , 3745 , 7075 , 1943 , 4432],
["103FCY" , "Fehlix" , "Chayne" , 8717 , 2521 , 5777 , 6189 , 5089 , 6957],
["102SBY" , "Sumren" , "Bergen" , 5012 , 1063 , 7937 , 9560 , 1115 , 5499],
["104SBK" , "Samira" , "Beckle" , 1140 , 9206 , 3898 , 8544 , 5937 , 8705],
["105NBT" , "Nellie" , "Bogart" , 3017 , 3342 , 5939 , 2479 , 3374 , 2297],
["106CGT" , "Cheryl" , "Grouth" , 9620 , 7160 , 5113 , 4803 , 5492 , 2195],
["107DGT" , "Danuta" , "Graunt" , 1583 , 7450 , 1026 , 7463 , 2390 , 6509],
["108JDN" , "Jaiden" , "Deckle" , 4064 , 4978 , 2984 , 3159 , 1464 , 4858],
["109JCK" , "Jimran" , "Caliks" , 6253 , 7962 , 2732 , 7504 , 2771 , 5193],
["110DDN" , "Deynar" , "Derran" , 6305 , 8817 , 5200 , 3647 , 3365 , 1256]]
• calculate and display the total sales made by each member of the team
• calculate and display the total sales made by the whole team
• display the first name, last name and the total sales made by the two members of the team with the
highest total sales. (Ignore the possibility of two or more members of the team having the same total
sales.)
Your program should function correctly even if the number of months or number of members of the
team is changed.
6. Zak sells snacks at an after-school club.
7. P-Cubed wants to know the weight of the heaviest item and the weight of the lightest item.
An operator enters weights for each item. The operator enters 0 when finished.
• display the price per textbook and the total cost of the order.
It also contains a function that randomly selects an animal from the array. This is the secret word the
user needs to guess.
• generate the number of attempts the user has to guess the secret word.
The maximum number of attempts is the length of the secret word +3. For example, the user has 8
attempts to guess when the secret word is tiger
• keep track of letters from incorrect attempts that are in the secret word and those that are not. There
should be no duplicated letters
• force the user to input a word that is the same length as the secret word
• letters from the attempt that appear in the secret word should be added to the correct letters store
• letters from the attempt that do not appear in the secret word should be added to the wrong letters
store
• the contents of the correct and wrong letter stores are displayed
• allow the user another attempt until they have guessed the word or have run out of attempts
• display a message telling the user the game is over including the random word if the maximum
attempts have been taken and the word has not been guessed.
Figure shows the contents of the correct and wrong stores after two attempts to guess the secret word
cow.
Your program should include at least two subprograms that you have written yourself.
You must include comments in the code to explain the logic of your solution.