Java | JSP | JSF Answers

Questions: 3 611

Answers by our 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 & Filtering

1.      Write a Java program to rearrange a given array of unique elements such that every second element of the array is greater than its left and right elements.  

 

Example:

Input :

nums= { 1, 2, 4, 9, 5, 3, 8, 7, 10, 12, 14 }

Output:

Array with every second element is greater than its left and right elements:

[1, 4, 2, 9, 3, 8, 5, 10, 7, 14, 12]

 

2.      Write a Java program to form the largest number from a given list of non-negative integers.  

 

Example:

Input :

nums = {1, 2, 3, 0, 4, 6}

Output:

Largest number using the given array numbers: 643210

 

3.      Write a Java program to shuffle a given array of integers.

 


 

4.      Write a Java program to find maximum product of two integers in a given array of integers.  

 

Example:

Input :

nums = { 2, 3, 5, 7, -7, 5, 8, -5 }

Output:

Pair is (7, 8), Maximum Product: 56



1.      Write a Java program to find the maximum and minimum value of a 1-d array.

 

2.      Write a Java program without using a second array to reverse elements of each row of a 2-d array of integer values.

e.g.      1    2   3    4                                      4    3    2  1

               5    6   7    8          è                    8    7    6  5

             9   10  11 12                                    12  11  10  9

 

3.      Write a java program to print the Pascal’s Triangle using a 2-d array.

 

4.      Write a Java program to convert an array to an ArrayList, and an ArrayList to an array.

 

5.      Write a Java program to arrange the elements of a given array of integers where all negative integers appear before all the positive integers.



Implement your own version of the priority queue data structure using java with OOPs principles mentioned functionalities: enqueue, Dequeue (highest priority), peek(highest priority), contains, size, center, sort reverse, iterator, traverse/print.

Use of similar data structures already present in the language/framework is not allowed.


Implement your own version of queue data structure using java with OOPs principles mentioned functionalities: enqueue, Dequeue , peek, contains, size, center, sort reverse, iterator, traverse/print.

Use of similar data structures already present in the language/framework is not allowed.


1)     Write a program that accepts the amount of money deposited in a bank account, the annual interest rate and the target amount (The amount of money the account holder wants to have in the account after a period of time) and then calculates the number of years it will take for the money to accumulate to the targeted amount. NB: 1) The interest being earned is Compound Interest. 2) Don’t use the formula for calculating compound interest.

For example if the money deposited is 10000 and the target amount is 20000 and the account earns an interest rate (compound) of 10% pa, then the output should be: -

It will take 8 years for your money to reach your target.

By the end of this period, the amount in your account will be 21435.89    


Bookong List Programming--developer needs to input the following information from the console using programming to view the booked ticket history for a passenger.

*passenger id: a 7 digit number for passenger id for whom booking is to be done.

*on submitting the passenger id,the console shows rows with columns populated from inserted array/list/appropriate collections; PNR NO|Travel date| source|destination|Seat preference|Meal preference


ticket booking programming;--Developer needs to input the following from the console using programming to book ticket for a passenger:

-passenger id:a 7 digit number for passenger id for whom booking is to be done.

-pnr no:a string field for pnr no with a default 7 digit number.

-travel date:a string field to enter the journey date in format(dd/mm/yyyy).

-source:a string field to capture the source airport.

-destination:a string field to capture the destination airport.

-status:a string field to select among following values new/confirm/hold.

-seat preference:a string field to select among following values,middle,aisle.

-meal preference:a string field to select among following values.

**once all fields are taken input,booking details need to be inserted in array/list/appropriate collection.after successful booking,a booking acknowledgment message need to be displayed on the console as "ticket booked successfully,Happy Journey...".


developer needs to input the following information from the console using programming to register passenger:passenger id:a random 7 digit number for passenger id with a default value;....passenger name:a string field for passenger name(maximum 50 characters);....email:a string field to capture the email;....password:a string field for password(maximum 30 characters);....Address:a string field to capture street,city details(maximum 100 characters);...Contact number:text field(maximum 10 characters);....once all fields are taken as input,passenger details need to be inserted in array/list/appropiate collection.after successful registration,a registration acknowledgment message need to be displayed on the console as "passenger registration is successfull".


1)     Write a program that accepts a set of integers (the user decides how many) and then stores them in an array. The main function then passes these values one by one to a method called get_even which returns 1 if the integer is even and 0 if it is odd. The main function should then specify which numbers were even, which ones were odd and their respective totals. It should also specify how many numbers were odd and how many were even. For example, if the user enters 25 34 56 17 14 20, the output should be: -

25 is an odd number

34 is an even number

56 is an even number

17 is an odd number

14 is an even number

20 is an even number 


There is a total of 2 odd numbers and their sum is 42.

There is a total of 4 even numbers and their sum is 124.

NB: All data input and output should be done in main. Don’t use % any where in the main function (% can be used in the method).                                 


6.      Write a Java program that will print the following series until it reaches 100.

 

1 1 2 3 5 8 13 …………………………

 

7.      Write a java program to find the sum of the series up to the nth term where n is input by the user.

1+(1+n)+(1+n+n)+(1+n+n+n)……………….nth Term

Example: input n = 6

Output: 1+7+13+19+25+31 = 96



LATEST TUTORIALS
APPROVED BY CLIENTS