Академический Документы
Профессиональный Документы
Культура Документы
Question 1:
if (condition)
{
if(condition)
statement;
else
statement;
}
else
statement
Question 2:
Answer:
if(Employee_Code == H)
{
salary=4000;
}
else
{
if(Hours_Worked <= 40)
salary= Hours_Worked*30;
else
salary= 8*30+( Hours_Worked-8)*40;
}
switch (condition)
{
case value :
// statement
break;
case value :
// statement
break;
Question 3:
case 5 :{
System.out.println("Fri");
break;
}
}
More Exercises:
Exercise 1:
Write an application for a furniture company (using scanner); the program determines
the price of furniture. Program will prompt the user to choose the wood id (which is
representing the wood type); price and the wood type of user choice will be displayed.
Refer the following table for the price listing of wood. Save the file as furniture.java
Wood ID Wood Type Price
1 Pine RM 100
2 Oak RM 225
3 Mahogany RM 310
any other ID Invalid wood RM 0
Hint: use ifelse
Exercise 2:
Write an application for UNISEL admission office (using JOptionPane). Prompt user for a
students grade point average (GPA for example 3.2) and an admission test score from 0 to
100. Print the message ACCEPTS if the student has any of the following:
GPA of 3.0 or above and an admission test score at least 60
GPA of below 3.0 and an admission test score of at least 80
If the student does not meet either qualification criteria, print REJECT. Save the file as
Admission.java. Repeat the program as long as user wishes to continue to use the system.
Hint: use ifelse and looping