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

Write a program that simulates a lottery. The program should have an array of five integers named lottery and should generate a random number in the range of 0 through 9 for each element in the array.

The user should enter five digits, which should be stored in an integer array named user. The program is to compare the corresponding elements in the two arrays and keep a count of the digits that match. For example, the following shows the lottery array and the user array with sample numbers stored in each. There are two matching digits (elements 2 and 4).

lottery array: 7 4 9 1 3

user array: 4 2 9 7 3


The program should display the random numbers stored in the lottery array and the number of matching digits. If all of the digits match, display a message proclaiming the user as a grand prize winner.


Input Validation: Do not accept a negative value for lottery number. Also keep track of array size.



Bank charges $10 per month plus the following check fees for a commercial checking account:

 $.10 each for fewer than 20 checks

$.08 each for 20–39 checks

$.06 each for 40–59 checks

$.04 each for 60 or more checks

The bank also charges an extra $15 if the balance of the account falls below $400 (before any check fees are applied).

 Write a program that asks for the beginning balance and the number of checks written.

Compute and display the bank’s service fees for the month (30 days).

Input Validation: Do not accept a negative value for the number of checks written. If a negative value is given for the beginning balance, display an urgent message indicating the account is overdrawn.



Write a program that displays the following menu:

Geometry Calculator

1. Calculate the Area of a Circle

2. Calculate the Area of a Rectangle

3. Calculate the Area of a Triangle

4. Quit

Enter your choice (1-4):

If the user enters 1, the program should ask for the radius of the circle and then display its area. formula: area π r 2 Use 3.14159 for π and the radius of the circle for r.

If the user enters 2, the program should ask for the length and width of the rectangle and then display the rectangle’s area. formula: area = length * width

 If the user enters 3 the program should ask for the length of the triangle’s base and its height, and then display its area. formula: area = base * height * .5

If the user enters 4, the program should end.

Input Validation: Display an error message if the user enters a number outside the range of 1 through 4 when selecting an item from the menu. Do not accept negative values for the circle’s radius, the rectangle’s length or width, or the triangle’s base or height.  



Traversing a Sorted Linear Array

Here A is an array with N elements with subscript Lower bound (LB) = 0 and upper

bound (UP) = N– 1 where N is the size of the array:

K = LB and UB = N – 1

Repeat steps 3 to 4 while K <= UB

Display element A[K]

K = K + 1

Inserting Item into Sorted Linear Array

insertItem()

Get value of ITEM to be inserted.

Call findLocationInsert()

findLocationInsert()

Search for position which ITEM can be inserted and Return position

Deleting item into Sorted Linear Array

deleteItem()

Get value of ITEM to be deleted

Call findLocationDelete()

findLocationDelete()

Search for the position in which ITEM will be deleted and return position

main() - Display option similar to this:

1. Insert value 2. Delete value 3. Traverse array 4. Exit

Provide switch statement which cases for the shown options are written.

array must be checked if it's already full or not.

Sample output:

Enter your choice: 1

Enter element to inserted: 5

Array Basic Operations

1. Insert value

2. Delete value

3. Traverse the array

4. Exit

 





Write a java program that will satisfy the given requirements:


A. It will display the given menu:


A - Arithmetic Series

B - Geometric Series

C - Harmonic Mean

D - Largest Prime Number

E - Largest Prime Number

Q - Quit the Program


B. The program will ask the user his/her choice.

C. If the choice is A,B,C,D or E, It will prompt the user for the required inputs, then compute and display the required outputs. If the choice is Q, the program will terminate

D. Validate all your inputs by promptingg for a new value if input is invalid.

E. Display also a description of your program

F. Program should execute for as long as the user wants to continue

G. Use of arrays is not allowed



Write the team, netball and rugby classes.

Create a flowchart of the following Pseudocode


Start

If option = A;

display items in stock;

print “Well here’s what we have in stock”; print(“Item\t\tCost\t\tCode”); print(“Candies\t\t14.50\t\t001”); print(“Cooldrinks\t\t17.20\t\t002”); print(“Cokes\t\t10.99\t\t003”);

end if

End


Using the above code add a method that takes in three arrays, one for student names, one for final test marks and a last one for assignment mark. The method should then calculate the students qualifying mark (a student needs 50 or more to qualify) using the following weights: 40% of the test and 60% of the assignment, finally print out whether the person qualified or not. [10]

Use the below format for you print out: 

-------- ------- ---------------- ------- ------------------

King 59 85 75 Allowed

John 52 45 48 Denied


Create a program with three methods/functions, The first one takes in n which is the size of an array then creates and populate the array with student names, the second method takes in n which is the size of an array then creates and populate n by 3 array with student marks(The three marks are for test 1 - 3) and finally a method that takes in the two arrays, calculates the final mark of all test and print out the results as indicated below: The first method should return and array of names and the second should return an array all test marks(i.e. 2d array with 3 columns). The third method in addition should also return an array for all the final marks 


Name Test 01 Test 02 Test 03 Final

-------- --------- --------- --------- ---------

Gerry 55 55 55 55 


Create a program with a method that takes a single character and returns true if the character is a vowel otherwise return false. 


LATEST TUTORIALS
APPROVED BY CLIENTS