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

Largest Digit

This one is a bit tricky. You're going to have to isolate each digit of the integer to determine which one is the largest, so good luck!


Instructions:

  1. Input a 3-digit integer.
  2. Print the largest digit in the integer.
  3. Tip #1: Use % 10 to get the rightmost digit. For example, if you do 412 % 10, then the result would be the rightmost digit, which is 2.
  4. Tip #2: On the other hand, use / 10 to remove the rightmost digit. For example, if you do 412 / 10, then the result would be 41.
  5. Tip #3: You'd have to repeat Tip #1 and Tip #2 three times for this problem because the input is a 3-digit integer.

Instructions

  1. Input one 3-digit integer.
  2. Print the largest digit in the integer. (Hint: use % 10 to get the rightmost digit and / 10 to remove it)

Input

A line containing a three-digit integer.

173

Output

A line containing a single-digit integer

7


"The code should use If-Else-Elseif statement"


Write an application for a lawn-mowing service. The lawn-mowing season lasts 20 weeks. The weekly fee for mowing a lot under 4,000 square feet is R25. The fee for a lot that is 4,000 square feet or more, but under 6,000 square feet, is R35 per week. The fee for a lot that is 6,000 square feet or over is R50 per week. Prompt the user for the length and width of a lawn USING JOPTIONPANE, and then display the weekly mowing fee USING JOPTIONPANE , as well as the 20-week seasonal fee. Save the file as Lawn.java.

Marks allocation 

1. The use of class and object - 10

2. The use of JOption for input -10

3. The use of JOption for output-10

4. correct out -10

 


3.1 Write a Java program that will compute the future investment value at a given interest rate for a specified number of years. The java program should have a minimum of two classes.

3.1.1 classA

 The main method (starting point) (5)

 The object of classb (5)

 Should also call the void method named futureInvestmentValue (double investment Amount, double monthlyInterestRate, int years) (15)

3.1.2 classB

 A get method named count_words(String str) (15)

Expected Output:

Input the investment amount: 28000

Input the rate of interest: 7

Input number of years: 6

Years Future Value

1. 30024.12

2. 32194.57

3. 34521.92

4. 37017.51

5. 39693.51

6. 42562.95 


4. Operation: Operation

by CodeChum Admin

You have been cordially invited to partake in Operation: Operation. Your mission, should you choose to accept it, is to take the two numbers and the operator given then perform the operation successfully.


Instructions:

  1. Input one number (integer or decimal), an operator (+, -, *, /), and another number (integer or decimal).
  2. Print the result of the operation between the two numbers, up to 2 decimal places.

Instructions

  1. Input one number (integer or decimal), an operator (+, -, *, /), and another number.
  2. Print the result of the operation between the two numbers, up to 2 decimal places.

Input

The first line contains the first number.

The second line contains the operator.

The third line contains the second number.

5
+
0.70

Output

A line containing a decimal/float containing two decimal places.

5.70


"The code should use If-Else-Elseif statement"


Write Java statements that accomplish the following.

1. Declare int variables x and y.

2. Initialize an int variable x to 10 and a char variable ch to 'B'.

3. Update the value of an int variable x by adding 5 to it.

4. Declare and initialize a double variable payRate to 12.50.

5. Copy the value of an int variable firstNum into an int variable tempNum.

6. Swap the contents of the int variables x and y. (Declare additional variables, if

necessary.)

7. Suppose x and y are double variables. Output the contents of x, y, and the expression

x + 12 / y – 18.

8. Declare a char variable grade and set the value of grade to 'A'.

9. Declare int variables to store four integers.

10. Copy the value of a double variable z to the nearest integer into an int variable x


design a car model class under package :package 3 with the following attributes: member field name licence number model current mileage engine size type string string double integer mark all the attributes as private & create appropriate getters & setters design another class as mainunder package :package3, where you need to implement logic as follows: you need to take the number of cars as input and then take each car's necessary information and put them in array. then at end show them in well-designed format.

We have to calculate the area of a rectangle, a square and a circle. Create an abstract class 'Shape' with three abstract methods namely 'RectangleArea' taking two parameters, 'SquareArea' and 'CircleArea' taking one parameter each. The parameters of 'RectangleArea' are its length and breadth, that of 'SquareArea' is its side and that of 'CircleArea' is its radius. Now create another class 'Area' containing all the three methods 'RectangleArea', 'SquareArea' and 'CircleArea' for printing the area of rectangle, square and circle respectively. Create an object of class 'Area' and call all the three methods.


Write a program that calculates and prints the bill for a cellular telephone company.

Create a program that will String input. Based on the number of inputs,

the USER will decide what shape it is circle,rectangle,square and triangle.

(1 input – circle, 2 inputs – square or rectangle, 3 inputs - triangle).

The program will then display the shape type, details, perimeter and area.


Justines-MacBook-Pro:classes Justine$ java-jar Shape.jar15

Type:Circle

Radius:15

Perimeter:94.2

Area:706.5


Justines-MacBook-Pro:classes Justine$ java-jar Shape.jar15

Type:Rectangle

Length:24

Width:12

Perimeter:72.0

Area:288.0


Justines-MacBook-Pro:classes Justine$ java-jar Shape.jar15

Type:Square

Side:12

Perimeter:48.0

Area:144.0


Justines-MacBook-Pro:classes Justine$ java-jar Shape.jar 9 15 12

Type:Triangle

Sides:9, 15, 12

Perimeter:36.0

Area:54.0


Justines-MacBook-Pro:classes Justine$ java-jar Shape.jar 9 15 12 8

Invalid input


class:

-TestShape

-Shape

-Circle

-Rectangle

-Square

T-riangle


Create a class Point2D , in package-"p1":for representing a point in x-y co-ordinate system. Create a parameterized constructor to init x & y co-ords. Add a method to return string form of point's x & y co-ords

(Hint:public String getDetails())

Add isEqual method to Point2D class :a boolean returning method : must return true if n only if both points are having same x,y co-ords or false otherwise.

Add calculateDistance method to calculate distance between current point and specified point & return the distance to the caller.

(Use distance formula . Use java.lang.Math class methods-sqrt, pow etc)

Write TestPoint class , in package "p2" , with a main method, Accept co ordinates of 2 points from user (Scanner) to create 2 points (p1 & p2)

Use getDetails method to display point details.(p1's details & p2's details)

Invoke isEqual & display if points are same or different

If they are not located at the same position , display distance between p1 & p2


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS