MALAYSIA UNIVERSITY OF SCIENCE AND TECHNOLOGY
BIT1034: ADVANCED PROGRAMMING
ASSIGNMENT 1
INSTRUCTIONS
Use C#.NET 2017 or higher
Do ALL questions.
Write ONE program for each question.
Use suitable labels for your output.
1) Given the names and marks of n=7 students as in the code snippet below:
int i, min, max, n = 7;
double average, sum = 0;
string grade;
string [] name = {“Joe”, “Sam”, “May”, “Din”, “June”, “Kay”, “Wong”};
int[] mark = {45, 66, 80, 75, 95, 40, 77};
(a) Compute the grade (0-49 = F, 50-69 = C, 70-84 = B, 85-100 = A)
(b) Compute the minimum, maximum and average mark (rounded to 2 decimal places).
Your output should resemble as follows.
EXAM RESULTS
No. Name Mark Grade
1 Joe 45 F
2 Sam 66 B
3 May 80 B
4 Din 60 C
5 Jun 95 A
6 Kay 40 F
7 Wan 77 B
Minimum = 40
Maximum = 95
Average = 66.14
2) A factory has n=12 staff who are paid RM9.50 per hour. Their wages are calculated as follows:
wage = hours * rate for hours between 0 and <=40
= 380 + (hours – 40) * rate * 1.5 for hours >40 and <= 60
= 665 + (hours – 60) * rate * 2.0 for hours > 60
Write a program to generate a report that resembles the below.
PAYROLL REPORT
No. Employee name Hours Salary (RM)
1 AAA 10 75.00
2 BBB 45 356.25
3 CCC 60 675.00
….
Total salary = RM …
3) Write a program to generate 200 integer random numbers in the range [1000, 9999] in array x.
(a) How many of the numbers in x fall in the range: (i) 1000-2499, (ii) 2500-4999, (iii) 5000-7499 and (iv)
7500-9999?
(b) How many of the numbers in x are (i) even and (ii) divisible by 5?
(c) The average of all the numbers in x.
4) Write a program using function(s) to calculate the area and circumference of n=5 circles with radii r = 5.5,
6.6, 7.7, 8.8, 9.9 (rounded to 2 decimal places).
Your output should resemble as shown below.
CIRCLE AREAS and CIRCUMFERENCES
No. Radius Area Circumference
1 5.5 95.03 34.56
…
5) Implement Question 4 using class Circle.
6) Create a text file called contacts to store n=10 records, each with fields name, sex, age, telephone and
email address as follows:
Susan, F, 21, 2345678,
[email protected] ….
Write a program to read and display all the fields of each record.
7) Write a program to generate n=5 7-character passwords using the following categories:
Uppercase: A to Z
Lowercase: a to z
Digits: 0 to 9
Special characters: @ $ # ? % & * (no blank space)
8) Generate integer random numbers in the range [100, 999] in a 2-dimensional array x with m=5 rows, n = 8
columns. Calculate the minimum, maximum, sum, average (rounded to 2 decimal places).