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

Harry loves numbers in the range [m1, m2] (m1 and m2 included). carry decides to gift harry an array of numbers for his birthday. harry wants to find the number of pairs of indices [l, r] for which the sum of all the elements in the range [l, r] lies between m1 and m2.   

  1. Come up with an algorithm with a worst case complexity of O(N2).
  2. Now improvise this algorithm, assuming all numbers are positive integers.  
  3. What if the numbers could be negative as well? Can you think of an O(nlogn) solution in this case? (Hint: use sorting)  
The point of this exercise is to (1) use some of the arithmetic
operators, and (2) start thinking about compound entities (like time of day)
that are represented with multiple values.
1. Create a new program called Time.java. From now on, we won’t remind
you to start with a small, working program, but you should.
2. Following the example program in Section 2.4, create variables named
hour, minute, and second. Assign values that are roughly the current
time. Use a 24-hour clock so that at 2:00 PM the value of hour is 14.
3. Make the program calculate and display the number of seconds since
midnight.
4. Calculate and display the number of seconds remaining in the day.
5. Calculate and display the percentage of the day that has passed. You
might run into problems when computing percentages with integers, so
consider using floating-point.
6. Change the values of hour, minute, and second to reflect the current
time. Then write code to compute the elapsed time since you started
There is an android distance converter application , that inputs distance (ie. in feet or yards ) and facilitates user to convert into yards or feet You are required to write only java code to develop this application Sample of the application is given below. [10 Marks Following are formulas given for caluclations . Yards to Feet = input Feet to Yards = input 3
Write a program that prompts the user to enter five integers that you store in an array. Write a function called quadruple() that takes a single-integer parameter and multiplies it by 4, returning the result to the calling program. Call the function once for each of the five integers, then display the quadrupled results from within the main() function.
Create a class named Car. The Car class contains a static integer field named count. Create a constructor that adds 1 to the count and displays the count each time a Car is created. Create a destructor that subtracts 1 from the count and displays the count each time a Car goes out of scope. Write a main() function that declares an array of five Car objects. Output consists of five constructor messages and five destructor messages, each displaying the current count.
Create two classes DM and DB to store the value of distances.DM stores distances in meters and centimetres and DB in feet and inches. Write a program that can read values for the class object and add one object of DM with another object of DB. Use a friend function to carry out the addition operation. The object that stores the results may be a DM or DB object depending on the units in which the results are required. Type display should be in feet-inches or meter-centimetre depending on the object of display.

Question )  Implement an object oriented ’Character’ class to capture the common attributes and actions of all characters in your game.

Code) Read input from the keyboard to let the user provide values for your character’s attributes of a specific character object (not a superclass object) your code will create.

Code)  Since the user could mistype or introduce problems with their typed input, handle all exceptions with exception handling as part of your character data gathering code.

Code) Create a superclass character object, and call its attack method to demonstrate its use 



1)  Implement an object oriented subclass of Character, to simulate a specific kind of character in your game. For example, a ’warrior’ class. A warrior is a character, but a character is not necessarily a warrior.

2)  Include one unique data field for an attribute of the specific character that is not inherited or defined in Character class

3) Implement a method which overrides the Character attack method to make your subclass simulate a more specific kind of attack that relates to its type, with informative printouts


1) Implement an object oriented ’Character’ class to capture the common attributes and actions of all characters in your game. No need to make this class or the subclass public.

2) Declare two data fields for attributes of the character, one textual and one numeric.

3) Implement a constructor method to initialize data fields and set up the character object .

4) Since all characters can attack, implement a method to simulate the character object attacking in some generic way, including informative printouts


Create a Student class with instance variables name, roll, mark and instance methods setStudentDetails(), displayStudent(). One object of the Student class represents a specific student. Create a Singly Linked List in such a way that every node of the Linked List contains 2 parts: stud and link, where, stud stores the reference to a Student object and link stores the reference of the next node. Hence, the Node class (user defined type) has the following structure.


LATEST TUTORIALS
APPROVED BY CLIENTS