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

  1. Copy the following java program.
  2. Paste it on the submission textbox then insert useful comments (Use multi-line and single-line comments.)

 

  1. public class IfElseExample {  
  2. public static void main(String[] args) {  
  3.     int number=13;    
  4.     if(number%2==0){  
  5.         System.out.println("even number");  
  6.     }else{  
  7.         System.out.println("odd number");  
  8.     }  
  9. }  
  10. }  

Draw a flowchart of cellphone that uses the following methods to calculate the billing amount. do not output the number of minutes during which the service is used.

a. regularBill: This method calculates and returns the billing amount for regular

service.

b. premiumBill: This method calculates and returns the billing amount for premium

service.



Draw a flowchart of the smallestIndex, which takes as its parameters an int array and its size and returns the index of the (first occurrence of the) smallest element in the array.


Using a switch statement, write a program that prompts the user for a numeric code and two operands. The numeric codes of 1, 2, 3, and 4 represents addition, subtraction, multiplication, and division respectively. Before division, your program should check whether the second operand is not zero. If it is, it should display “Division by zero not allowed” to the screen.





Context

The Observer Pattern de nes a one-to-many dependency between objects so that when one object changes state, all of its dependents are noti ed and updated automatically. 


Imagine the life of a celebrity who has many fans. Each of these fans wants to be know of what their favorite celebrity has posted recently (images, videos, chats, etc.). So as long as the fan’s interest continues, she/he can follow this celebrity. When the fan loses interest, she/he stops following that celebrity.

Hint: ∼ Fans are observers and celebrity is a subject.

∼ Remember, a celebrity can have more than one follower


a. Create an abstract class called GeometricFigure. Each figure includes a height, a width, a figure type, and an area. Include an abstract method to determine the area of the figure. Create two subclasses called Square and Triangle. Create an application that demonstrates creating objects of both subclasses, and store them in an array. Save the files as GeometricFigure.java, Square.java, Triangle.java, and UseGeometric.java.

b. Modify Exercise a, adding an interface called SidedObject that contains a method called displaySides(); this method displays the number of sides the object possesses. Modify the GeometricFigure subclasses to include the use of the interface to display the number of sides of the figure. Create an application that demonstrates the use of both subclasses. Save the files as GeometricFigure2.java, Square2.java, Triangle2.java, SidedObject.java, and UseGeometric2.java.


Create a class named Poem that contains fields for the name of the poem and the number of lines in it. Include a constructor that requires values for both fields. Also, include get methods to retrieve field values. Create three subclasses: Couplet, Limerick, and Haiku. The constructor for each subclass requires only a title; the lines field is set using a constant value. A couplet has two lines, a limerick has five lines, and a haiku has three lines. Create an application that demonstrates usage of an object of each type. Save the files as Poem.java, Couplet.java, Limerick.java, Haiku.java, and DemoPoems.java.

create a java program for Two Way Chat Application using Java Socket Programming


Write a class Factors to model the factors of an integer1: • have attribute storing the integer whose factors are to be calculated. • have boolean array attribute ( factors ) where each element record whether that index is a factor of the integer i.e factor[5] = true • have a constructor which will assign the stored integer attribute to a user specified value and create the factors array NB: what is the size of this factors array? • have a method that calculates the factors of the stored integer and stores this is the Boolean array mentioned above. This is done by dividing the integer by all the integers less than itself and checking if there is a remainder. • have a method that prints out the factors of the stored integer to the screen i.e. “Factors of 120 are: 2, 3, 5, “ • have a method that takes another Factor object and prints out the common factors between that object the current object. • have a method that determines whether the integer is a perfect number by looking at the factors array.

What is the java program for this?


Passenger fare is classified according to the type of passenger. Senior Citizen enjoys 20%discount from the regular fare, Students get 10% discount. Regular passengers who do not qualified as neither Senior Citizen nor a Student should pay the regular fare of 150.

Write an algorithm that will accept details of five (5) passengers, including its name and

passenger type and will compute for the corresponding fare of each passenger. Display

the name and type of passenger, as well as the computer fare.


LATEST TUTORIALS
APPROVED BY CLIENTS