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

+findLongestSubString(StringBuilder) : StringBuilder

-Should accept StringBuilder as input and return StringBuilder

-Should find the longest substring that appears at both ends of a given StringBuilder

-Should return "Longest substring is not present in the given StringBuilder" if longest substring does not exist

-Should return "Give proper input" if input is empty StringBuilder

Sample Input:

playerplay

Sample Output:

Play

Sample Input:

playerplays

Sample output:

Longest substring is not present in the given StringBuilder







Write a java program that will satisfy the given requirements using while loop:




A. It will display the given menu:




A - Arithmetic Series


B - Geometric Series


C - Harmonic Mean


D - Largest Prime Number


E - Largest Prime Number


Q - Quit the Program




B. The program will ask the user his/her choice.


C. If the choice is A,B,C,D or E, It will prompt the user for the required inputs, then compute and display the required outputs. If the choice is Q, the program will terminate


D. Validate all your inputs by promptingg for a new value if input is invalid.


E. Display also a description of your program


F. Program should execute for as long as the user wants to continue


G. Use of arrays is not allowed


Add a prompt to the CondoSales application to ask the user to specify a (1) garage or a (2) parking space, but only if the view selection is valid. Add $5,000 to the proce of any condo with a garage. If the parking value is invalid, display an appropriate message and assume that the price is for a condo with no garage.




Write a recursive method named series (int a, int n) that takes as a parameter an integer that may compute the following series:

-2, 7, 52, 2702… if a = -2 and n = 4


Then, write a full program to solve the above problem using recursion.


We now write the subclasses of Item to represent the actual multimedia items (viz.






CDs (music) and DVDs (movies)) we store. There are two issues to consider for






these subclasses:






• Note the rules for constructors require a call to the superclass constructor.






The idea is to call the superclass constructor to initialize the fields in the






superclass.






• Use overridden methods for subclass specific behaviour. In particular we






need to override the toString method as this is different for each subclass.






We will also override the depreciate method since each item depreciates






differently.











Write a class called Item. The Item class represents all that is common between



various multimedia items. It should have the following attributes (fields):



a) a String name to store the name of the item.



b) a String comment to store a comment about the item.



c) a double value to store how much the item cost.



It should have appropriate constructors and at least the following methods



a) getters and setters for the attributes.



b) a public String toString() method that returns a String representation of the



Item.



c) a method void depreciate() that decreases the value of the item by 5%.

8. Groupings



by CodeChum Admin




Did you know that you can also reverse lists and group them according to your liking with proper code? Let's try it to believe it.






Instructions:




Create a variable that accepts a positive odd integer.



Create an empty list. Then, using loops, add random integer values into the list one by one. The number of values to be stored is dependent on the inputted odd integer on the first instruction.



Reverse the order of the list. Then, print out the list's new order in this manner:



[first-half values]-[middle value]-[second-half values], just like that of the sample output. Make use of list slicing that you’ve learned from the past lessons to easily achieve this segment.



Input




The first line contains an odd positive integer.



The next lines contains an integer.




5



1



3



4



5



2



Output




A line containing a list.




[2,5]-[4]-[3,1]

7. Arraying 102



by CodeChum Admin




We've already made arraying/listing the easy way, but how about arraying/listing and printing the list in reverse order?






Make a program that will input an integer and then using loops, add items on an array/list one by one for the same number of times as that of the first inputted integer. Then, print out the array/list in reverse order, that is, starting from the last item on the array/list down to the first one, each in separated lines.




Input




The first line contains the size of the array/list.



The next lines contains the items of the array/list (integers).




5



1



64



32



2



11



Output




Multiple lines containing integers.




11



2



32



64



1

6. The GCD



by CodeChum Admin




The greatest common divisor, also known as GCD, is the greatest number that will, without a remainder, fully divide a pair of integers.






Now, I want you to make a program that will accept two integers and with the use of loops, print out their GCD. Make good use of conditional statements as well.




Off you go!




Input




A line containing two integers separated by a space.




6·9



Output




A line containing an integer.




3

5. FizzBuzz 2.0



by CodeChum Admin




Remember the game of FizzBuzz from the last time? Well, I thought of some changes in the game, and also with the help of loops as well. Firstly, you'll be asking for a random integer and then loop from 1 until that integer. Then, implement these conditions in the game:




print "Fizz" if the number is divisible by 3



print "Buzz" if the number is divisible by 5



print "FizzBuzz" if the number is divisible by both 3 and 5



print the number itself if none of the above conditions are met



Input




A line containing an integer.




15



Output




Multiple lines containing a string or an integer.




1



2



Fizz



4



Buzz



Fizz



7



8



Fizz



Buzz



11



Fizz



13



14



FizzBuzz

LATEST TUTORIALS
APPROVED BY CLIENTS