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

Passenger fare is classified according to the type of passenger. Senior Citizen enjoys 20%

discount from the regular fare, Students get 10% discount. Regular passengers who do

not qualified as neither Senior Citizen nor a Student should pay the regular fare of 150.

Write an algorithm that will accept details of five (5) passengers, including its name and

passenger type and will compute for the corresponding fare of each passenger. Display

the name and type of passenger, as well as the computer fare.


Write a multithreading program to get the maximum limit from the user to find the sum of odd and even numbers. Create a thread to find the even numbers from 1 to the maxlimit and get the summation. Similarly create another thread to find the odd numbers from 1 to maxlimit and get the summation. In the main thread the summation of both the odd sum and even sum should be calculated. 


Body Mass Index (BMI) is one of the criteria that is used to calculate whether one is fit or not basing on a person’s height (m) and weight (kg). The criterion is very simple; if one’s BMI is 25 or greater, it signifies overweight. A BMI less or equal to 18.5 indicates underweight. Lastly, a BMI greater than 30 shows obesity. You have been requested to create a program that that helps the Namibian Defence Forces’ (NDF) Captain to calculates the BMI of a person (BMI = height/weight2) and also determine whether the person has also completed running 10 km in the required time. Men should complete 10km in less than 60 minutes for them to be accepted. Women should do that under 80 minutes. Both males and females are accepted if their BMI is less than 25 and greater than 18.5. For 2018 intake, there are already 6 males selected and 1 female. The values for gender, mass and weight are enter by user inputs 


Create a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop should ask the user whether he or she wishes to perform the operation again. If so, the loop should repeat; otherwise it should terminate 


Using a for loop create a program that will prompts the user for two numbers and then print out a list of even number in between the two given numbers(inclusive), starting from the small number to the big number


Using a switch statement, write a program that prompts the user for a numeric code and two operands. The numeric codes of 1, 2, 3, and 4 represents addition, subtraction, multiplication, and division respectively. Before division, your program should check whether the second operand is not zero. If it is, it should display “Division by zero not allowed” to the screen.  


To qualify for an International Conference for Women in Computing (ICWC) next year in Toronto, Canada a student have got a distinction (a mark greater than 75) in PRG510S, be a female, and below the age of 25. Write a simple program that receives a mark, gender, and age from the keyboard and displays a corresponding message basing on the input.  


write a java program that accepts an ordinary number and outputs its equivalent roman numerals. the ordinary numbers and their equivalent roman numerals are given below: ordinary numbers roman numerals.


You are given an array of N non-negative integers: A1, A2, ..., AN. An alternating subsequence is a subsequence in which the indices of any two consecutive elements differ by exactly two in the original array. That is, if Ai1, Ai2, ..., Aik is some subsequence, then for it to be an alternating subsequence, (i2 - i1 = 2), (i3 - i2 = 2), and so on should all hold true. Among all alternating subsequences, find the one which has maximum sum of elements, and output that sum.

Input
The first line of the input contains an integer T denoting the number of test cases.

The first line of each test case contains an integer N denoting the number of elements in the array.

The second line contains N space-separated integers A1, A2, ..., AN denoting the array A.

Output
For each test case, output a single line containing the answer.

Note
A subsequence with only a single integer is also an alternating subsequence.
Constraints
1 ≤ T ≤ 10
1 ≤ N ≤ 105
0 ≤ Ai ≤ 105

Misha was playing with Balanced Brackets alone. Mykhailo also wanted to play the game with her, so he comes up and asks her a question.

Misha is allowed to chose a sub-sequence (i.e. not necessarily contiguous substring) of brackets. AFTER chosing a the sub-sequence, she is allowed to re-arrange it (if needed) such that this chosen sub-sequence (after rearrangement) is balanced. Find the maximum length of this sub-sequence. (Please note that the resulting sub-sequence , after rearrangement MUST be balanced.)

Input:

  • First line will contain T
  • T, number of testcases. Then the testcases follow.
  • First line of each test case has an integer N
  • N, denoting length of string.
  • Second line of each test case has a string S
  • S which is the string. String will only consist of '(' and ')'.

Output:

For each testcase, the maximum possible length of balanced string.

Constraints

  • 1≤T≤10
  • 1≤T≤10
  • 1≤|S|≤10
  • 5
  • 1≤|S|≤105
  • String will only consist of '(' and ')'.
LATEST TUTORIALS
APPROVED BY CLIENTS