IT232-Assignment-2 Questions-OOP

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

College of Computing and Informatics

Object Oriented Programming

Assignment 2
Deadline: Day 12/12/2021 @ 23:59
[Total Mark for this Assignment is 5]

Student Details:
Name: ### ID: ###

CRN: ###

Instructions:

e and one PDF file) using the Assignment Template on Blackboard via the allocated folder. These files must not be in compressed form
you have uploaded both the correct files.
Assign (e.g. misspell words, remove spaces between words, hide characters, use different character sets, convert text into image or langua

resented. This includes filling your information on the cover page.


n zero mark.
converted into an image, unless specified otherwise by the question.

s or other resources will result in ZERO mark.


Pg. 1 Question ThreeQuestion Three

Learning
Outcome(s): Question One 1.5 Marks

Develop a Write a java program that:


program based
a. Create an abstract class named Shape that contains three integers
on specification
using length, breadth, radius and an empty method named printArea().
programming b. Provide three classes named Rectangle, Triangle and Circle such that
language each one of the classes extends the class Shape.
elements
c. Each one of the classes contains only the method printArea() that read
including syntax,
the requested values and prints the area of the given shape.
d. Provide a class Main that create a rectangle, a triangle and a cercle then
print their respective areas.
Note: you should Include the screenshot of the program output as a part
of your answer. Otherwise, zero marks will be awarded.
Pg. 2 Question ThreeQuestion Three

Learning 2 Marks
Outcome(s): Question Two
Develop a Create a class called Invoice that a hardware store might use to represent an
program based invoice for an item sold at the store.
on specification
using a. An Invoice should include four information as instance variables: a part
programming number (type String), a part description (type String), a quantity of the
item being purchased (type int) and a price per item (double).
language
b. Your class should have a constructor that initializes the four instance
elements variables. Provide a set and a get method for each instance variable.
including syntax, c. In addition, provide a method named getInvoiceAmount that calculates
the invoice amount (i.e., multiplies the quantity by the price per item),
then returns the amount as a double value. If the quantity is not positive,
it should be set to 0. If the price per item is not positive, it should be set
to 0.0.
d. Write a tester class named InvoiceTest that demonstrates class Invoice’s
capabilities by creating two invoices then changing and printing their
characteristics.

Note: you should Include the screenshot of the program output as a part
of your answer. Otherwise, zero marks will be awarded.
Pg. 3 Question ThreeQuestion Three

Learning 1.5 Marks


Outcome(s): Question Three
Explain the
Write a complete Java program that do the following:
basic principles
of programming, a. Read your student’s ID number, store it in an array named myStudentNO
and print it.
concept of
b. find the number of even and odd integers in myStudentNO array
language, and
universal Note: Your program output should look as shown below
constructs of
programming

Note: you should Include the screenshot of the program output as a part
of your answer and you should enter your student id number. Otherwise
zero marks will be awarded.

You might also like