Examine the following loops and determine the number of times the loop executes and the final value of ires at the termination of the loop.
a) ires = 0;
for index = -12 : 12
ires = ires + 1;
end
b) ires = 0;
for index = 10 : -2 : 1
if index == 6 continue
end
ires = ires + index;
end
c) ires = 2;
while ires <= 100
ires = ires.^2;
end
d) ires = 2;
while ires > 100
ires = ires.^2;
end
Homework 4
Data Structures
Assignment Topic: Merge Processing files of struct
Write 5 different functions to calculate and output a summary of
l how many points did each team gain?
l how many games did each team won,
l the name of the team that has the most points,
l and the name of the team with the fewest points.
l any other interesting statistics.
Write a C++ (or similar programming language code: c, java, c#, or python) code that includes following functionalities:
I. Store at least three different data sets of sport teams each in a separate external text file or similar (csv files- 1 more point and json files- 2 more points are accepted). Each file consists of 10-15 different rows. Where each row consists of at least 4 different values.
Example of file structure:
Team Name, Team Play Against, First Team Score, Second Team Score
Write a program that reads and records magazine sales for 5 students. Record a
student’s name, the magazine sold, and the number sold. Information should be read
in one record at a time – that is to say, read one student, magazine, and number before
getting the next set. (Similar to the example in the notes.) Produce a table that
displays the recorded information.
Note: use multiple arrays
Your goal is to create a program that will determine the average score for an
athlete in a competition. There are 10 judges who each award a score between 0
and 10. The lowest and highest scores are thrown out, and the athlete’s score is
the average of the eight remaining scores.
You need to create a scorecard file in a text editor or type it into onlineGDB. The
scorecard should have the first and the last name of the athlete on the first line
and 10 space-separated numbers between 0 and 10 on the second line. The
numbers should have at most 1 digit after the decimal point.
An array to hold the scores from all judges.
Example Input File:
Mirabella Jones
7.5 8.8 7 8.1 8 9.8 9.3 8.9 9.1 9
Example Output:
Mirabella Jones's results:
7.5, 8.8, 7.0, 8.1, 8.0, 9.8, 9.3, 8.9, 9.1, 9.0
The highest score of 9.8 and the lowest score of 7.0 were
dropped
The average score is 8.59
Part 2
Write your own function that illustrates a feature that you learned in this unit. The function must take at least one argument. The function should be your own creation, not copied from any other source. Do not copy a function from your textbook or the Internet.
Include all of the following in your Learning Journal:
Part 1
The volume of a sphere is 4/3πr3, where π has the value of "pi" given in Section 2.1 of your textbook. Write a function called print_volume (r) that takes an argument for the radius of the sphere, and prints the volume of the sphere.
Call your print_volume function three times with different values for radius.
Include all of the following in your Learning Journal:
Write a complete program to allow the following data processing:
i. Declare the variables (name, program code, part, CGPA).
ii. Ask the user the data of name, program code, part, and CGPA.
iii. Display the data in a proper format.
Company ABC Sdn Bhd is planning to develop a program to summarize their employees’ salary information. Each of the employee is required to register the name, IC number, ID number (in format 123456) and salary data. Identify the data needs for the program. Design the simple flow to allow the registration process for one employee. And finally deploy your analysis and design to build a complete program.
Given a square matrix, calculate the absolute difference between the sums of its diagonals. For example, the square matrix m is shown below:
1 2 3
4 5 6
7 8 9
The left-to-right diagonal = 1 + 5 + 9 = 15. The right to left diagonal = 3 + 5 + 7 =15. Their absolute difference is |15 – 15| = 0
Sample Input
3
11 2 4
4 5 6
10 8 12
Sample output
17
Note: The number 3 on the first line of input represent the dimension of the square matrix. In this case, it’s a 3 x 3 two-dimensional array.
Define a VB.NET sub procedure known as Bus() which takes departure time, fare and destination as parameters then displays the Bus fare based on the three parameters else it displays appropriate error mechanism using appropriate mechanism