Java | JSP | JSF Answers

Questions answered by Experts: 3 611

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

2-We must calculate the banana price by supplying both how many KGs of bananas we are adding to the cart, and the price per KG in the constructor. The getCost() method will return the total cost based on these two values.
3- Lemon: This class also inherits from Fruit. You must supply a price per lemon and how many lemons we are adding through the constructor. The getCost() method will just return the cost of all the lemons.
The abstract Fruit.java class contains some methods and variables that it takes care of, and one method called getCost() that every inheriting subclass must Override given that each fruit object will calculate the cost differently.

1-Apple: The apple class inherits from Fruit. It accepts also the number of apples to add in the constructor. The price returned is per dozen! You must use the price already given to you in file Consts.java. The getCost() method must return the correct price for all the applies. For example, if the price per dozen is 24.0, and you added 3 apples, then the total cost of this class should return 6.0 QR.
The user enters the following code. What will be the value of
total after the code is executed?
val1 = 4;
val3 = 20;
total = sum(val1,val3);
Question: Create the following class in Java as specified in the UML diagram below:

SimpleCalc

+ SimpleCalc()
+ add(int, int):int
+ subtract (int, int):int
+ multiply (int, int): int
+ divide (int, int): double

• Create an application program (useCalc.java) with a main method. Within this method instantiate/create an object of SimpleCalc and test all four of its methods. Run the useCalc.java class.
A university posts its employees’ salaries at
http://cs.armstrong.edu/liang/data/Salary.txt. Each line in the file consists of a
faculty member’s first name, last name, rank, and salary (see Liang Book:
Programming Exercise 12.24). Write a program to display the total salary for assistant
professors, associate professors, full professors, and all faculty, respectively, and
display the average salary for assistant professors, associate professors, full professors,
and all faculty, respectively.
Can you help me code this please?

Develop and run a Complete Java applet to prompt user to input for radius of a cylinder and call methods CylinderVolume and CylinderSurfaceArea to calculate and display the area and perimeter of that rectangle using the assignment. Declare all variables as double data type and display the output to two digits after decimal point.

volume = 3.14 * radius^2 * height
surfacearea = 2 * 3.14 * radius (height + radius)

With this user interface:

----------------------------------------------------------------------------------------------------------------------

Enter Radius [Input Text Field]
Enter the height of the Cylinder [Input Text Field]

(Button to calculate volume) (Button to calculate surface area)

The Volume of Cylinder is [Output Text Field]
The Surface Area of a Cylinder is [Output Text Field]

----------------------------------------------------------------------------------------------------------------------
Create a class named Salesperson. Data fields for Salesperson include an integer ID number and a double annual sales amount. Methods include a constructor that requires values for both data fields, as well as get and set methods for each of the data fields. Write an application named DemoSalesperson that declares an array of 10 Salesperson objects. Set each ID number to 9999 and each sales value to zero. Display the 10 Salesperson objects. Save the files as Salesperson.java and DemoSalesperson.java.
The UML diagram for an Instantiable class Person is shown below:

Write an application program to create 5 person objects, with appropriate data, using a suitable array.
Using the information entered for the 5 objects, write methods to:
• count the number of females in the array
• count the number of people aged over 25
• find the average age of all males
• find the average age of all people

Person

-name:String
-age:int
-gender:char

+Person()
+Person(String, int, char)
+setName(String):void
+setAge(int):void
+setGender(char):void
+getName():String
+getAge():int
+getGender():char
+toString():String
The UML for an Instantiable class called Vehicle is shown below:

Write an application program that uses an array to create three Vehicle objects with appropriate data. Add code to display the contents of the array.



Vehicle

-regNo:String
-carMake:String

+Vehicle()
+Vehicle(String, String)
+setRegNo(String):void
+setCarMake(String):void
+getRegNo():String
+getCarMake():String
+toString():String
The UML for an Instantiable class called Vehicle is shown below:

Write an application program that uses an array to create three Vehicle objects with appropriate data. Add code to display the contents of the array.



Vehicle

-regNo:String
-carMake:String

+Vehicle()
+Vehicle(String, String)
+setRegNo(String):void
+setCarMake(String):void
+getRegNo():String
+getCarMake():String
+toString():String
LATEST TUTORIALS
APPROVED BY CLIENTS