Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 21

1. Prepare a program that must display the message “CONGRATULATIONS”, you have reached the target amount”.

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;

public class Main {

public static void main(String[] args) {

String input= "";

int amount;

input=JOptionPane.showInputDialog("Enter the amount ");

amount=Integer.parseInt(input);

if (amount>= 20000){

JOptionPane.showMessageDialog(null,"CONGRATULATION");}

else{

JOptionPane.showMessageDialog(null,"SORRY,you have to collect more");}

// 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;

public class Main {

public static void main(String[] args) {

String input= "";

int age,wait;

input=JOptionPane.showInputDialog("Enter the age ");

age=Integer.parseInt(input);

if (age>= 18){

JOptionPane.showMessageDialog(null,"You are old enough to drive");}

else{

wait=18-age;

JOptionPane.showMessageDialog(null,"SORRY,you have to wait " + wait + " years" );}

// 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;

public class Main {

public static void main(String[] args) {

String input= "";

double purchase,amount;

input=JOptionPane.showInputDialog("Enter the purchase ");

purchase=Double.parseDouble(input);

if (purchase >=2000){

amount= purchase - (purchase*.05);

JOptionPane.showMessageDialog(null,"Please pay the amount of" + amount);}

else{

JOptionPane.showMessageDialog(null,"Please pay the amount of" + purchase );}

}
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;

public class Main {

public static void main(String[] args) {

String input= "";

int grade, grade1;

input=JOptionPane.showInputDialog("Enter the grade ");

grade=Integer.parseInt(input);

if (grade >=100){

JOptionPane.showMessageDialog(null,"The grade is 100");}

else{

grade1= grade+1;

JOptionPane.showMessageDialog(null,"The grade is " + grade1 );}

// 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;

public class Main {

public static void main(String[] args) {

String input= "";

int units,tuition;

input=JOptionPane.showInputDialog("Enter the units ");

units=Integer.parseInt(input);

if (units>= 21){

JOptionPane.showMessageDialog(null,"The tuition fee is 7000");}

else{

tuition= units * 300;

JOptionPane.showMessageDialog(null,"The tuition fee is " + tuition );}

// 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;

public class Main {

public static void main(String[] args) {

String input= "";

int a,b;

input=JOptionPane.showInputDialog("Enter the first number ");

a=Integer.parseInt(input);

input=JOptionPane.showInputDialog("Enter the second number ");

b=Integer.parseInt(input);

if (a==b){

JOptionPane.showMessageDialog(null,"Equal");}

else if(a>b){

JOptionPane.showMessageDialog(null,"The highest number is" + a );}

else {

JOptionPane.showMessageDialog(null,"The highest number is" + b );}

}
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;

public class Main {

public static void main(String[] args) {

String input= "";

int a,b,c, average;

input=JOptionPane.showInputDialog("Enter the first number ");

a=Integer.parseInt(input);

input=JOptionPane.showInputDialog("Enter the second number ");

b=Integer.parseInt(input);

input=JOptionPane.showInputDialog("Enter the second number ");

c=Integer.parseInt(input);

if (a==b && a==c && c==b){

JOptionPane.showMessageDialog(null,"Equal");}

else {

average=(a+b+c)/3;

JOptionPane.showMessageDialog(null,"The average number is" + average );}

}
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;

public class Main {

public static void main(String[] args) {

String input= "";

double hours, rate, gross, overtime;

input=JOptionPane.showInputDialog("Enter the hours worked ");

hours=Double.parseDouble(input);

input=JOptionPane.showInputDialog("Enter the rate per hour ");

rate=Double.parseDouble(input);

if (hours>=40){

gross=(hours - 40)* rate *1.5 + (40*rate);

JOptionPane.showMessageDialog(null,"The gross pay and ot is " + gross );}

else {

gross= hours*rate;

JOptionPane.showMessageDialog(null,"The gross pay is " + gross );}

}
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;

public class Main {

public static void main(String[] args) {

String input= "";

int speed;

input=JOptionPane.showInputDialog("Enter the Speed ");

speed=Integer.parseInt(input);

if (speed>1100){

JOptionPane.showMessageDialog(null,"Its an civilian aircraft" );}

else if (speed>=500 && speed<1100){

JOptionPane.showMessageDialog(null,"It's a military aircraft");}

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

Profit Tax Rate

0-10000 0

10001-30000 100 + 3% of the profit

30001-50000 200+ 5% of the profit

OVER 50000 300+ 7% of the profit

// number 10

package javaapplication28;

import javax.swing.JOptionPane;

public class Main {

public static void main(String[] args) {

String input= "";

double profit,tax;

input=JOptionPane.showInputDialog("Enter the profit ");

profit=Double.parseDouble(input);

if (profit >=0&& profit<=10000){

JOptionPane.showMessageDialog(null,"The tax rate is 0" );}

else if (profit >=10001 && profit<=30000){

tax= 100+(profit*0.03);

JOptionPane.showMessageDialog(null,"The tax rate is" + tax);}

else if (profit >=30001 && profit<=50000){

tax= 200+(profit*0.05);

JOptionPane.showMessageDialog(null,"The tax rate is" + tax);}

else {

tax = 300+ (profit*0.07);

JOptionPane.showMessageDialog(null,"The tax is " + tax );}

}
}

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

c) If more than 500,000 tax is 15% of the real state value

// number 11

package javaapplication29;

import javax.swing.JOptionPane;

public class Main {

public static void main(String[] args) {

String input= "";

double value,tax;

input=JOptionPane.showInputDialog("Enter the real estate valuet ");

value=Double.parseDouble(input);

if (value<250001){

tax= value*.05;

JOptionPane.showMessageDialog(null,"The tax is " + tax );}

else if (value <=250001 && value >= 500000){

tax= value *.10;

JOptionPane.showMessageDialog(null,"The tax is" + tax);}

else {

tax= value * .15;

JOptionPane.showMessageDialog(null,"The tax is" + tax);}

}
12. IN 2001 BIR proposed an overhaul of the income tax law. They proposed the ff. schedule

INCOME Tax rate

0 to 5000 0

5001 to10000 100 +3% of income over 5000

10001 to 25000 200 + 6% of income over 10000

25001 to 50000 300 +9% of income over 25000

Over 50000 500 + 15 % of income over 50000

// number 12

package javaapplication30;

import javax.swing.JOptionPane;

public class Main {

public static void main(String[] args) {

String input= "";

double income,tax;

input=JOptionPane.showInputDialog("Enter the income ");

income=Double.parseDouble(input);

if (income >=0&& income<=5000){

JOptionPane.showMessageDialog(null,"The tax rate is 0 " );}

else if (income >=5001 && income<=10000){

tax= 100+(income-5000)*.03;

JOptionPane.showMessageDialog(null,"The tax rate is " + tax);}

else if (income >=10001 && income<=25000){

tax= 200+(income-10000)* .06;

JOptionPane.showMessageDialog(null,"The tax rate is " + tax);}

else if (income >=250001 && income<=50000){

tax= 300+(income-25000)* .09;

JOptionPane.showMessageDialog(null,"The tax rate is " + tax );}

else {

tax= 500+(income - 50000) *.15;

JOptionPane.showMessageDialog(null,"The tax rate is " + tax );}

}
}

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;

public class Main {

public static void main(String[] args) {

String input= "";

double position,salary, newsalary;

input=JOptionPane.showInputDialog("Enter the employees position ");

position=Double.parseDouble(input);

input=JOptionPane.showInputDialog("Enter the salary ");

salary=Double.parseDouble(input);

if (position == 1){

JOptionPane.showMessageDialog(null,"Sales Person" );

newsalary= (salary* 0.15) + salary;

JOptionPane.showMessageDialog(null,"The new salary is " + newsalary );}

else if (position == 2){

JOptionPane.showMessageDialog(null,"Linemen" );

newsalary= (salary* 0.10) + salary;

JOptionPane.showMessageDialog(null,"The new salary is " + newsalary );}

else {

JOptionPane.showMessageDialog(null,"Engineer" );

newsalary= (salary* 0.08) + salary;

JOptionPane.showMessageDialog(null,"The new salary is " + newsalary );}


}

14. Design and develop a simple application program that’s adds, subtract, multiply and divide two input number

Sample output 5. exit

1. add 2 numbers Enter your choice: 1

2. subtract two numbers Enter the first number ; 10

3. multiply two numbers Enter the second number: 10

4. divide two numbers The sum is = 20

package javaapplication34;

import javax.swing.JOptionPane;

public class Main {

public static void main(String[] args) {

String input= "";

double choice,x,y,add,sub,div,mul;

input=JOptionPane.showInputDialog("Enter the choice ");

choice=Double.parseDouble(input);

input=JOptionPane.showInputDialog("Enter the first number ");

x=Double.parseDouble(input);

input=JOptionPane.showInputDialog("Enter the second number ");

y=Double.parseDouble(input);

if (choice==1){

add= x+y;

JOptionPane.showMessageDialog(null,"The sum is " + add );}

else if (choice==2){

sub= x-y;

JOptionPane.showMessageDialog(null,"The difference is " + sub);}


else if (choice==3){

mul= x*y;

JOptionPane.showMessageDialog(null," The product is" + mul );}

else if (choice==4){

div= x/y;

JOptionPane.showMessageDialog(null,"The qoutient is" + div);}

else{

JOptionPane.showMessageDialog(null, " Exit");}

15. Input 3 unique numbers and print the lowest.

package javaapplication35;

import javax.swing.JOptionPane;

public class Main {

public static void main(String[] args) {

String input= "";

int x,y,z;

input=JOptionPane.showInputDialog("Enter the first number ");

x=Integer.parseInt(input);

input=JOptionPane.showInputDialog("Enter the second number ");

y=Integer.parseInt(input);

input=JOptionPane.showInputDialog("Enter the third number ");

z=Integer.parseInt(input);

if (x<y && x<z){

JOptionPane.showMessageDialog(null,"The lowest number is " + x );}


else if (y<z){

JOptionPane.showMessageDialog(null,"The lowest number is " + y);}

else{

JOptionPane.showMessageDialog(null, " The lowest number is " + z);}

16. Input 3 unique numbers and arrange the numbers in lowest to highest order.

package javaapplication23;

import javax.swing.JOptionPane;

public class Main {

public static void main(String[] args) {

String input= "";

int a,b,c;

input=JOptionPane.showInputDialog("Enter the first number");

a=Integer.parseInt(input);

input=JOptionPane.showInputDialog("Enter the second number");

b=Integer.parseInt(input);

input=JOptionPane.showInputDialog("Enter the thrid number");

c=Integer.parseInt(input);

if (a<b && a<c && b<c) {

JOptionPane.showMessageDialog(null,"Arrangement lowest to highest is" + a + b + c);}

else if (a<c && a<b && c<b) {

JOptionPane.showMessageDialog(null,"Arrangement lowest to highest is" + a + c+ b); }


else if (b<a && b<c && a<c){

JOptionPane.showMessageDialog(null,"Arrangement lowest to highest is " + b + a + c );}

else if (b<c && b<a && c<a){

JOptionPane.showMessageDialog(null,"Arrangement lowest to highest is " + c+ a + b );}

else if (c<b && c<a && b<a){

JOptionPane.showMessageDialog(null,"Arrangement lowest to highest is " + c + b + a );}

else {

JOptionPane.showMessageDialog(null,"Arrangement lowest to highest is " + c + a + b );}

17. Input 3 unique numbers and print the difference of the highest and lowest numbers.

package javaapplication24;

import javax.swing.JOptionPane;

public class Main {

public static void main(String[] args) {

String input= "";

int a,b,c, diff;

input=JOptionPane.showInputDialog("Enter the first number ");

a=Integer.parseInt(input);

input=JOptionPane.showInputDialog("Enter the second number ");

b=Integer.parseInt(input);

input=JOptionPane.showInputDialog("Enter the third number ");


c=Integer.parseInt(input);

if (a<b && a<c && b<c){

diff= c-a;

JOptionPane.showMessageDialog(null," The difference is" + diff );}

else if (a<c && a<b && c<b){

diff= b-a;

JOptionPane.showMessageDialog(null," The difference is" + diff );}

else if (b<a && b<c && a<c){

diff= c-b;

JOptionPane.showMessageDialog(null," The difference is" + diff);}

else if (b<c && b<a && c<a){

diff= a-b ;

JOptionPane.showMessageDialog(null," The difference is" + diff );}

else if (c<b && c<a && b<a){

diff= a-c;

JOptionPane.showMessageDialog(null," The difference is" + diff );}

else {

diff= b-c;

JOptionPane.showMessageDialog(null," The difference is" + diff );}

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

Less than 0 Message

Between 0 to 100 Ice

Exceeds 100 Water


steam

package javaapplication37;

import javax.swing.JOptionPane;

public class Main {

public static void main(String[] args) {

String input= "";

double temp;

input=JOptionPane.showInputDialog("Enter the Temperature ");

temp=Double.parseDouble(input);

if (temp<=0 ){

JOptionPane.showMessageDialog(null," It is ice" );}

else if (temp>=0 && temp <=100){

JOptionPane.showMessageDialog(null," It is water " );}

else{

JOptionPane.showMessageDialog(null, " It is Steam");}

19. The national earthqpackage javaapplication26;

import javax.swing.JOptionPane;

public class Main {

public static void main(String[] args) {

String input= "";


double ritcher;

input=JOptionPane.showInputDialog("Enter the Rithcer Number ");

ritcher=Double.parseDouble(input);

if (ritcher<=5){

JOptionPane.showMessageDialog(null," little or no damage " );}

else if (ritcher>=5.0 && ritcher <= 5.5){

JOptionPane.showMessageDialog(null," some damage " );}

else if (ritcher>=5.5 && ritcher <= 6.5){

JOptionPane.showMessageDialog(null," serious damage " );}

else if (ritcher>=6.5 && ritcher <= 7.5){

JOptionPane.showMessageDialog(null," disaster " );}

else{

JOptionPane.showMessageDialog(null, " Castastrophe");}

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

Richter Number Characterization

Less than 5 Little or no damage

5.0 to 5.5 Some damage

5.5 to 6.5 Serious damage

20.

You might also like