Вы находитесь на странице: 1из 9

Programming Competition - JAVA Problem 1: Requirement Create a program that will accept five whole numbers then print

the following result: 1. The sum of the first and last number 2. The difference of the second and third number 3. The product of the computed sum of the 1st and 5th number and the computed difference of the 2nd and 3rd number 4. The quotient of the resulting values in requirements number 3 and 1 5. Value of the last number Test case #1 Enter your 1st number: Enter your 2nd number: Enter your 3rd number: Enter your 4th number: Enter your 5th number: Result no. 1: Result no. 2: Result no. 3: Result no. 4: Result no. 5: Test case #2 Enter your 1st number: Enter your 2nd number: Enter your 3rd number: Enter your 4th number: Enter your 5th number: Result no. 1: Result no. 2: Result no. 3: Result no. 4: Result no. 5: Test case #3 Enter your 1st number: Enter your 2nd number: Enter your 3rd number: Enter your 4th number: Enter your 5th number: Result no. 1: Result no. 2: Result no. 3: Result no. 4: Result no. 5: 15 -20 10 35 5 20 -30 -600 -30 5 10 7 3 8 3 13 4 52 4 3 5 4 3 2 1 6 1 6 1 1

1|Page

Programming Competition - JAVA Problem 2: Requirement Create a program that will compute for the perimeter of a trapezoid. Use the following formula to compute the required result:

Perimeter = h (b1+b2), where h is the height of the shape and b1 and b2 represents the length of the bases of the trapezoid. The computed result must be rounded to nearest tens Test Case #1 Enter height of the trapezoid: Enter length of the upper base: Enter length of the lower base: Computed perimeter is: 5 3 4 17.50

Test Case #2 Enter height of the trapezoid: Enter length of the upper base: Enter length of the lower base: Computed perimeter is: Test Case #3 Enter height of the trapezoid: Enter length of the upper base: Enter length of the lower base: Computed perimeter is: 12.5 10.75 14.25 156.25 30 30 20 750.00

2|Page

Programming Competition - JAVA Problem 3: Requirement Create a program that will accept 10 fractional numbers from the user then print the following result. 1. Computed sum 2. Computed average (average is equal to the sum divide by 10) All results must be displayed in two 2 decimal places

Test Case #1 Enter ten (10) numbers: 10 10 10 10 10 10 10 10 10 10 Sum >> 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 + 10 = 100 Average >> 100/10 = 10 Test Case #2 Enter ten (10) numbers: 12.23 23.34 34.45 45.56 56.67 67.78 78.89 89.90 12.23 23.34 Sum >> 12.23+23.34+34.45+45.56+56.67+67.78+78.89+89.90+12.23+23.34 = 444.39 Average >> 444.39/10 = 44.43

3|Page

Programming Competition - JAVA Problem 4: Requirement Create a program that will compute for the grade of a student given the following formula: Grade = Laboratory Grade (60%) + Lecture Grade (30%) + Attitude (10%) Laboratory Grade = Homework (20%) + Minor Projects (30%) + Major Projects (50%) Lecture Grade = Quizzes (30%) + Final Exam (70%) Attitude = Attendance (50%) + Class Participation (50%)

4|Page

Programming Competition - JAVA Problem 5: Requirement Create a program that will compute for the weekly net salary of an employee based on the following formula: Weekly Net Salary (WNS) = Gross Income (GI) Total Deduction (TD) GI = Regular Income (RI) + Allowance (ALL) RI = Total Hrs Worked (THW) x Rate Per Hr (RPH) THW is the total hours worked from Monday to Friday RPH = Regular Rate (RR) / 8 RR will depend on the following table Rate Level Regular Rate / day 1 480 2 560 3 640 4 720 5 800 Allowance is 350 per week TD = SSS + GSIS + TAX + PHILHEALTH SSS = 5% of RI GSIS = 10% of RI TAX = 12% of RI PHILHEALTH = 100

