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

Complete with necessary functions this example code to implement a solution to the producer consumer problem discussed in class using Posix threads and semaphores. Assume that there is only 10 producer and 10 consumer. The output of your code should be similar to the following and it must run in infinite loop


Write a recursive function power (x, y) that calculates the value of x to the power.


Let b is a real number. Let n be a non-negative integer. Assume

b and n are not simultaneously 0. Write iterative and recursive functions that return value of bn , the nth power of b.

follow the following methods’ details :

powerRecursive()

  • Receive the values of b and n from main() and compute the nth power of b recursively

• Return the computed nth power of b

powerIteration()

• Receive the values of b and n from main() and compute the nth power of b iteratively

• Return the computed nth power of b

main()

  • Accept the value for b and n which will be used to compute the nth power of
  • Display the computed nth power of b from both iterative and recursive methods


Sample Output:

Enter value of b:3

Enter value of n: 6

6th power of 3 is 729. --> This is displayed through Iterative Method.

6th power of 3 is 729. --> This is displayed through Recursive Method.



Using a whole loop create a that calculates the monthly salaryof N [ where N is the number if employees that's entered by the user.] If the employee worked less or equal to 160 hours, the employee wilk be paid N$240.00 per hour. For any hour greater than 160, the employee is paid N$320.00 per hour.


Create a program that takes in a sentence from user input, the program then removes the last word and first word in the sentence. The remaining string is converted to upper case then printed out. [Hint: In case there is only two words, an empty line is printed]

 

Sample run 1:                    Sample run 2:

Enter a sentence: Hello There       Enter a sentence: Happy Thursday Everyone

Output:                          Output: THURSDAY

Create a program that takes in a student first name and average mark obtained, the system should the group the students using the first letter in their name modulus 10 [ Remember that characters are considered as numeric values, hence ‘J’%10 is a valid calculation ]. For example if the student name is Cena, then the student belongs to group 7 because ‘C’%10 = 7 and if the name was Jack then the student belongs to group 4. The program should further use the group number to get the group lecturer and class date as follows: [Hint: If the result is 0 then the student belongs to group 10]


Using a for loop create a program that will prompts the user for two numbers and then print out a summation list of all the between the two given numbers, starting from the small number to the big number. For negative numbers use brackets when printing the summation

Sample Run1

Enter two numbers: 1 10

Output1: Sum = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55

Sample Run2

Enter two numbers: -3 3

Output2: Sum = (-3) + (-2) + (-1) + 0 + 1 + 2 + 3 = 0

Using a for loop create a program that will prompts the user for two numbers and then print out a summation list of all the between the two given numbers, starting from the small number to the big number. For negative numbers use brackets when printing the summation



Printing triangles: Write a program which inputs a positive integer n and outputs an n line high triangle of '*' characters whose right-angle is in the bottom left corner. For example, if 5 is input the output should be



Sample Run1


Enter a positive integer: 5


Output1:


*


**


***


****


*****


Create a program that takes in a student first name and average mark obtained, the system should the group the students using the first letter in their name modulus 10 [ Remember that characters are considered as numeric values, hence ‘J’%10 is a valid calculation ]. For example if the student name is Cena, then the student belongs to group 7 because ‘C’%10 = 7 and if the name was Jack then the student belongs to group 4. The program should further use the group number to get the group lecturer and class date as follows: [Hint: If the result is 0 then the student belongs to group 10]

Groups

Group Lecturer

Class date

1 , 7, 9

Mrs. T. Chikohora

Monday

2 , 4, 5

Mrs. J. Muntuumo

Wednesday

3, 6, 10

Mr. S. Tjiraso

Friday


LATEST TUTORIALS
APPROVED BY CLIENTS