Java | JSP | JSF Answers

Questions: 4 418

Answers by our Experts: 3 943

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Consider a rectangular shape as an object that has two sides length and width as key attributes, another property is to check if the shape is a square or not. Apart from getters, setters and constructors, your class should have the following functionality listed below:


A) isSquare() : returns true if the values of length and width are equal

B) calculateArea() : Calculates the area of the shape provide with the respective formula, returning the Area with the formula used

C) calculatePerimeter(): Calculates the perimeter of the shape returning the result and formula used

D) Provide a toString() : to represent all the shape attributes and the value returned by the isSquare, including results for the Area and Perimeter as provided above


1. Implement class modelled above and test its functionality as specified below


Run1

Enter the length and width values separated by a space: 10 8

Enter the length and width values separated by a space: 6 6



Using User defined Input create a java code of this output.

Output:

Enter your name: Kevin Alonzo

Enter grade in Math: 90

Enter grade in English: 88

Enter grade in Filipino: 98

Enter grade in Science: 87

Enter grade in: P.E: 98

Kevin Alonzo This is your GPA.

This is your GPA 92.2


Consider a rectangular shape as an object that has two sides length and width as key attributes, another property is to check if the shape is a square or not. Apart from the ordinary instance methods such as getters, setters and constructors, your class should have the following functionality listed below:

A)   isSquare() : returns true if the values of length and width are equal

B)   calculateArea() : Calculates the area of the shape provide with the respective formula, returning the Area with the formula used

C)   calculatePerimeter(): Calculates the perimeter of the shape returning the result and formula used

D)  Provide a toString() : to represent all the shape attributes and the value returned by the isSquare, including results for the Area and Perimeter as provided above  

1.1.        Provide a simple Class and object diagram for the above scenario                         [30 Marks]


consider the time displayed on a digital clock( 07.30.00) with 3 main components hours, minutes and seconds as attributes. Apart from the ordinary instance methods such as getters, setters and constructors, your class should have the following functionality listed below

A) PM) returns true if the hour value is between 12 noon till midnight

B) to 12hourt): converts the provided time to 12 hour format considering the isPM function

C) Add Time() takes in another time and sum them up appropriately considering that there only 24 hours in a day

D) Provide a toString(): to represent the time with AM/PM if it's in 12 hour format 1.1.Provide a simple Class and object diagram for the above scenario

1.2. Implement class modeled above and test its functionality as specified below

Sample Run

Enter time (hh mm):19 24 30

Enter time (hh mm ): 06 15 10

Output:

19.24.30 isPM

06:15:10 isAM

19:24:30 to 12 hour format is 07:24:30 PM

19:24 30 PLUS 06:15:10=01:39:40

The addition result represented with to String: 01:39:40 AM

Create a simple program that will compute the employees salary.



Program should need the following:



1. Name of the employee.



2. Number of hours work for the week.



3. Number of hours absent.



4. Rate is 180/hour.



5. Compute the weekly salary.

Program to calculate discount If customer purchase clothes on Offseason, set discount 15% and on Onseason 40%


 Should use two classes, Onseason and Offseason


 Use two methods- discount(method name should be same)

Program to find the total salary by hand of an Employee


Class 1 Get basic pay, deduction, and bonus from the console.


Class 2 Calculate hra (5% of basic pay) and pf (20% of basic pay).


Class 3 Find the total salary (basicpay+hra-pf-deduction+bonus) and get the salary slip


Salary slip should contains :- basic pay, deduction, hra, pf, bonus and total salary by hand.

Program to check the addition result is divisible by 10



Class 1 - Return addition result of two numbers



Class 2 -Check the addition result is divisible by 10(use super keyword)

a point as an object with an x and y as key attributes, another properties is to check if the point is the origin or not. use methods such as getters, setters and constructors, your class should have the following functionality listed

isOrigin() : returns true if the values of x = 0 and y =0

distanceTo() : Takes in another point and finds the distance between the two points.

distanceToX(): Calculates the distance to the x-axis

Provide a toString() : to represent all the point attributes and the value returned by the isOrigin method  1.Provide a simple Class and object diagram for the above scenario 2.Implement class modelled above and test its functionality as specified below    

Sample Run1 

 Enter the x&y values separated by a space: 9 4

 Enter the x&y values separated by a space: 3 5

Output1:

Point A(9,4) not the Origin

Point B(3, 5) not the Origin

Distance from Point A(9,4) to Point B(3,5) = 6.08

Distance of Point B (3,5) to the X-axis = 5

Point A represented with toString : x = 9, y = 4 

isOrigin : False




fraction as an object with a numerator and denominator as key attributes, check if the fraction is positive or negative. Use instance methods such as getters, setters and constructors, your class should have functionality listed below:

A) isImproper() : returns true if the numerator is bigger than the denominator e.g 5/4

B) toMixed() : converts an improper fraction to mixed e.g. 9/4 = 4 1⁄2 C) AddFraction(): takes in another fraction and add them up as follows, a/b + c/d = (a x b) + (b x c) /bxd

D) Provide a toString() : to represent the fraction as X/Y or X/Y/Z for improper fractions 1.1. Provide a simple Class and object diagram for the above scenario

1.2. Implement class modelled above and test its functionality as specified below

Sample Run1

Enter the numerator and denominator separated by a space: 9 4

Enter the numerator and denominator separated by a space: 3 5

Output1:

9/4 is an Improper Fraction

3/5 is a Proper Fraction

9/4 PLUS 3/5 = 57/20

The addition result represented with toString : 2/17/20 


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS