AP Assignment 2022
AP Assignment 2022
Advanced Programming
Assignment
21h October 2022
25/03/1444
(20 marks: 15 for written answers and 5 for discussions)
Introduction
• The purpose of this assignment is to assess student in:
• CLO 2.5 (11 Marks): code programs that read, write, and modify text file.
• CLO 2.1 (9 Marks): create and use multidimensional Arrays.
• There are four questions in the assignment, and you are asked to fulfill all the requirements,
use the most appropriate datatypes, and use comments to explain your code.
• The answers should be your own.
• Use (Rafid) to submit your source files in a single .ZIP file.
• Each source code file must
• Contain a program header (a comment at the top of the source file that includes your
name, studentID, the date, and a brief description of your solution).
• An appropriate level of comments.
• Follow a consistent style of indentation.
• Follow the usual Java conventions for constant and variable names.
• The deadline for submitting your assignment through (Rafid) is 11:59 pm (Midnight), Friday,
4th November 2022 (10th of Rabi II 1444 H).
• When submitting work, it is your responsibility to ensure that all work submitted is
• Consistent with stated requirements
• Entirely your own work
• On time
• Marks will be awarded on the basis of the following scheme:
• Question 1 (50%): 10 marks
• Question 2 (25%): 5 marks
• Discussion and demonstration (25%): 5 marks (1 for Q1 and 4 for Q2)
Please note that there are severe penalties for submitting work which is not your own. If you have
used code which you have found on the Internet or from any other source, then you must signal that
fact with appropriate program comments.
Also, note that to obtain the mark you must attend a session to demonstrate your assignment and to answer
questions about any aspect of it. There will be a schedule for these sessions. So, make sure you attend your
session as non-attendance will result in your work not being marked.
1
Al-Baha University ﺟ ﺎﻣ ﻌ ﺔ اﻟﺑ ﺎﺣ ﺔ
Faculty of Computer Science and ﻛ ﻠﯾ ﺔ ﻋ ﻠو م اﻟﺣ ﺎﺳ ب و ﺗ ﻘ ﻧ ﯾ ﺔ اﻟﻣ ﻌ ﻠو ﻣ ﺎت
Information Technology
Question 1 (CLO 2.5): Developing programs that read, write, and modify
text file. [10 Marks]
2
Al-Baha University ﺟ ﺎﻣ ﻌ ﺔ اﻟﺑ ﺎﺣ ﺔ
Faculty of Computer Science and ﻛ ﻠﯾ ﺔ ﻋ ﻠو م اﻟﺣ ﺎﺳ ب و ﺗ ﻘ ﻧ ﯾ ﺔ اﻟﻣ ﻌ ﻠو ﻣ ﺎت
Information Technology
Section (2) [5 Marks]:
Write a java program that reads the scores from the file "outFile.txt" and then prints out the highest
and lowest scores among them to the console.
You should:
1. Open the file you created in the previous question: "outFile.txt"
2. Declare an array named mark of type int with size 10. You will use the array to store the
scores you read from the file.
3. Find and print out the highest and lowest marks using for loop from the stored elements in
the mark array.
3
Al-Baha University ﺟ ﺎﻣ ﻌ ﺔ اﻟﺑ ﺎﺣ ﺔ
Faculty of Computer Science and ﻛ ﻠﯾ ﺔ ﻋ ﻠو م اﻟﺣ ﺎﺳ ب و ﺗ ﻘ ﻧ ﯾ ﺔ اﻟﻣ ﻌ ﻠو ﻣ ﺎت
Information Technology
2 15 3 37
3 8 1 14
46 3 5 9
2. Print all elements of the array using for loops as shown in figure 3.
3. Check if the elements in the array are even or odd such that:
if the element is even, print out: element is even
else if the element is odd, print out: element is odd
Note: element is the number stored in the array.
Expected Output: