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

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

Write a class Battery that models a rechargeable battery.

        Capacity: double

        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 () charges the battery to its original capacity.

·        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.


 Write Java code for implementing arrays that accepts user inputs and then displays them. Take different arrays like this: stringArray, integerArray, doubleArray.



(a)  Write Java code for implementing arrays that accepts user inputs and then displays them. Take different arrays like this: stringArray, integerArray, doubleArray.



1. Create a program that will convert the input dollar(s) into its equivalent peso. One dollar is approximately equal to 50.60 pesos. Then display The result.




Sample output:




The equivalent of $100 into is Php5,060.00

1. Create a program that will convert the input dollar(s) into its equivalent peso. One dollar is approximately equal to 50.60 pesos. Then display The result.

1. Create a program that will convert the input dollar(s) into its equivalent peso. One dollar is approximately equal to 50.60 pesos. Then display The result.



Sample output:



The equivalent of $100 into is Pho 5, 060.00

Using the above code add a method that takes in three arrays, one for student names, one for final test marks and a last one for assignment mark. The method should then calculate the students qualifying mark (a student needs 50 or more to qualify) using the following weights: 40% of the test and 60% of the assignment, finally print out whether the person qualified or not. [10]


LATEST TUTORIALS
APPROVED BY CLIENTS