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

Draw a flowchart. 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.



1. Write a program that generates a random number between 0 to 10. Use the following statements below for generating random number and the class Random from the package java.util:Random rand = new Random();int num = rand.nextInt(10);2. Display the generated random number with text: "The generated random number between 0 to 10 is: ".3. Name the class as RandomNumber and save the file.4. Compile and execute the program using the command prompt (cmd). If you do not have cmd, run it in JDoodle.5. Correct syntax and logical errors if there are any.6. Once you have successfully compiled and execute the program, copy the source code and paste it here in the Submission box.

  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


LATEST TUTORIALS
APPROVED BY CLIENTS