



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Java Program, Main Method, Helper Methods, Writing Programs, Graphical User, Packages, Array is Created, Default Constructor, Concrete Method, Boolean Expression are points of Advanced Applications Programming course exam.
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!




Exam Code(s) 1AE1, 1MIS1, 1MIS Exam(s) Masters of Business Studies in Electronic Commerce MSc. Information Systems Management full-time MSc. Information Systems Management part-time Module Code(s) MS8 15 Module(s) Advanced Application Programming Paper No. Repeat Paper External Examiner(s) Dr. Danail Ivanov Internal Examiner(s) Dr. Tom Acton Mr. Seamus Hill Instructions: Candidates are required to answer: Section A (20 Marks) Answer all 10 parts of section A, This section consists of 10 multiple-choice questions all of which should ideally be attempted. Answers are to be written on the MCQ sheet provided, NOT on the Examination paper. Section B (80 Marks) Answer Any Two Questions Duration 3 hrs Department(s) Accountancy & Finance Course Co-ordinator(s) Requirements : MCQ Yes, Type a-d
2 abstract class Student { 3 4 protected final static int NUM_OF_TESTS = 3; 5 6 protected String name; 7 8 protected int[] test; 9 10 protected String courseGrade; 11 12 public Student( ) { 13 this("No Name"); 14 } 15 16 public Student(String studentName) { 17 name = studentName; 18 test = new int[NUM_OF_TESTS]; 19 courseGrade = "****"; 20 } 21 22 abstract public void computeCourseGrade(); 23 24 public String getCourseGrade( ) { 25 return courseGrade; 26 } 27 28 public String getName( ) { 29 return name; 30 } 31 32 public int getTestScore(int testNumber) { 33 return test[testNumber-1]; 34 } 35 36 public void setName(String newName) { 37 name = newName; 38 } 39 40 public void setTestScore(int testNumber, int testScore) { 41 test[testNumber-1] = testScore; 42 } 43 44 } 45 46
47 class UndergraduateStudent extends Student { 48 49 50 public void computeCourseGrade() { 51 int total = 0; 52 53 for (int i = 0; i < NUM_OF_TESTS; i++) { 54 total += test[i]; 55 } 56 57 if (total / NUM_OF_TESTS >= 70) { 58 courseGrade = "Pass"; 59 } else { 60 courseGrade = "Fail"; 61 } 62 } 63 } 64 65 class GraduateStudent extends Student { 66 67 public void computeCourseGrade() { 68 int total = 0; 69 70 for (int i = 0; i < NUM_OF_TESTS; i++) { 71 total += test[i]; 72 } 73 74 if (total / NUM_OF_TESTS >= 80) { 75 courseGrade = "Pass"; 76 } else { 77 courseGrade = "No Pass"; 78 } 79 } 80 } 81 82 83 public class students { 84 85 public static void main(String[] args) { 86 Student[] roster = new Student[5]; 87 roster[0] = new GraduateStudent(); 88 roster[1] = new UndergraduateStudent(); 89 roster[2] = new UndergraduateStudent(); 90 roster[3] = new GraduateStudent(); 91 roster[4] = new GraduateStudent(); 92 for (int i = 0; i < roster.length; i++) { 93 roster[i].setTestScore(1, 70); 94 roster[i].setTestScore(2, 70); 95 roster[i].setTestScore(3, 70); 96 } 97 for (int i = 0; i < roster.length; i++) { 98 roster[i].computeCourseGrade(); 99 } 100 for (int i = 0; i < roster.length; i++) { 101 System.out.println("Grade " + roster[i].getCourseGrade()); 102 } 103 } 104 105 }
Enter temperature in fahreneit (e.g. 88): 80 Input: 80.0F is equivalent to Output: 26.67C