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

Write a program to take a String as input then display the number of x characters word has in ascending order.

Example:

Enter a String

China is world most populous country

Number of 2 characters word : 1

Number of 4 characters word : 1

Number of 5 characters word : 2

Number of 7 characters word : 1

Number of 8 characters word : 1

Here, ascending is 2,4,5,7,8 don't return like 5,2,4,8,7

Hint: length(), charAt(), indexOf(), compareTo(), substring(), equals() can be used.

Note: Array, Split function as well as ternary operators i.e. ? : are not to be used.


Suppose there is XYZ Company and there are different departments like production,

marketing, finance, sales etc. Manager of the company want to know about the detail of the

employees who are highly paid. Write a program using the concept of classes to implement the

same. 


Plan, code and compile a BowlingLane class that will model a 5 Pin Bowling Lane. The bowling lane will have 5 pins which can be either upright or knocked down. Use 5 boolean variables to represent the pins. Next, create a client program that will:

  • instantiate a bowling lane object after prompting the user for the states of each of the 5 pins (up or down);
  • Display the bowling lane object to the user in a friendly way so they can clearly see which pins are up and which pins are down.
  • Using a separate method you must build into the bowling lane object, classify the lane configuration and display it to the user. The rules are as follows:
  • If pins 2 & 3 or 3 & 4 are down, display HS - Headsplit.
  • If pins 2, 3 & 4 are all down, display A - Aces.
  • If all the pins are down, display X - Strike.
  • display the sum of the pins that have been knocked down. NOTE! The pin values are different than the pin locations. Pins 1 & 5 are worth 2 points, pins 2 & 4 are worth 3 points, and pin 3 is worth 5 points.

Develop a Java program to compute and display all prime numbers between two numbers that the user enters(eg if the user enters 2 and 12 it displays 3,7,11 each in a new line. If the user enters the same numbera, program must keep giving an error message and prompting user to enter different numbers only. Use array to store numbers, use appropriate functions and control structures

The Fibonacci sequence is constructed by adding the last two numbers of the sequence so far to get the next number in the sequence. The first and the second numbers of the sequence are defined as 0 and 1. We get:

0, 1, 1, 2, 3, 5, 8, 13, 21…

 

Write a function which takes input as a number:

  • If the given number is a Fibonacci number, print the number
  • If the given number is NOT a Fibonacci number, print the sum of all odd Fibonacci numbers less than the given number.




Swati bought 600 shares of stock at a price of Rs 20 per share. She must pay her stock broker a 2% commission for the transaction.


Faizan and Hamza are brothers. In three years, Hamza will be five years younger than two time’s Faizan’s current age. Write a Java program to calculate and display Hamza’s age


Build a queue out of two completely separate stacks, S1 and S2. Enqueu operations happen by pushing the data on to stack 1. Dequeue operations are completed with a pop from stack 2. Obviously you will have to find some way to get the input stack information over to the output stack. Your job is to figure out how and when to do that, using only push and pop operation


Swati bought 600 shares of stock at a price of Rs 20 per share. She must pay her stock broker a 2% commission for the transaction.


Write a program that the display the following:

-The amount paid for the stock alone (without the commission)

-The amount of the commission

-The total amount paid 


The Fast Freight Shipping Company charges the following rates:


Weight of Package (in Kilograms) Rate per 500 Miles shipped

2 KG or less: Rs 1.10

Over 2 Kg but not more than 6 Kg: Rs 2.20

Over 6 KG but not more than 10 Kg: Rs 3.70

Over 10 KG but not more than 20 KG: Rs 4.80


Write a program that asks for the weight of the package and the distance it is to be shipped, and then displays the charges.

Input validation:

1. Do not accept values of 0 or less for the weight of the package.

2. Do not accept weights of more than 20 Kg (this is the maximum weight the company will ship).

3. Do not accept distances of less than 10 miles or more than 3,000 miles.


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS