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

using SWITCH selection statement

Write a Program that will ask the user to accept 5

integers, select an arithmetic operation for odd

and even, and perform the corresponding

operation.

Enter the first number: 34

Enter the second number: 25

Enter the third number: 62

Enter the fourth number: 13

Enter the fifth number: 27


Choose which operation you want to perform:

1. Addition

2. Subtraction

Enter the operation of odd: 1

Enter the operation of even: 2

The sum of odd numbers is: 65

The difference of even numbers is: -28


Develop and deploy a web based “Programme Information System” using JSP, any database backend and any web server. Your system should use JDBC for input of information to both the tables




COMPLETE THIS CODE(DONT CHANGE)

package myqueue_J;

public class MyQueue_J {

public int data;

public MyQueue_J next;

public static MyQueue_J front=null;

public static MyQueue_J rear=null;

public static MyQueue_J temp=null;


public MyQueue_J(int d, MyQueue_J n) {

data=d;

next=n;

}

public static void enqueue(int d){

MyQueue_J temp = new MyQueue_J(d, null);

Insert to perform enqueue operation

}

public static void dequeue(){

Insert to perform dequeue operation

}

public static int printQueue(){

int ctr=0;


Insert to display the elements in the queue

}

public static void main(String[] args) {


Insert to perform the desired output

}

}


THE OUTPUT

After the Enqueue operations:

1. Element Front: 10

2. Element rear: 30

3. Elements in the Queue: 10 15 20 25 30

4. Number of Elements in the Queue: 5


The dequeued element is 10.

The dequeued element is 15.

After the Dequeue operations:

1. Element Front: 20

2. Element rear: 30

3. Elements in the Queue: 20 25 30

4. Number of Elements in the Queue: 3


2 Problem description In this labwork you are expected to implement a program that builds a computer for different purposes using Template Method pattern. Your program needs to able to build two types of computers which is Gaming and Office. CPU, Memory and type of storage depends on the computer type. For a gaming computer you need to put: ∗ High-end multi-core cpu ∗ High-clock speed memory ∗ SSD storage For an office computer you need to put: ∗ Low-end dual-core cpu ∗ Energy-efficient memory ∗ Energy-efficient HDD However, way you build a computer is a set of pre-determined steps: ∗ Plug CPU ∗ Plug Memory ∗ Plug Storage ∗ Plug peripherals (which are common for both type of computer)

3 Measure of success You are expected to implement necessary classes for this example using Template Method Pattern.


Create your own NetworkServer and NetworkClient applications as following.we will name them as MyComputerServer and MyComputingClient .The Client send two numbers and the server send back addition of the two numbers


Encapsulation

Create a class main and class for a point (that has an x-coordinate and a y-coordinate). Also, create another class called Rectangle. The Rectangle should have 2 points, the top left and the bottom right. Implement the following methods for the Rectangle:

  • display() - draws the rectangle on the console based on the sample
  • area() - computes and returns the area of a given rectangle
  • perimeter() - computes and returns the perimeter of a given rectangle
  • centerPoint() - computes and returns the center point of a given rectangle
  • isSquare() - checks whether a given rectangle is a square or not. 

Input

A pair of numbers representing the points for the rectangle (x and y).

5 8

Output

The first few lines contain the drawn rectangle. After one empty line, the next line prints either "RECTANGLE" or "SQUARE".

#·#·#·#·#·#
#·········#
#·········#
#·········#
#·········#
#·········#
#·········#
#·········#
#·#·#·#·#·#

RECTANGLE
AREA:·40
PERIMETER:·26
CENTER·POINT:·(2.50,4.00)





We've already tried comparing 3 numbers to see the largest among all, so let's try a more complicated mission where we locate the position of the largest among 5 numbers. There are only 4 possible cases for this mission:





- if the largest digit is the first digit, print "Leftmost"





- if the largest digit is the third digit, print "Middle"





- if the largest digit is the last digit, print "Rightmost"





- if none of the above is correct, print "Unknown"









Now, show me how far you've understood your lessons!





Input





A line containing a five-digit integer.





1·4·6·3·2




Output





A line containing a string.





Middle

Write a Java program that will ask the user to enter a string then copy the given string to  a char array(array of characters; please see sample code below).  The program will then  swap the first and last word in char array and store the result in another char array.

The program should also meet the following requirements:

·        It will display the original string and the new string(after swapping).

·        It will display the first and last word.

·        Use of StringBuffer, StringBuilder, and String class after the string  was copied to an array of characters is not allowed.

·        Use of any String, StringBuilder, StringBuffer, and Array method is not allowed.

·        It should execute for as long as the user wants to continue.

·        Create and use this method in your program:

        displayArray()

        {

            //display array   

        }


Consider the association relationship between the class Customer in question 2 above and a class Invoice where the Customer class is a member of the Invoice class. Write the codes for the Invoice class and a test driver to test all the public methods

The Customer class models a customer using as shown in the class diagram below. Write the codes for the Customer class and a test driver to test all the public methods. Note that a discount is given as a percentage. The toString() method should output the customer information including the ID, name and discount

LATEST TUTORIALS
APPROVED BY CLIENTS