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

Explain what is meant by the syntax and the semantics of a programming language. Give Java examples to illustrate the difference between a syntax error and a semantics error. Use different examples than those found in the textbook.

  • ou must create a class named Bus.
  • You should also create a main class named Main.
  • In the Bus class, there should be member variables named:

   -length, capacity, speed (must be an integer)

   -fuel_capacity, fuel_burn_rate (must be a double) 

   -name, color (must be a string)

 

  • Create a constructor in the Bus class containing the parameters:

   -name

   -length

   -capacity

   -color

   -speed

   -fuel_capacity

   -fuel_burn_rate


Consider the UML below:



LoanInterest

    


                                               

 

 

 A bank charges varying interest rates for loans made by students depending on whether they are undergraduate or post-graduate students. Undergraduates are charged 12% on the loan amount and postgraduates 10%. Interest on a small-business loan is 15%.

a)   Write the Java code to declare the LoanInterest interface with the method interest().                                                                                                       

b)   Write the Java code for the definition of the Student class.                          

c)   Write the Java code for the definition of the subclass UnderGrad.              

d)   Construct objects of each of the subclasses and assign them to an arraylist.                                                                                                                               

                       

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 



1. What do you call the 1st array/index in two dimensional array?



2. What do you call the 2nd array/index in two dimensional array?



3. What is the output of the given code?



double[] sales = {12.5, 32.50, 16.90, 23, 45.68,



9, 10.5};



for(int i=0; i<sales.length; i++)



{ } System.out.print(sales.length);




4. What is the output of the given code?



double[][] sales = {



{12.5, 32.50}, (16.90, 23, 45.68}, {1, 2, 3, 4),



};



System.out.print(sales[2][1]);




5. What is the output of the given code?



double[][] sales = {



(12.5, 32.50), (16.90, 23, 45.68}, {1, 2, 3, 4),



}; System.out.print(sales[1][1]);



Instruction: Answer the following. Show all your solutions. For items 5 and 6: Given R b a f(x)dx = 4; R c a f(x)dx = 6; R b a g(x)dx = −2; and R c a g(x)dx = 1.


6. Suppose a < c < b, solve: i. ∫ b c [g(x) + 2f(x)]dx (3 pts.) ii. − ∫ a c g(x)dx (2 pts.)


1.    You must create a class named Bus.

2.    You should also create a main class named Main.

3.    In the Bus class, there should be member variables named:

   -(integers) = length, capacity, speed

   -(double) = fuel_capacity, fuel_burn_rate;

   -(String) = name, color;

 

4.    Create a constructor in the Bus class containing the parameters:

   -name

   -length

   -capacity

   -color

   -speed

   -fuel_capacity

   -fuel_burn_rate

5.Create the following methods in the Bus class:

     -*Must be a return method.

     -*Must have a variable named result. 

     -*Must compute the estimated travel hour/s of a bus using the member variables fuel

     -*Must compute the gas used within the given hour/s using the member variables



Create a short program that will print 123467.89 as currency using NumberFormat.



Sample Output:


I have ₱1,234,567.89 in my bank account.



Submit your answers by attaching a screenshot of your program's source code and its output.

Create a short program that will print 123467.89 as currency using NumberFormat.

Answers the question below:



1. What do you call the 1st array/index in two dimensional array?




2. What do you call the 2nd array/index in two dimensional array?




3. What is the output of the given code?



double[] sales = {12.5, 32.50, 16.90, 23, 45.68,



9, 10.5};



for(int i=0; i<sales.length; i++)



{ } System.out.print(sales.length);




4. What is the output of the given code?



double[][] sales = {



{12.5, 32.50}, (16.90, 23, 45.68}, {1, 2, 3, 4),



};



System.out.print(sales[2][1]);




5. What is the output of the given code?



double[][] sales = {



(12.5, 32.50), (16.90, 23, 45.68}, {1, 2, 3, 4),



}; System.out.print(sales[1][1]);



The program shall:

• generate a random number from 1 to 50 for a player to guess;

• display a message that indicates whether the player's guess is correct, too low, or too high; • prompt the user to keep on guessing until the correct value is entered

4. Create a try-catch structure that will handle two (2) exceptions. These are when the user inputs the following:

• a number that is out of range (1 - 50) a letter or any non-numeric character

5. Prompt the user so that he can guess again if an exception is thrown.

6. Display the number of total guesses.

Note: An invalid input (when an exception is thrown) is not considered a valid guess or attempt. 

Sample Output:

Guess a number from 1 to 50!

30

Too high. Try Again.

10

Too high. Try again

qwerty

Invalid input.

Guess a number from 1 to 50!

51

Out of range.

Guess a number from 1 to 50!

1

Too low. Try Again.


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS