حل واجبات الجامعة العربية المفتوحة
اتصل : O544321455 - OO966544321455
واتس اب: 966544321455+
ايميل : a_al_shora@hot mail.com
سكايبي : a_al_shora
حل واجب 0.5.4.4.3.2.1.4.5.5 الجامعة العربية المفتوحة
حل واجبات الجامعة العربية المفتوحة O54.4.3.2.1.4.5.5 - OO96654.4.3.2.1.4.5.5
ايميل : a_al_shora @ h.o.t.m.ail.c.o.m
سكايبي: a_al_shora
واتس اب: OO96654.4.3.2.1.4.5.5
1
Faculty of Computer Studies
Information Technology and Computing Program
M105 Tutor-Marked Assignment
Course Code: M105 Semester: Spring 2013-2014
Course Title: Introduction to Programming with Java Credit Hours: 3 Hours
Cut-Off Date: Sunday, May 4, 2014 Total Marks: 80
Contents
Preface……………………………………………………………………………………………
1
Instructions for submitting TMA………………………………………………………………..
Question One: [12 marks]
a. Write a Java class (program) that reads from the user 2 integers that
represent the radius of a circle and the angle (in degrees) of a sector inside
this circle.
Then calculates and prints the area of this sector (rounded to 2 decimal
places) according to the following formula:
where is the angle of the sector (in radians) [11 marks] Hint: Read about "Converting degrees to radians" in any "geometry" book, or search the internet.
b. Give the exact output of your program. Provide a snapshot representing the exact output of any values from your choice. [1 mark]
Question Two: [20 marks]
a. According to Wikipedia, "The body mass index (BMI) is a measure for human body shape based on an individual's mass and height". Your task is to write a Java application that reads from the user his/her mass (in kilograms) and height (in meters) as real numbers, then prints a simple message explains the status of the user (using nested if-else statements) as follows: - "Underweight" if BMI < 18.5 - "Normal" if 18.5 ≤ BMI < 25 - "Overweight " if BMI ≥ 25 [17 marks] Hint:
b. Give the exact output of your application. Give 3 snapshots representing the exact output of 3 different cases (i.e., when the user is underweight, normal and overweight). [3 marks]
3
Question Three: [20 marks]
a. Write a Java program that reads from the user 2 integers and count all the numbers between them (inclusive) that are divisible by either 3 or 5 but not both. [18 marks]
b. Give the exact output of your program. Provide 2 snapshots representing the exact output of 2 different inputs. [2 marks]
Hints:
• The user should insert the 2 numbers in the same line using only one prompt message.
• You could assume that user will insert positive integers and that the first number is less than or equal to the second number
Sample Input and Output: Please, insert two positive integers with a single space between them: 4 18 There are 6 numbers between 4 and 18 which are divisible by either 3 or 5 but not both
Explanation: Only 6 numbers satisfy the condition which are 5, 6, 9, 10, 12 and 18
Question Four: [25 marks]
a. Assume that we have a list of employees' names of a company and their ages. Write a program that reads from the user several lines of input. Each line includes an employee's name and his/her age (as an integer). The program should calculate and print the following:
• The average age of all employees (rounded to 2 decimal places).
• The oldest employee and his/her age. [24 marks]
b. Give the exact output of your program. Provide a snapshot representing the exact output of any values from your choice. [1 mark]
Hints:
• You could assume that the user will insert valid data and at least one employee.
• You could assume that the oldest employee is only one person.
• User could stop the program via entering the word "end" as an employee's name.
Sample Input and Output: In each line, insert an employee's name and his/her age To halt the program, insert "end" as an employee's name ----------- Sultan 30 Mona 41 Hisham 45 Adel 30 end ----------- The average age of all employees is 36.50 The oldest employee is Hisham whose age is 45
Input from the user
Input from the user
حل واجبات الجامعة العربية المفتوحة
اتصل : O544321455 - OO966544321455
واتس اب: 966544321455+
ايميل : a_al_shora@hot mail.com
سكايبي : a_al_shora
حل واجب 0.5.4.4.3.2.1.4.5.5 الجامعة العربية المفتوحة
حل واجبات الجامعة العربية المفتوحة O54.4.3.2.1.4.5.5 - OO96654.4.3.2.1.4.5.5
ايميل : a_al_shora @ h.o.t.m.ail.c.o.m
سكايبي: a_al_shora
واتس اب: OO96654.4.3.2.1.4.5.5
اتصل : O544321455 - OO966544321455
واتس اب: 966544321455+
ايميل : a_al_shora@hot mail.com
سكايبي : a_al_shora
حل واجب 0.5.4.4.3.2.1.4.5.5 الجامعة العربية المفتوحة
حل واجبات الجامعة العربية المفتوحة O54.4.3.2.1.4.5.5 - OO96654.4.3.2.1.4.5.5
ايميل : a_al_shora @ h.o.t.m.ail.c.o.m
سكايبي: a_al_shora
واتس اب: OO96654.4.3.2.1.4.5.5
1
Faculty of Computer Studies
Information Technology and Computing Program
M105 Tutor-Marked Assignment
Course Code: M105 Semester: Spring 2013-2014
Course Title: Introduction to Programming with Java Credit Hours: 3 Hours
Cut-Off Date: Sunday, May 4, 2014 Total Marks: 80
Contents
Preface……………………………………………………………………………………………
1
Instructions for submitting TMA………………………………………………………………..
Question One: [12 marks]
a. Write a Java class (program) that reads from the user 2 integers that
represent the radius of a circle and the angle (in degrees) of a sector inside
this circle.
Then calculates and prints the area of this sector (rounded to 2 decimal
places) according to the following formula:
where is the angle of the sector (in radians) [11 marks] Hint: Read about "Converting degrees to radians" in any "geometry" book, or search the internet.
b. Give the exact output of your program. Provide a snapshot representing the exact output of any values from your choice. [1 mark]
Question Two: [20 marks]
a. According to Wikipedia, "The body mass index (BMI) is a measure for human body shape based on an individual's mass and height". Your task is to write a Java application that reads from the user his/her mass (in kilograms) and height (in meters) as real numbers, then prints a simple message explains the status of the user (using nested if-else statements) as follows: - "Underweight" if BMI < 18.5 - "Normal" if 18.5 ≤ BMI < 25 - "Overweight " if BMI ≥ 25 [17 marks] Hint:
b. Give the exact output of your application. Give 3 snapshots representing the exact output of 3 different cases (i.e., when the user is underweight, normal and overweight). [3 marks]
3
Question Three: [20 marks]
a. Write a Java program that reads from the user 2 integers and count all the numbers between them (inclusive) that are divisible by either 3 or 5 but not both. [18 marks]
b. Give the exact output of your program. Provide 2 snapshots representing the exact output of 2 different inputs. [2 marks]
Hints:
• The user should insert the 2 numbers in the same line using only one prompt message.
• You could assume that user will insert positive integers and that the first number is less than or equal to the second number
Sample Input and Output: Please, insert two positive integers with a single space between them: 4 18 There are 6 numbers between 4 and 18 which are divisible by either 3 or 5 but not both
Explanation: Only 6 numbers satisfy the condition which are 5, 6, 9, 10, 12 and 18
Question Four: [25 marks]
a. Assume that we have a list of employees' names of a company and their ages. Write a program that reads from the user several lines of input. Each line includes an employee's name and his/her age (as an integer). The program should calculate and print the following:
• The average age of all employees (rounded to 2 decimal places).
• The oldest employee and his/her age. [24 marks]
b. Give the exact output of your program. Provide a snapshot representing the exact output of any values from your choice. [1 mark]
Hints:
• You could assume that the user will insert valid data and at least one employee.
• You could assume that the oldest employee is only one person.
• User could stop the program via entering the word "end" as an employee's name.
Sample Input and Output: In each line, insert an employee's name and his/her age To halt the program, insert "end" as an employee's name ----------- Sultan 30 Mona 41 Hisham 45 Adel 30 end ----------- The average age of all employees is 36.50 The oldest employee is Hisham whose age is 45
Input from the user
Input from the user
حل واجبات الجامعة العربية المفتوحة
اتصل : O544321455 - OO966544321455
واتس اب: 966544321455+
ايميل : a_al_shora@hot mail.com
سكايبي : a_al_shora
حل واجب 0.5.4.4.3.2.1.4.5.5 الجامعة العربية المفتوحة
حل واجبات الجامعة العربية المفتوحة O54.4.3.2.1.4.5.5 - OO96654.4.3.2.1.4.5.5
ايميل : a_al_shora @ h.o.t.m.ail.c.o.m
سكايبي: a_al_shora
واتس اب: OO96654.4.3.2.1.4.5.5