Test Case # 1 Employee Code: Employee Rate: Enter hrs worked for Monday (0-8): Enter hrs worked for Tuesday (0-8): Enter hrs worked for Wednesday (0-8): Enter hrs worked for Thursday (0-8): Enter hrs worked for Friday (0-8): Total Hours Worked: Rate per Hour: Regular Income: Allowance Gross Income: SSS GSIS TAX PhilHealth Total Deduction Weekly Net Income: E0-0001 3 8 8 8 8 8 40 80 3200 350 3550 160 320 384 100 964 2236

5|Page

Programming Competition - JAVA Problem 6: Requirement Create a program that will produce the following output: 1 22 333 4444 55555 .. The program will accept an integer value from the user and will become the basis on the number of levels the triangle will be made of. The given example is a 5-level triangle. Test Case # 1 Enter the number of levels the triangle will have: 4 1 22 333 4444 Test Case # 2 Enter the number of levels the triangle will have: 8 1 22 333 4444 55555 666666 7777777 88888888

Problem 7: Requirement Create a program that will accept a series of numbers and then stop if it satisfies any of the following condition 1. The total sum of inputted numbers becomes higher than 1000 2. The user enters a non-positive number 3. The user enters 0 Problem 8: Requirement Create a program that will accept two date values in numeric form. The first date is the birthdate of the user and the second date is the current date. Based on those two inputs, the program should be able to compute the exact age of the user. Test Case # 1 Enter your Birth Date: 6|Page

Programming Competition - JAVA Month [1 to 12]: Day [1 to 31]: Year [yyyy] : Enter Current Date: Month [1 to 12]: Day [ 1 to 31 ]: Year [yyyy]: Your current age is: Test Case # 2 Enter your Birth Date: Month [1 to 12]: Day [1 to 31]: Year [yyyy] : Enter Current Date: Month [1 to 12]: Day [ 1 to 31 ]: Year [yyyy]: Your current age is: Test Case # 3 Enter your Birth Date: Month [1 to 12]: Day [1 to 31]: Year [yyyy] : Enter Current Date: Month [1 to 12]: Day [ 1 to 31 ]: Year [yyyy]: Your current age is: 10 4 1993 12 4 1993 Less Than One Year Old 6 15 1995 8 5 2010 15 years old 12 28 1986 7 30 2011 24 years old

7|Page

Programming Competition - JAVA Problem 9: Requirement Create a program that will accept ten (10) numbers from the user. Apply the following rules to get the required result. 1. If the sum of the first five numbers is higher than the sum of the last five numbers, print the sum of the 1st, 2nd, 9th, and 10th number. 2. If the sum of the first five numbers is equal to the sum of the last five numbers, print the product of 3rd and 8th number 3. If the sum of the first five numbers is lower than the sum of the last five numbers, subtract the sum of 5th, 4th, 1st number to the sum of 6th, 7th and 9th number Problem 10: Requirement Create a program that will accept a continuous stream of numbers and will only stop if the user enters seven (7) numbers that are divisible by 7 Test Case # 1 Start Entering numbers: 5 10 15 7 14 28 35 77 42 49 STOP!!! Test Case # 2 Start Entering numbers: 49 42 35 28 42 7 1 5 9 49 14 21 28 35 70 63 STOP!!! Test Case # 3 Start entering number: 7 7 14 21 21 35 28 STOP!!!

Note: Bold numbers are indications of numbers that are divisible by 7

8|Page

Programming Competition - JAVA Problem 11: Requirement Create a program that will allow the user to set the starting and ending number of the number sequence to be printed by the computer. Test Case # 1 Enter the number sequence starting number: 1 Enter the number sequence ending number: 5 ----------------------------------------------------------------Number sequence ----------------------------------------------------------------1 2 3 4 5 Test Case # 2 Enter the number sequence starting number: 10 Enter the number sequence ending number: 17 ----------------------------------------------------------------Number sequence ----------------------------------------------------------------10 12 13 14 15 16 17

9|Page

Вам также может понравиться