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:
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:
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.