Compilation In: Andres Soriano College
Compilation In: Andres Soriano College
Compilation in
Submitted by:
Joligen P. Ybañez
Submitted by:
Mr. Ricky Nemiño
package ICT7StringConcat;
package ICT7StringConcat;
String a="a",b="b",c="c",d="d",e="e",f="f",g="g",h="h";
String i="i",j="j",k="k",l="l",m="m",n="n",o="o",p="p";
String q="q",r="r",s="s",t="t", u="u",v="v",w="w",x="x";
String y="y",z="z";
package ICT7DesignAnalysisAlgorithm;
import javax.swing.JOptionPane;
public class StringClassJOP {
public static void main(String[]args){
String str1=" ";
str1=JOptionPane.showInputDialog(null,"Enter First String:");
String str2=" ";
str2=JOptionPane.showInputDialog(null,"Enter Second String:");
System.out.println("Combine String Example");
String com=str1.concat(str2);
System.out.println("Combine String:"+com);
}
}
package ICT7StringConcat;
public class StringClassReplace {
public static void main(String[]args){
String name= "Joligen";
String newName =name.replaceAll("Joligen","Jen");
System.out.println(newName);
}
package ICT7StringConcat;
String str3=str1.concat(str2);
System.out.println("The concatenated string:" + str3);
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ICT7_InputKeyboardType;
/**
*
* @author asc
*/
import java.util.Scanner;
public class InputScannerTestTypeOfHousesandGarages {
public static void main(String[]args){
int TypeofHouse=0;
int TypeofGarage=0;
Scanner input= new Scanner(System.in);
System.out.println("Enter the type of house you want to
purchase");
System.out.println("1-Single Family");
System.out.println("2-Townhouse");
System.out.println("3-Condominium");
System.out.println("Your choice");
TypeofHouse=input.nextInt();
System.out.println("HouseType:"+TypeofHouse);
System.out.println("Enter the type of garage you want");
System.out.println("0-Doesnt Matter");
System.out.println("1-Interior");
System.out.println("2-Exterior");
System.out.println("Your choice");
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ICT7_InputKeyboardType;
/**
*
* @author asc
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ICT7DesignAnalysisAlgorithm;
/**
*
* @author asc
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
package ICT7_InputKeyboardType;
import java.util.Scanner;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ICT7_InputKeyboardType;
import javax.swing.JOptionPane;
/**
*
* @author asc
*/
public class InputFromKeyBoardJOP {
public static void main(String[]args){
try {
String answer;
answer=JOptionPane.showInputDialog(null,"Speed in miles per
hour?");
double mph=Double.parseDouble(answer);
double kph= 1.621*mph;
JOptionPane.showInputDialog(null,"KPH=" +kph);
System.exit(0);
}catch(Exception e){
e.printStackTrace();
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ICT7DesignAnalysisAlgorithm;
import javax.swing.JOptionPane;
/**
*
* @author asc
*/
public class InputFromKeyboardJOP2 {
public static void main(String[]args){
try {
String answer;
answer=JOptionPane.showInputDialog(null,"Speed in miles per
hour?");
double mph=Double.parseDouble(answer);
double kph= 1.621*mph;
JOptionPane.showInputDialog(null,"KPH=" +kph);
System.exit(0);
}catch(Exception e){
e.printStackTrace();
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ICT7DesignAnalysisAlgorithm;
import javax.swing.JOptionPane;
/**
*
* @author asc
*/
public class InputFromKeyvoardJOptionPane2 {
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ICT7DesignAnalysisAlgorithm;
import java.util.Scanner;
/**
*
* @author asc
*/
public class InputScannerTest {
public static void main(String[]args){
int TypeofHouse=0;
int TypeofGarage=0;
Scanner input= new Scanner(System.in);
System.out.println("Enter the type of house you want to
purchase");
System.out.println("1-Single Family");
System.out.println("2-Townhouse");
System.out.println("3-Condominium");
System.out.println("Your choice");
TypeofHouse=input.nextInt();
System.out.println("HouseType:"+TypeofHouse);
System.out.println("Enter the type of garage you want");
System.out.println("0-Doesnt Matter");
System.out.println("1-Interior");
System.out.println("2-Exterior");
System.out.println("Your choice");
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ICT7_InputKeyboardType;
import java.util.Scanner;
/**
*
* @author asc
*/
public class InputScannerTestTypeOfHouseandGarage {
public static void main(String[]args){
int TypeofHouse=0;
int TypeofGarage=0;
Scanner input= new Scanner(System.in);
System.out.println("Enter the type of house you want to
purchase");
System.out.println("1-Single Family");
System.out.println("2-Townhouse");
System.out.println("3-Condominium");
System.out.println("Your choice");
TypeofHouse=input.nextInt();
System.out.println("HouseType:"+TypeofHouse);
System.out.println("Enter the type of garage you want");
System.out.println("0-Doesnt Matter");
System.out.println("1-Interior");
System.out.println("2-Exterior");
System.out.println("Your choice");
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ict7ybanez;
*
* @author asc
*/
public class Application1 {
/**
* @param args the command line arguments
*/
for(int i=1;i<=4;i++){
System.out.println(" ");
System.out.print( i);
System.out.print( i);
System.out.printf( " " );
System.out.print( i);
System.out.print( i );
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ict7ybanez;
import javax.swing.JOptionPane;
sum=number1+number2;
product=number1*number2 ;
difference =number1-number2;
quotient =number1/number2;
//
JOptionPane.showMessageDialog(
null, " The sum of two numbers is :"+sum+ "\n The product of
two numbers is :" +product+"\n The difference of two numbers
is :"+difference+"\n The quotient of two numbers is :"+quotient);
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ict7ybanez;
import javax.swing.JOptionPane;
String result;
int number1,
number2;
JOptionPane.showMessageDialog(
null, result, "The Results",
JOptionPane.PLAIN_MESSAGE);
System.exit( 0 );
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ict7ybanez;
import javax.swing.JOptionPane;
int num1,
num2,
num3,
sum, product;
int average,max,min;
num1 = Integer.parseInt( JOptionPane.showInputDialog( "Enter
first integer:" ) );
num2 = Integer.parseInt( JOptionPane.showInputDialog( "Enter
second integer:" ) );
num3 =Integer.parseInt( JOptionPane.showInputDialog( "Enter three
integer:" ) );
sum=num1+num2+num3;
product=num1*num2*num3;
average=(num1+num2+num3)/3;
max=(num1>num2)?num1:num2;
max=(max>num3)?max:num3;
min=(num1<num2)?num1:num2;
min=(min<num3)?min:num3;
JOptionPane.showMessageDialog(
null,"The sum of three integers: "+sum +"\nThe average of
three integers: "+average+
"\nThe product of three integers: "+product+
"\nThe smallest: "+ min+"\nThe largest: " +max, "The Results",
JOptionPane.PLAIN_MESSAGE);
System.exit( 0 );
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ict7ybanez;
import javax.swing.JOptionPane;
int number1,
number2,
number3,
number4,
number5
;
max=(number1>number2)?number1:number2;
max=(max>number3)?max:number3;
max=(max>number4)?max:number4;
max=(max>number5)?max:number5;
min=(number1<number2)?number1:number2;
min=(min<number3)?min:number3;
min=(min<number4)?min:number4;
min=(min<number5)?min:number5;
JOptionPane.showMessageDialog(
null,
" \nThe largest: " +max+"\nThe smallest: "+ min,"The Results",
JOptionPane.PLAIN_MESSAGE);
System.exit( 0 );
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ict7ybanez;
import javax.swing.JOptionPane;
if ( number % 2 == 0 )
result = "Number is even.";
else
result = "Number is odd.";
JOptionPane.showMessageDialog(
null, result, "The Results",
JOptionPane.PLAIN_MESSAGE );
System.exit( 0 );
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ict7ybanez;
import javax.swing.JOptionPane;
if ( number1 % 2==0 ){
result = number1+" is multiple of "+number2;
JOptionPane.showMessageDialog(null, result);
}
JOptionPane.showMessageDialog(
null,"The product of the two number is :"+product,"The
result",
JOptionPane.PLAIN_MESSAGE);
System.exit( 0 );
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ict7ybanez;
import javax.swing.JOptionPane;
*
* @author asc
*/
public class Application8 {
public static void main(String[]args){
String input,
result;
int radius;
JOptionPane.showMessageDialog(
null, result, " The Results",
JOptionPane.PLAIN_MESSAGE);
System.exit( 0 );
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
**/
package ict7ybanez;
import java.util.Scanner;
Assume that the user enters the correct number of digits. What happens
when you
* execute the program and type a number with more than five digits?
What happens
* when you execute the program and type a number with fewer than five
digits?
* [Hint: It is possible to do this exercise with the techniques you
learned in
* this chapter. You will need to use both division and remainder
operations to
* “pick off ” each digit.]
*
* @author asc
**/
public class Application9 {
public static void main(String[]args){
int num;
Scanner input=new Scanner(System.in);
System.out.println("Enter a number: ");
num=input.nextInt();
if(num/10000==0)
System.out.println("The input number is less than five digits");
if(num/10000>=10)
System.out.println("The input number is more than five digits");
if(num/10000!=0)
{
if(num/10000<10)
{
System.out.printf("%d ",num/10000);
System.out.printf("%d ",(num%10000)/1000);
System.out.printf("%d ",(num%1000)/100);
System.out.printf("%d ", (num%100)/10);
System.out.printf("%d",(num%10));
}
} }
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ict7ybanez;
int num = 0;
System.out.println("number\tsquare\tcube");
System.out.println(num + "\t" + num * num + "\t" + num * num * num);
num = num + 1;
System.out.println(num + "\t" + num * num + "\t" + num * num * num);
num = 2;
System.out.println(num + "\t" + num * num + "\t" + num * num * num);
num = 3;
System.out.println(num + "\t" + num * num + "\t" + num * num * num);
num = 4;
System.out.println(num + "\t" + num * num + "\t" + num * num * num);
num = 5;
System.out.println(num + "\t" + num * num + "\t" + num * num * num);
num = 6;
System.out.println(num + "\t" + num * num + "\t" + num * num * num);
num = 7;
System.out.println(num + "\t" + num * num + "\t" + num * num * num);
num = 8;
System.out.println(num + "\t" + num * num + "\t" + num * num * num);
num = 9;
System.out.println(num + "\t" + num * num + "\t" + num * num * num);
num = 10;
System.out.println(num + "\t" + num * num + "\t" + num * num * num);
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ict7ybanez;
import java.util.Scanner;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ict7ybanez;
*
* @author asc
*/
public class Application12 {
public static void main(String[]args){
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ICT7Quizzes;
/**
*
* @author ASC
*/
public class MaxMain {
public static void main(String[]args){
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ICT7Quizzes;
import javax.swing.JOptionPane;
/**
*
* @author ASC
*/
public class MaxCalculation {
break;
case 2:
price = 216;
menu = "Max's Platter";
break;
case 3:
price = 212;
menu = "Max's Chopsuey Meal";
break;
case 4:
price = 205;
menu = "Max's Fiesta Plate";
break;
case 5:
price = 190;
menu = "Max's Budget Meal";
break;
case 6:
price = 147;
menu = "Max's Basic";
break;
case 7:
price = 196;
menu = "Max's Chicken BBQ Meal";
break;
case 8:
price = 50;
menu = "Soft Drink";
break;
case 9:
JOptionPane.showMessageDialog(null, transaction +
"Display transaction :"+ qtotal+ "\n Total Sales :"+total);
JOptionPane.showMessageDialog(null, "You are about
to exit");
a: do {
con =
Integer.parseInt(JOptionPane.showInputDialog(null, "Do you want to exit?
(1)yes (2)No"));
if (con == 1) {
System.exit(0);
} else if (con == 2) {
System.out.println("Wrong Choice");
} else {
JOptionPane.showMessageDialog(null,"Thank
You And Come Again!!!" );
}
break;
default:
JOptionPane.showMessageDialog(null, "Invalid
Choice");
// continue;
}
do {
qty = Integer.parseInt(JOptionPane.showInputDialog(null,
"Enter a quantity"));
if (qty<=0) {
JOptionPane.showMessageDialog(null, "Invalid
quantity");
break;
} else {
break;
}
do {
con = Integer.parseInt(JOptionPane.showInputDialog(null,
"Continue (1)Yes or(2)No"));
if (con == 1) {
// continue outer;
con =
Integer.parseInt(JOptionPane.showInputDialog(null, "Do you want to exit?
(1)yes (2)No"));
if (con == 1) {
System.exit(0);
} else if (con == 2) {
System.out.println("Wrong Choice");
} else {
JOptionPane.showMessageDialog(null,"Thank
You And Come Again!!!" );
}
}
else{
JOptionPane.showMessageDialog(null,"Thank You And Come
Again!!!");
}
break;
} while (y == 1);
do {
} while (z == 1);
y=1;
//continue;
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ICT7Quizzes;
import javax.swing.JOptionPane;
/**
*
* @author ASC
*/
public class MaxDisplaymenu {
public int choice;
public void Display(){
choice = Integer.parseInt(JOptionPane.showInputDialog(null, "
**********MAX'S COMBO MEALS**********\n\n" +
"\nM[1] Max's Spring Chicken
Meal_______________________________________P242.00\n " +
" 1/2 Max's spring chicken,soup of the day,rice
rolls,iced tea,caramel bar\n" +
"\nM[2] Max's
Platter__________________________________________________P216.0 \n " +
" 1/4 regular fried chicken,pancit canton.rice
rolls,iced tea, caramel bar\n" +
"\nM[3] Max's Chopsuey
Meal___________________________________________P212.00\n " +
" 1/4 regular fried chicken, chopsuey,rice or
rolls, iced tea,caramel bar\n" +
"\nM[4] Max's Fiesta
Plate______________________________________________P205.00\n " +
" 1/4 regular fried chicken,fresh lumpia,rice or
roll,iced tea,caramel bar\n" +
"\nM[5] Max's Budget
Meal_____________________________________________P190.00\n " +
" 1/4 regular fried chicken,rice or rolls,iced
tea, caramel bar\n" +
"\nM[6] Max's
Basic__________________________________________________
package MidtermYbanez;
import javax.swing.JOptionPane;
public class MaxRestaurant{
public static void main(String[] args) {
int choice, con = 1, x = 1, y = 1, z = 1, q = 1;
int trans = 0, price, qty, qtotal = 0;
int pay, change, total = 0, ord;
String order = "", menu, transaction = " ";
choice = Integer.parseInt(JOptionPane.showInputDialog(null,
" **********MAX'S COMBO
MEALS**********\n\n" +
"\nM[1] Max's Spring Chicken
Meal_______________________________________P242.00\n " +
" 1/2 Max's spring chicken,soup of the day,rice
rolls,iced tea,caramel bar\n" +
"\nM[2] Max's
Platter__________________________________________________P216.0 \n " +
" 1/4 regular fried chicken,pancit canton.rice
rolls,iced tea, caramel bar\n" +
"\nM[3] Max's Chopsuey
Meal___________________________________________P212.00\n " +
" 1/4 regular fried chicken, chopsuey,rice or
rolls, iced tea,caramel bar\n" +
"\nM[4] Max's Fiesta
Plate______________________________________________P205.00\n " +
" 1/4 regular fried chicken,fresh lumpia,rice or
roll,iced tea,caramel bar\n" +
"\nM[5] Max's Budget
Meal_____________________________________________P190.00\n " +
" 1/4 regular fried chicken,rice or rolls,iced
tea, caramel bar\n" +
"\nM[6] Max's
Basic__________________________________________________P147.00\n " +
" 1/4 regular fried chicken,rice or rolls,iced
tea, caramel bar\n" +
"\nM[7] Max's Chicken BBQ
Meal________________________________________P196.00\n " +
" 2pcs.of choice out leg and thigh chicken,
grilled with special BBq sauce,rice iced tea\n" +
"\nD[8] Soft
Drink____________________________________________________P50.00\n " +
" 1 can of [Coke,Sprite,Royal,Pepso]\n" +
"\n[9] Exit"));
switch (choice) {
case 1:
price = 242;
menu = "Max's Spring Chicken Meal";
break;
case 2:
price = 216;
menu = "Max's Platter";
break;
case 3:
price = 212;
menu = "Max's Chopsuey Meal";
break;
case 4:
price = 205;
menu = "Max's Fiesta Plate";
break;
case 5:
price = 190;
menu = "Max's Budget Meal";
break;
case 6:
price = 147;
menu = "Max's Basic";
break;
case 7:
price = 196;
menu = "Max's Chicken BBQ Meal";
break;
case 8:
price = 50;
menu = "Soft Drink";
break;
case 9:
JOptionPane.showMessageDialog(null, "Display
transaction :\n"+order+"\n Total Sales : Php "+qtotal+".00");
JOptionPane.showMessageDialog(null, "You are about
to exit");
a:do {
con =
Integer.parseInt(JOptionPane.showInputDialog(null, "Do you want to exit?
(1)yes (2)No"));
if (con == 1) {
JOptionPane.showMessageDialog(null,"Thank
You And Come Again!!!" );
System.out.print("Display
transaction :"+order+"\n Total Sales : Php "+qtotal+".00");
System.exit(0);
} else if (con == 2) {
continue outer;
} else {
JOptionPane.showMessageDialog(null,"Invalid
Input");
}
break;
default:
JOptionPane.showMessageDialog(null, "Invalid
Choice");
continue;
}
do {
qty = Integer.parseInt(JOptionPane.showInputDialog(null,
"Enter a quantity"));
if (qty<=0) {
JOptionPane.showMessageDialog(null, "Invalid
quantity");
break;
} else {
// continue;
} while (con == 1);
inner:do {
con = Integer.parseInt(JOptionPane.showInputDialog(null,
"Continue (1)Yes or(2)No"));
if (con == 1) {
continue outer;
if (con == 1) {
JOptionPane.showMessageDialog(null,"Thank
You And Come Again!!!" );
System.out.print("Display transaction
:\n"+order+"\n Total Sales : Php "+qtotal+".00");
System.exit(0);
} else if (con == 2) {
continue outer;
} else {
JOptionPane.showMessageDialog(null,"Invalid
Input");
continue inner;
}
}
else{
JOptionPane.showMessageDialog(null,"Invalid Input");
}
continue inner;
} while (y == 1);
do {
} while (z == 1);
y=1;
continue;
}
}
}
P147.00\n " +
" 1/4 regular fried chicken,rice or rolls,iced
tea, caramel bar\n" +
"\nM[7] Max's Chicken BBQ
Meal________________________________________P196.00\n " +
" 2pcs.of choice out leg and thigh chicken,
grilled with special BBq sauce,rice iced tea\n" +
"\nD[8] Soft
Drink____________________________________________________P50.00\n " +
" 1 can of [Coke,Sprite,Royal,Pepso]\n" +
"\n[9] Exit"));
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package July21_10;
import javax.swing.JOptionPane;
/**
*
* @author asc
*/
public class Quiz2 {
int costofanitem;
int totalcost=0;
costofanitem
=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter cost of an
item"));
totalcost=costofanitem;
while(costofanitem>0){
costofanitem
=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter cost of an
item" ));
totalcost+=costofanitem;
}
if(costofanitem ==0)
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ict7ybanez;
/**
*
* @author asc
*/
public class arrayinitialized {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
long
[]shelfnumbers={2985,8024,5170,1304,9187,3119,3082,8632,4633,9623};
String[] titles={"distinguished gentleman","perfect
murder","solt","ransom",
"not another ten
minutes","mad","getshorty","snickers","borninvisible","hush"
};
String []directors={"Jonathan Limm","Andrew Devis","Asis
Mirza","Ron Howard","Jonel Gollen",
"Shibram Shadam","Barrey Sallen","Paul
Abdul","Robinson","Jonathan Darve"};
int[]lenght= {112,108,145,121,100,0,105,126,90,96};
String[]ratings={"R","R","R","NR","UR","NR","R","PG-
13","NR","PG-13"};
double[]prices={14.95,19.95,22.25,14.95,9.95,17.50,9.95,5.95,8.75,8.90};
for(int i=0;i<=9;i++){
System.out.println("Video:"+i);
System.out.println("\t"+
"ShelfNumbers="+shelfnumbers[i]);
System.out.println("\t"+"Titles="+titles[i]);
System.out.println("\t"+"Directors="+directors[i]);
System.out.println("\t"+"Lenght="+lenght[i]);
System.out.println("\t"+"Ratings="+ratings[i]);
System.out.println
("\t"+"Prices="+"$"+prices[i]) ;
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package July21_10;
import javax.swing.JOptionPane;
/**
*
* @author asc
*/
public class arrayinput {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
long []shelfnumbers=new long[10];
String[] titles=new String[10];
String []directors=new String[10];
int[]lenght=new int[10];
String[]ratings=new String[10];
double[]prices=new double[10];
for(int i=0;i<=9;i++){
JOptionPane.showMessageDialog(null,"Video:"+i+"\n"+"\t
Shelfnumbers= "+Entershelfnumbers+"\n "+"\t Tiltles= "+ searchtitles+"\n
"+
"\t Directors= "+searchdirectors+"\n "+"\t Lenght=
"+searchlenght+"\n "+"\t Ratings= "+searchrating+"\n "+
"\t Prices= "+searchprices);
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package array;
/**
*
* @author asc
*/
public class Daysofweek {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String[]Days={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturd
ay","Sunday"};
for(int j=0;j<Days.length;j++)
{
System.out.println("The abbreviation for " + Days[j] + " is "+
Days[j].substring(0,3)+"." );
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package July21_10;
/**
*
* @author asc
*/
public class do_while {
public static void main(String[]args){
int j=0,k=9,i=0;
System.out.println("Print number:");
do{
do{
do{
System.out.println("\t"+j+"\t"+k+"\t"+i);
j++;
k--;
i++;
}while(i<=0);
}while(k>=0);
}
while(j<=9);
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Method;
/**
*
* @author asc
*/
public class Employee {
private String firstname;
private String lastname;
private double monthlysalary ;
this.lastname = lastname;
}
this.monthlysalary = monthlysalary;
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Method;
System.out.println("Name:"+ Em.getFirstname());
System.out.println("Last name:"+Em.getLastname());
double Emsalary=Em.getMonthlysalary()*12;
System.out.println("Monthly Salary:"+ Em.getMonthlysalary());
System.out.println("Yearly:"+ Emsalary);
System.out.println("Employee 10% rate increase:" );
double Emsalary1=(Em.getMonthlysalary()*12*.10)+
(Em.getMonthlysalary()*12);
System.out.println(Emsalary1);
System.out.println("\nName:"+ Jm.getFirstname());
System.out.println("Last name:"+Jm.getLastname());
double Jmsalary=Jm.getMonthlysalary()*12;
System.out.println("Monthly Salary:"+ Jm.getMonthlysalary());
System.out.println("Yearly:"+ Jmsalary);
System.out.println("Employee 10% rate increase:" );
double Jmsalary2=(Jm.getMonthlysalary()*12*.10)+
(Jm.getMonthlysalary()*12);
System.out.println(Jmsalary2);
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Method;
/**
*
* @author Administrator
*/
// A simple example of recursion.
class Factorial {
// this is a recursive function
int fact(int n) {
int result;
if(n==1) return 1;
result = fact(n-1) * n;
return result;
}
}
class Recursion {
public static void main(String args[]) {
Factorial f = new Factorial();
System.out.println("Factorial of 3 is " + f.fact(3));
System.out.println("Factorial of 4 is " + f.fact(4));
System.out.println("Factorial of 5 is " + f.fact(5));
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Method;
/**
*
* @author asc
*/
public class Invoice {
package Method;
*
* @author asc
*/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ICt7;
/**
*
* @author asc
*/
public class Invoice2 {
private String Firstnane;
private String Lastname;
private String Socialsecuritynumber;
private double grosssales;
private double commisionrate;
public Invoice2(String Fname,String Lname,String Socialnumber,double
grosales,double comrate){
this.Firstnane=Fname;
this.Lastname=Lname;
this.Socialsecuritynumber=Socialnumber;
this.grosssales=grosales;
if (grosssales<0)
grosssales=0;
this.commisionrate=comrate;
if(commisionrate<0)
commisionrate=0;
this.grosssales = grosssales;
}
this.commisionrate = commisionrate;
}
public double basesalary(){
return commisionrate*grosssales;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ICT7;
/**
*
* @author asc
*/
public class Invoice2Test {
public static void main(String[]args){
Invoice2 myinv= new
Invoice2("Joligen","Ybanez","0986",5000,.10);
System.out.println("First Name:"+myinv.getFirstnane());
System.out.println("Last Name:"+myinv.getLastname());
System.out.println("Social Security
Number:"+myinv.getSocialsecuritynumber());
System.out.println("Gross Sales:"+myinv.getGrosssales());
System.out.println("Commision Rate:"+myinv.getCommisionrate());
System.out.println("Total:"+myinv.basesalary());
System.out.println("First Name:"+myin.getFirstnane());
System.out.println("Last Name:"+myin.getLastname());
System.out.println("Social Security
Number:"+myin.getSocialsecuritynumber());
System.out.println("Gross Sales:"+myin.getGrosssales());
System.out.println("Commision Rate:"+myin.getCommisionrate());
System.out.println("Total:"+myin.basesalary());
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ICT7DesignAnalysisAlgorithm;
import javax.swing.JOptionPane;
/**
*
* @author asc
*/
public class JOptionPaneTest {//... Text to put on the buttons.
public static void main(String []args){
//Line 11 This defines an array of strings that will be
displayed as possible choices.
String[] choices = {"Democratic", "Republican", "None of your
business","My business", "Cancel"};
switch (response) {
case 0:
democraticCount++;
break;
case 1:
republicanCount++;
break;
case 2:
noAnswerCount++;
break;
case 3:
mybusiness++;
break;
case -1:
//... Both the quit button (3) and the close box(-1)
handled here.
//System.exit(0) is not the best way to stop this
program
/*System.exit(0) stops the execution of a program,
but it it isn't always the best choice.
*A better way would be to exit the loop so that any
final processing could be done.
*This requires either an extra boolean variable to
tell whether we should continue in the loop,
*or a break that terminates the loop.
Unfortunately, the break statement is used both in the
*switch statement and in loops,
*/
System.exit(0); // It would be better to exit
loop, but...
default:
//... If we get here, something is wrong. Defensive
programming.
JOptionPane.showMessageDialog(null, "Unexpected
response " + response);
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ICT7_InputKeyboardType;
import javax.swing.JOptionPane;
/**
*/
public class JOptionPaneTestVoting {
public static void main(String []args){
int democraticCount = 0;
int republicanCount = 0;
int noAnswerCount = 0;
int mybusiness = 0;
while (true) {
int response = JOptionPane.showOptionDialog(null, "How did
you vote?", "Party Poll",JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE,null,choices,"None of your Business");
switch (response) {
case 0:
democraticCount++;
break;
case 1:
republicanCount++;
break;
case 2:
noAnswerCount++;
break;
case 3:
mybusiness++;
break;
case -1:
System.exit(0);
default:
JOptionPane.showMessageDialog(null, "Unexpected
response " + response);
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package LinearSearch;
/**
*
* @author asc
*/
public class LinearSearch {
public static void main(String args[]){
int num[]={1,2,3,4,5,6,7,8,9,10};
System.out.println( "The array element:");
for(int i=0;i<num.length;i++){
}
System.out.println(num[0]+"Found!");
System.out.println(num[4]+"Found!");
System.out.println(num[9]+"Found!");
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ICT7DesignAnalysisAlgorithm;
/**
*
* @author asc
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.swing.JOptionPane;
public class Quiz {
public static void main (String[]args)throws IOException{
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package July21_10;
/**
*
* @author asc
*/
public class Quiz1 {
while(j<=9){
while(i>=0){
while(k<=9){
System.out.println("\t"+j+"\t"+i+"\t"+k);
j++;
i--;
k++;
}
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Method;
import java.util.Scanner;
/**
*
* @author asc
*/
public class MainAccount {
public static void main(String[]args){
Account account1 = new Account(50.00);
Account account2 = new Account(-7.53);
System.out.printf("Account balance:$%.2f\n",
account1.getBalance());
System.out.printf("Account balance:$%.2f\n\n",
account2.getBalance());
account1.setBalanceCredit(deposit);
System.out.printf("Account balance:$%.2f\n",
account1.getBalance());
System.out.printf("Account balance:$%.2f\n\n",
account2.getBalance());
System.out.printf("Enter deposit amount for account2: ");
deposit = input.nextDouble();
System.out.printf("\nadding %.2f to account2 balance\n\n",
deposit);
account2.setBalanceCredit(deposit);
double withdraw;
account1.setBalancedebit(withdraw);
System.out.printf("Account balance:$%.2f\n",
account1.getBalance());
System.out.printf("Account balance:$%.2f\n\n",
account2.getBalance());
withdraw = input.nextDouble();
account2.setBalancedebit(withdraw);
class Account {
Account(double ibalance){
if(ibalance>0.00)
balance=ibalance;
}
//the balance
public double getBalance() {
return balance;
}
//deposit
balance = balance+amount;
}
public void setBalancedebit(double amount) {
//withdraw
balance = balance-amount;
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
import javax.swing.JOptionPane;
/**
*
* @author Ybanez
*/
public class finalexam {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String names[][]= new String[3][1];
String input[] = new String[100];
int calculate = 0;
int max=0;
System.out.println("Input "+names[j][i]);
}
}