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

how long do you take to finish an assignment? mine is due 7th Nov 11:59pm


Constructor 
public Vehicle () { 
maxLoad=14.5;
} 
// default constructor 
public Vehicle () 
{ 
}
public Vehicle (int a, int b) 
{ 
//////
}
Call method form main method 
Vehicle x= new Vehicle ( ); 
x.setMaxLoad(14.5);   

Question1: According to Syntax in above, specify class name and its modifier?Question1: According to Syntax in above, specify class name and its modifier?






Playing game program for water sort puzzle

Write the code below for the two interfaces described given the rules below. 


The Network has two methods called connect and disconnect. The connect method takes a String argument called networkName and returns a boolean. The disconnect method returns a boolean and takes no arguments. 


The Ethernet interface inherits from the Network interface and adds two methods: plug and unPlug. The plug method takes an integer as argument called port and returns a boolean. The unPlug method returns a boolean and takes not arguments.


InstructionsPerform the following items. Mobile users may write their answers on a clean sheet of paper. (8 items x 5 points)

  1. Create a constructor named Exam that assigns "Good luck" to a previously declared String variable named message.
  2. Create an empty overloaded constructor for the Exam class with two (2) String parameters named period and level.
  3. Declare a double-type accessor named getPrice that returns the value of price.
  4. Declare a boolean-type accessor named isFinished that returns the value of status.
  5. Declare a class named Midterm that inherits from the class named Exam.
  6. Create three (3) class declarations to show multiple levels of inheritance. Use the classes named Exam, Midterm, and Essay.
  7. Create a constructor named Midterm that prints "Exam has started." using println(). Its first statement should be a call to a constructor in the parent class.
  8. Given the base class named Quiz and the derived class named Essay, write a statement to show inheritance between these classes.

Write a class Battery that models a rechargeable battery.

       totalCapacity: double

       availableBattery: double;( this contains battery charge available)

        String company;

·        having no parameter – for setting values to zero or null.

·        having two parameters for assigning values to both data members.

·        Overload the above constructor and use this keyword to set the values of data members

·        Provide getters and setters for data member(s).

·        The method public void drain (double amount) drains the capacity of the battery by the given amount.

·        The method public void charge (double amount) charges the battery by adding amount to availableBattery make sure it’s less  than totalcapacity.

·        A method toString to print object data.


1.     Inside main, create 3 objects.

a.     Set values of first object using constructor.

b.     Take data from user and set the values for the 2 objects and display values.

2.     Call all the above methods (drain, charge) and display updated values.



Suppose you want to deposit a certain amount of money into a savings account, and then leave it alone to draw interest for the next 10 years. At the end of 10 years, you would like to have $10,000 in the account. How much do you need to deposit today to make that happen? You can use the following formula, which is known as the present value formula, to find out: The terms in the formula are as follows: • P is the present value, or the amount that you need to deposit today. • F is the future value that you want in the account. (In this case, F is $10,000.) • r is the annual interest rate. • n is the number of years that you plan to let the money sit in the account. Write a method named presentValue that performs this calculation. The method should accept the future value, annual interest rate, and number of years as arguments. It should return the present value, which is the amount that you need to deposit today.


Problem:


Write a Java program that will convert a number(x) in base r to base 10.


The program should also meet the following requirements:


· Base r is an input and must be validated ; r is from 2 to 9 only


· The number x is an input and must be stored in an int type variable. Do not convert x to


string.


· Use of String type variable is not allowed.


· Use of arrays is not allowed.


· Use of built-in method that converts a given number to another base is not allowed.


· Your program should execute for as long as the user wants to continue


Assume that the user will input a valid number.


Note: This program converts X^r to Y^10


Where :


X^r - a number in base r


r – is from 2 to 9 only


Y^10 – the equivalent number in base 10


  • Write pseudocode to plan the logic for an application for a furniture company. The program needs to determine the price of a table depending on the user’s input.
  • Prompt the user to choose 1 for pine, 2 for oak, or 3 for mahogany.
  • The output is the name of the wood chosen, as well as the price of the table made of that wood. Pine tables cost $120, oak tables cost $325, and mahogany tables cost $420.
  • If the user enters an invalid wood code, set the price to 0, and inform the user what the error is.
  • Include a prompt in the application to ask the user to specify a (1) large table or a (2) small table but only if the wood selection is valid. Add $50 to the price of any large table, and add nothing to the price for a small table. Display an appropriate message if the size value is invalid, and assume the price is for a small table.
  • Include an explanation of your reasoning for writing the pseudocode the way you did.

Write a Java class Complex for dealing with complex number. Your class must have the following features:

  • Instance variables :
  • realPart for the real part of type double
  • imaginaryPart for imaginary part of type double.
  • Constructor:

o   Having no parameter – for setting values to zero or null.

o   Having two parameters for assigning values to both data members.

o   Overload the above constructor and use this keyword to set the values of data members

  • Instance methods:
  • public void setRealPart (double realPart): Used to set the real part of this complex number.
  • public void setImaginaryPart (double realPart): Used to set the imaginary part of this complex number.
  • public double getRealPart(): This method returns the real part of the complex number
  • public double getImaginaryPart(): This method returns the imaginary part of the complex number
  • public String toString(): This method allows the complex number to be easily printed out to the screen
LATEST TUTORIALS
APPROVED BY CLIENTS