30 Proggrsming Problems
30 Proggrsming Problems
30 Proggrsming Problems
if you
have collected 20,000 or more. If not, you to display “SORRY, you have t o collect more”.
package javaapplication4;
import javax.swing.JOptionPane;
int amount;
amount=Integer.parseInt(input);
if (amount>= 20000){
JOptionPane.showMessageDialog(null,"CONGRATULATION");}
else{
// String msg=
// JOptionPane.showMessageDialog(null,msg);
}
2. Write a program that reads the age of a person and then output the message “YOU are old enough to drive”, if his or
her age is at least 18 years old. Otherwise, display the number of years to wait before being able to drive.
// number 2
package javaapplication5;
import javax.swing.JOptionPane;
int age,wait;
age=Integer.parseInt(input);
if (age>= 18){
else{
wait=18-age;
// String msg=
// JOptionPane.showMessageDialog(null,msg);
}
3. Any customer whose total purchase is at least 2000 will be given a 5% percent discount. Write a program that reads in
the customer purchase and outputs the amount to be paid.
// number 3
package javaapplication6;
import javax.swing.JOptionPane;
double purchase,amount;
purchase=Double.parseDouble(input);
if (purchase >=2000){
else{
}
4. Due to poor result of an examination, your professor decided to increase each student by 1 point. Input the grade and
print new grade. If the original grade exceeds 100, then it remains as such.
package javaapplication22;
import javax.swing.JOptionPane;
grade=Integer.parseInt(input);
if (grade >=100){
else{
grade1= grade+1;
// String msg=
// JOptionPane.showMessageDialog(null,msg);
}
5. A college student who is registered, for 21 units or more is considered as full time student. The tuition fee for fulltime
is 7000. A part time student is charged 300 per unit for tuition. Given the number of units a student is registering,
calculate and print his tuition fee on the basis of the given criteria.
// number 5
package javaapplication23;
import javax.swing.JOptionPane;
int units,tuition;
units=Integer.parseInt(input);
if (units>= 21){
else{
// String msg=
// JOptionPane.showMessageDialog(null,msg);
}
6. Accept two integers and determine of the values are equal, if the values are equal do not print anything otherwise
print the higher number.
// number 6
package javaapplication24;
import javax.swing.JOptionPane;
int a,b;
a=Integer.parseInt(input);
b=Integer.parseInt(input);
if (a==b){
JOptionPane.showMessageDialog(null,"Equal");}
else if(a>b){
else {
}
7. Input three integers and identify if there are equal numbers. If there are equal numbers print the equal numbers,
otherwise print the average of the numbers.
// number 7
package javaapplication25;
import javax.swing.JOptionPane;
a=Integer.parseInt(input);
b=Integer.parseInt(input);
c=Integer.parseInt(input);
JOptionPane.showMessageDialog(null,"Equal");}
else {
average=(a+b+c)/3;
}
8. An employee’s weekly working hours is 40. If an employee exceeds 40 hours, it is considered overtime. Create a
program that will accept the number of hours worked by employee and his hourly rate and print the gross pay and
overtime pay rendered, If there is no OT pay to print, print only the gross pay. To compute for the gross pay of an
employee, multiply the number of hours worked by his hourly rate by using 1.50% of his hourly rate.
// number 7
package javaapplication25;
import javax.swing.JOptionPane;
hours=Double.parseDouble(input);
rate=Double.parseDouble(input);
if (hours>=40){
else {
gross= hours*rate;
}
9. Design and develop a simple program for the Air force to label an aircraft as military or civilian. The program is to be
given the plane’s observed speed in km/h, (kilometer per hour). The speed will serve as its input. For planes travelling in
excess of 1100 km/h, display them as “It’s a civilian aircraft”, between 500 km/h to 1100 km/h, display them as “It’s a
military aircraft” and for planes travelling at slower speed – less than 500 km/h, you should display them as an “It’s a
Bird”.
// number 9
package javaapplication27;
import javax.swing.JOptionPane;
int speed;
speed=Integer.parseInt(input);
if (speed>1100){
else {
JOptionPane.showMessageDialog(null,"It's a bird");}
}
10. Write a program that reads in the sales expenses of the short distance telephone company for the past year and
then calculate the profit and the next tax based on the ff. table
0-10000 0
// number 10
package javaapplication28;
import javax.swing.JOptionPane;
double profit,tax;
profit=Double.parseDouble(input);
tax= 100+(profit*0.03);
tax= 200+(profit*0.05);
else {
}
}
11. Create a program that will compute the real estate tax, given the following formulas:
a) If value of real estate is less than 250.001.00 tax is 5% of the real estate value
b) If value of real estate is b/w 250,000.1 to 500,000.00, tax is 10% of the real estate value
// number 11
package javaapplication29;
import javax.swing.JOptionPane;
double value,tax;
value=Double.parseDouble(input);
if (value<250001){
tax= value*.05;
else {
}
12. IN 2001 BIR proposed an overhaul of the income tax law. They proposed the ff. schedule
0 to 5000 0
// number 12
package javaapplication30;
import javax.swing.JOptionPane;
double income,tax;
income=Double.parseDouble(input);
tax= 100+(income-5000)*.03;
else {
}
}
13. Employees of ABC Electric Corporation are given raises as follows: Sales person (15%), Linemen (10%), Engineer (8%)
, . Write a program that will input the employees position, then input the salary and display the new salary based on
their job category.
package javaapplication20;
import javax.swing.JOptionPane;
position=Double.parseDouble(input);
salary=Double.parseDouble(input);
if (position == 1){
JOptionPane.showMessageDialog(null,"Sales Person" );
JOptionPane.showMessageDialog(null,"Linemen" );
else {
JOptionPane.showMessageDialog(null,"Engineer" );
14. Design and develop a simple application program that’s adds, subtract, multiply and divide two input number
package javaapplication34;
import javax.swing.JOptionPane;
double choice,x,y,add,sub,div,mul;
choice=Double.parseDouble(input);
x=Double.parseDouble(input);
y=Double.parseDouble(input);
if (choice==1){
add= x+y;
else if (choice==2){
sub= x-y;
mul= x*y;
else if (choice==4){
div= x/y;
else{
package javaapplication35;
import javax.swing.JOptionPane;
int x,y,z;
x=Integer.parseInt(input);
y=Integer.parseInt(input);
z=Integer.parseInt(input);
else{
16. Input 3 unique numbers and arrange the numbers in lowest to highest order.
package javaapplication23;
import javax.swing.JOptionPane;
int a,b,c;
a=Integer.parseInt(input);
b=Integer.parseInt(input);
c=Integer.parseInt(input);
else {
17. Input 3 unique numbers and print the difference of the highest and lowest numbers.
package javaapplication24;
import javax.swing.JOptionPane;
a=Integer.parseInt(input);
b=Integer.parseInt(input);
diff= c-a;
diff= b-a;
diff= c-b;
diff= a-b ;
diff= a-c;
else {
diff= b-c;
18. Write a program that examines the value of a variable called TEMP. Then display the following messages, depending
on the value assigned to TEMP.
Temperature
package javaapplication37;
import javax.swing.JOptionPane;
double temp;
temp=Double.parseDouble(input);
if (temp<=0 ){
else{
import javax.swing.JOptionPane;
ritcher=Double.parseDouble(input);
if (ritcher<=5){
else{
uake information center has the ff criteria to determine the earthquakes damage.
Here are the given Richter scale criteria and their corresponding characterization. The Richter scale serves as the input
data and the characterization as output information
20.