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

Hey I’ve got this cool idea for an app! It’s kind of simple but just hear me out. All the user has to do is enter a bunch of integers. Then the application prints the largest sum of a strictly ascending sequence of the array. A strictly ascending sequence is a sequence where the current number is always lesser than the next number. 


For example, the user enters 2 4 5 1 7 3, the output should be 11 (2 + 4 + 5).


Then that’s it! I think this is going to be a hit! Don’t you think? Well I do. If you help me then we’re going to be rich!


Note: For this problem, a sequence must contain at least 2 numbers. If there is no sequence found, then the largest sum is 0.


Output:

Enter the size: 6
Enter element #1: 2
Enter element #2: 4
Enter element #3: 5
Enter element #4: 1
Enter element #5: 7
Enter element #6: 3
Largest sum = 11

Given the number of people attending a pizza party, output the number of needed pizzas and total cost. For the calculation, assume that people eat 2 slices on average and each pizza has 12 slices and costs $14.95.

Output each floating-point value with two digits after the decimal point, which can be achieved as follows:

System.out.printf("Cost: $%.2f\n", cost);

Ex: If the input is:

4

the output is:

Pizzas: 1
Cost: $14.95

Hint: Use the ceil() method to round up the number of pizzas so that enough pizzas are ordered.


Find the odd one out with reason:

  1. a++, a+=1, ++a, a+1
  2. nextLine(), nextDouble(), nextFloat(), nextShort(), next()
  3. Integer, Boolean, Float, Long
  4. break, continue, goto, return
  5. *, +, /, %
  6. True, TRUE, "true", true

ask user to input howmany members’ information will be entered into the system. Using linked list, program should accept asked information. Upon giving the neededinformation of each member,the system will display the information of each member. Use data types for each member of the linked list.

sample output below:

How many members’ information will be entered? 2

Kindly give the information of member #1

Enter first name: Sam

Enter middle name: Hui

Enter last name: Messi

Enter area code: 035

Enter telephone number: 999-22


Enter gender: male

Enter age: 9

Kindly give the information of member #2

Enter first name: Kim

Enter middle name: Prim

Enter last name: Cole

Enter area code: 047

Enter telephone number: 08-0978

Enter gender: female

Enter age: 18


Welcome to the club Sam Hui Messi!

Your area code and telephone number is (035) 999-22.

You are a male member, and your age is 9.


Welcome to the club Kim Prim Cole!

Your area code and telephone number are (047) 08-0978.

You are a female member, and your age is 18.


ask the user to input how many members’ information will be entered into the system. Using a linked list, the program should accept information such as first name, middle name, last name, area code,telephone number, gender, and age. sample output below:

How many members’ information will be entered? 2

Kindly give the information of member #1

Enter first name: Sam

Enter middle name: Hui

Enter last name: Messi

Enter area code: 035

Enter telephone number: 999-22


Enter gender: male

Enter age: 9

Kindly give the information of member #2

Enter first name: Kim

Enter middle name: Prim

Enter last name: Cole

Enter area code: 047

Enter telephone number: 08-0978

Enter gender: female

Enter age: 18


Welcome to the club Sam Hui Messi!

Your area code and telephone number is (035) 999-22.

You are a male member, and your age is 9.


Welcome to the club Kim Prim Cole!

Your area code and telephone number are (047) 08-0978.

You are a female member, and your age is 18.



Create a program in Java that will enter a number and check if the given number is odd or even number.




Sample output:



Enter a number to be check: 18



Number 18 is even number



OR



Enter a number to be check: 18



Then entered number is even number



Given the number of people attending a pizza party, output the number of needed pizzas and total cost. For the calculation, assume that people eat 2 slices on average and each pizza has 12 slices and costs $14.95.

Output each floating-point value with two digits after the decimal point, which can be achieved as follows:

System.out.printf("Cost: $%.2f\n", cost)


Write a program to read the content of any of the below website and all its sub pages and perform following actions:




Parse all the pages and sub pages of News, Sports and Business section




Extract the content, Image and Links




Dump the Content, Image and Links into the respective mongo collections





Websites




https://timesofindia.indiatimes.com/

Simulate or explain the code


public Act4B_Grp3_DAT2A(int size) {


A = new int[size];

N = 0;

}


public void insertItem(int item) {

if (N < A.length) {

int insertLocation = findLocationInsert(item);

for (int i = N - 1; i >= insertLocation; i--) {

A[i + 1] = A[i];

}

A[insertLocation] = item;

N++;

}


}


private int findLocationInsert(int item) {

if (N < A.length){

for (int i = 0; i < N; i++) {

if (A[i] > item) {

return i;

}

else {

System.out.print("This is full!");

}

}

return N;

}

return N;

}


public void deleteItem(int item) {

int deleteLocation = findLocationDelete(item);

if (deleteLocation != -1) {

for (int i = deleteLocation + 1; i < N; i++) {

A[i - 1] = A[i];

}

N--;

}

}


private int findLocationDelete(int item) {

for (int i = 0; i < N; i++) {

if (A[i] == item) {

return i;

}

else {

System.out.print("Element not found!");

}

return -1;

}

return -1;

}


Please explain this code or simulate this.




public SortedLinearArray(int size) {



array = new int[size];



currentSize = 0;



}




public void insertItem(int item) {



if (currentSize < array.length) {



int insertLocation = findLocationInsert(item);



for (int i = currentSize - 1; i >= insertLocation; i--) {



array[i + 1] = array[i];



}



array[insertLocation] = item;



currentSize++;



}



}




private int findLocationInsert(int item) {



for (int i = 0; i < currentSize; i++) {



if (array[i] > item) {



return i;



}



}



return currentSize;



}




public void deleteItem(int item) {



int deleteLocation = findLocationDelete(item);



if (deleteLocation != -1) {



for (int i = deleteLocation + 1; i < currentSize; i++) {



array[i - 1] = array[i];



}



currentSize--;



}



}




private int findLocationDelete(int item) {



for (int i = 0; i < currentSize; i++) {



if (array[i] == item) {



return i;



}



}



return -1;



}




LATEST TUTORIALS
APPROVED BY CLIENTS