0% found this document useful (0 votes)
7 views

IFSelection

ict

Uploaded by

rzsu225
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

IFSelection

ict

Uploaded by

rzsu225
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

The company pays its employees according to the position(0: Engineer, 1: Technician) of the
employee in the company and the number of hours worked. Employees will be paid an overtime
rate of 1.5 times of the employee’s basic pay if the total number of hours worked exceeds 160
hours. The hourly rate for an Engineer and Technician is $30.00 and $25.50 respectively. Write a
pay calculator to compute pay of an employee of a given position and the number of hours
worked.
2. Write a fragment of code which computes and display the profit for selling an item based on
the type of the item and the price of the item. Assume there exit 2 variables, an integer type to
indicate type of the item and a float price to indicate the price of the item. You should use the
conditional statement to compute the profit based on the following criteria.
type price profit
0 Less than $20.00 10% of the price
(clothes) $20.00 to $50.00 15% of the price
Above $50.00 20% of the price
1 Less than $5.00 5% of the price
(shoes) Or above $30.00
$5.00 to 30.00 10% of the price

4. Write a fragment of code which computes the interest for housing loan of a local bank. The
interest calculation is based on the type of account, the amount loan and the loan period. Assume
there exit 3 variables, a String accountType to indicate account type of loan, a float amt to
indicate amount loaned and an integer year to indicate the loan period .You should use the
conditional statement to compute and store the interest in a float variable interest based on the
following criteria.

Account Type Loan period in years Interest

“Normal” Below 5 years 15% of amount loan

otherwise 17% of amount loan

“Deluxe” Below 10 years 14% of amount loan

10 to 15 years 16% of amount loan

above 15 years 18% of amount loan

Other any no of years 18% of amount loan


5. Complete the codes below to generate the following output.
5 4 3 2 1 0 -1 -2 -3 -4 -5
6. Complete the codes below to generate the following output.
1*4*9*16*25*
7. Complete the following code to compute x y(x to the power of y).For example if x is 2 and
y is 3, then the result of 2 3 is (2*2*2) =8;if x is 5 and y is -2 then the result of 5 -2 is 1/25 which is
0.04; x0 is 1.Write down the missing code of the parts indicated by i to assume integer x is
always greater than 0.
8. Complete the program below which compute the average of 10 random even numbers
ranging from 0 to 8(inclusive).
9. A factorial of an integer , n, is the product of all the integers from 1 to n.
n! =n(n-1)……..2.1 n=1,2,…..
n!=1 n=0
Write a fragment of code to generate the factorial of n until the factorial reaches 120.
Your output should resemble the output below:
0! =1
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
10. Write a fragment of codes to generated the following number sequence
1 2 3 5 8 13 21 34 55 89 144
11. Write a java expression to determine the grade with a given mark.
Grade Marks
A More than or equal to 80
B More than or equal to 70
C More than or equal to 60
F Below 60

You might also like