java代写 java代码代写 java程序代写 java作业代写

Java代写,Java作业代写,Java程序代写,Java Final代写

INFO1113 Final Exam,Java Final代写,留学java代写


1. What will be output of the following program shown in Figure 1? Explain your answer.


2. The following Java program shown in Figure 2 returns compile time error. Identify all the 6 marks errors and correct them.

java代写,java final代写

Do not write the entire program. Just mention the line numbers which are incorrect and then write the required changes in those lines to get the following output:

Android App Don’t show Ad


3. Suppose you had a linked list object, and you added the five numbers: 123, 456, 789, 658 and 527 in that order. What would be the output if you called the following method shown in Figure 3 on the head node of the linked list? Explain your answer.


4. Create a class GiftCard (Figure 4A) that represents a gift card for the purchase of books 9 marks

online. It should have the following private attribute: amount - the amount of money on the card

and the following public methods:

GiftCard(double amount) - a constructor to initialize the card

void buyBook(double totalPrice) - records the purchase of books by decreasing the amount of money used for purchase using this card and prints “Books bought successfully”. Print an error message if the gift card does not have sufficient amount to pay the totalPrice.

double amountRemaining() - returns the remaining amount of money in the gift card.


5. Create an interface called BasePolygon that has a default method called display() which 9 marks

simply prints “This is a Polygon”.

Create another interface called Polygon that extends BasePolygon interface and has an

abstract method calculateArea().

Create a class Rectangle that implements the interface Polygon. It has two private attributes height and width. The constructor has two parameters and initializes height, width with those parameters. Define the method calculateArea() so that it outputs the area of a rectangle.


6. Create a generic class called ShoppingCart. Use a ArrayList> to store all the items information added to the shopping cart. You need to create an Item class that contains two public attributes ItemName, ItemPrice of type N, P respectively and a constructor to initialize those attributes.

The ShoppingCart class should contain the following three public methods and a constructor:

addItem(N name, P price) to add an item to the shopping cart.

removeItem(N name) to remove an item from the shopping cart. If the item does not exist, print " not Found in your cart" otherwise print " Removed from your cart".

checkout() to print the list of items in the shopping cart

java代写,java final代写

7. Write a java program to read the age of each person in a HashMap from the standard I/O. The HashMap contains the person’s name and their age. Display the name of the person in each category as follows: age less than 16 is “Not eligible to drive” category, greater or equal to 16 means “Eligible to drive”. You may assume that the age will always be a non-negative integer.

京ICP备2025144562号-1
微信
程序代写,编程代写
使用微信扫一扫关注
在线客服
欢迎在线资讯
联系时间: 全天