Skip to main content

Arrays, Object and Classes Concepts in Java | Practice Questions

Trainee Class Methods

Refer the below Class outline and implement the methods

public boolean findTrainee(Trainee trainee[],int traineeId)
public Trainee getTrainee(Trainee trainee[],int traineeId)
public int getCount(Trainee trainee[],String location)
public Trainee[] getAllTrainees(Trainee trainee[],String sequence)
public int[] getAllId(Trainee trainee[])

Toy Class

Create Class Toy with below attributes

name 
category 
price
discount

Create Class ToyDemo with main method. Create four toy objects with relevant data. Two objects should have category as “fruits” and other two objects should have category as “animal”. Write a method in this class which will take all four toy objects as input. Additionally, it will also take category name as input. This method should return least price toy name (considering the discount as well) for specified category. If there is no specific category (e.g category as “fruits”, method should return message “no category found”.

Follow class outline diagram as given below. Ensure class attributes are private and other methods are public. Use package “com” to build your solution.

NOTE: Use .equals for comparing String values instead of == operator. Search on net and find out why. Else discuss among colleagues.

Car Class

Create class Car with below attributes: make

model
passenger
Capacity 
onRoadPrice

Create class CarDemo which has main method. Create another method - getBestCar in this class which will take four car objects and additional parameter as compareType. Value of this parameter can be ‘c’ or ‘p’, where ‘c’ stands for capacity of passengers and ‘p’ stands for on road price. This method will return make and model name for highest value of ‘c’ or ‘p’ (with – character in between. E.g for make – Hyundai and model – santro, method should return “Hyundai-santro”). Create four objects of Car class in main method and drive it through getBestCar method.
Follow class outline diagram as given below. Ensure class attributes are private and other methods are public. Use package “com” to build your solution.

Credit Card Company Class

Create class Customer with below attributes:

custId 
accountId
creditCardCharges

Create another class CreditCardCompany which has a method which takes Customer object as parameter and returns the payback amount for the credit card charges value for that customer. Use below logic to calculate payback amount:

a) 0.25% for charges up to Rs. 500.
b) 0.50% for the next Rs.1000 (that is, the portion between Rs. 500 and Rs. 1500),
c) 0.75% for the next Rs.1000 (that is, the portion between Rs. 1500 and Rs. 2500),
d) 1.0% for charges above Rs2500.

Thus, a customer who charges Rs. 400 a year receives Rs.1.00, which is 0.25 • 1/100 • 400, and one who charges Rs1, 400 a year receives Rs. 5.75, which is 1.25 = 0.25 • 1/100 • 500 for the first Rs. 500 and 0.50 • 1/100 • 900 = 4.50 for the next Rs. 900. Determine by hand the pay backs amount for a customer who charged Rs. 2000 and one who charged Rs. 2600.

Create another class as CreditCardDemo which will have main method. Within main method, create object of CreditCardCompany. Create 5 customer objects with relevant data. Call the method to return payback amount for each customer and display the same

CONTACT DETAILS

For any other questions or other tasks please feel free to contact me
via email: mhassnainjamil@gmail.com
via WhatsApp: +92-324-7042178
via skype: hassnainjamil1

Comments

Popular posts from this blog

The Zoo Management System - entity relationship diagram & MS Access Database

Zoo Management System - Project Details: You are the employee of a big, worldwide working Zoo Management Company. Your company is responsible for the Zoo management. Your boss thinks it would be a great idea to store all data for each Zoo in a brand new self-developed ZOO Management System. Up to now, the ZOO management company has maps of each ZOO available. Your boss knows that you took a course in introduction on an ERP system, so he asks you if you could help designing such a system. Each ZOO must have the same organizational structure, which should look like this: Each Zoo has a Zoo-Address. Each Zoo has many visitors (Visitor Ticket Process (VTP). Many Zoo-Attractions belong to a Zoo. Module 1: Entity Relationship Diagram Design a ER (entity-relationship) diagram for your ZOO Management System. Use the information provided below with the entities and its attributes. Put the entities in the correct relationship to each other (organizational structure). Module 2: DB Implem...

Human Physiology by Stuart Ira Fox [PDF] (12th edition) free download

Sudoku Game Project in Java with full source code including GUI task

Introduction The purpose of the project is to try in practice the use of recursion and object-oriented program design. Please make sure to read this entire note before starting your work. Pay close attention to the sections on deadlines, deliverables, and exam rules. The problem Your task in this part of the project is to write a solver for Sudoku puzzles. Sudoku puzzles are a kind of crossword puzzles with numbers where the following two conditions have to be met: In each row or column, the nine numbers have to be from the set [1,2,3,4,5,6,7,8,9] and they must all be different.  For each of the nine non-overlapping 3x3 blocks, the nine numbers have to be from the set [1,2,3,4,5,6,7,8,9] and they ust all be different. The following two figures show a Sudoku puzzle and its solution. The input The input of your program, the Sudoku puzzles, is given in text files. More specifically, they are represented as nine lines of nine characters separated by spaces. The characters can be of two...