Sie sind auf Seite 1von 47

ANDRES SORIANO COLLEGE

Mangagoy, Bislig City

Compilation in

Submitted by:
Joligen P. Ybañez

Submitted by:
Mr. Ricky Nemiño
package ICT7StringConcat;

public class StringClass {


public static void main(String[]args){
String firstName="Joligen";
String lastName="Ybanez";
System.out.println(firstName+ " "+lastName);
}

package ICT7StringConcat;

public class StringClassAlphabet {


public static void main(String[]args){
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";

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

System.out.print("Name :"+"\t"+J+o+l+i+g+e+n+" "+P+"


"+Y+b+a+n+e+z+"\n");
System.out.println("Age :"+"\t"+"21"+" "+y+e+a+r+s+"
"+o+l+d);
System.out.println("B-day :"+"\t"+S+e+p+t+e+m+b+e+r+"
"+"16,"+"1988" );
System.out.println("Address :"+"\t"+G+u+a+v+a+"
"+J+u+n+c+t+i+o+n+","+" "+B+i+s+l+i+g+" "+C+i+t+y);

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;

public class StringConcact {

public static void main(String[] args) {


// TODO code application logic here
String str1="This is the beginning";
String str2="of my application";

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;

public class GetInputFromKb {


public static void main(String [] args){
BufferedReader dataIn = new BufferedReader(new
InputStreamReader(System.in));
String name="";
System.out.println("Please enter your name:");
try
{
name = dataIn.readLine();
}
catch (IOException e)
{
System.err.println("error");
}
System.out.println("Hello" +" "+ name);
}
}

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

public class GetInputFromKeyboard2 {


public static void main(String [] args){
BufferedReader dataIn = new BufferedReader(new
InputStreamReader(System.in));
String name="";
System.out.println("Please enter your name:");
try
{
name = dataIn.readLine();
}
catch (IOException e)
{
System.err.println("error");
}
System.out.println("Hello" +" "+ name);
}
}

package ICT7_InputKeyboardType;
import java.util.Scanner;

public class ImportFromKeyBoardScanner {


public static void main(String [] args){
Scanner input = new Scanner(System.in);

boolean DrivingUnderAge = false;


System.out.println("Were you driving under age?");
System.out.println("If YES, enter TRUE, otherwise enter
FAlSE.");
DrivingUnderAge = input.nextBoolean();
System.out.println("Was driving under age:" + DrivingUnderAge);
}
}

/*
* 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 {

public static void main(String [] args){


String name="";
name = JOptionPane.showInputDialog("Enter your name:");
String mag = "Hello"+ name + "!";
JOptionPane.showMessageDialog(null, mag);
}
}

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

/**Write an application that displays the numbers


* 1 to 4 on the same line, with each pair of adjacent
* numbers separated by one space. Write the program using
* the following techniques:
a) Use one System.out.println statement.
b) Use four System.out.print statements.
c) Use one System.out.printf statement.

*
* @author asc
*/
public class Application1 {

/**
* @param args the command line arguments
*/

public static void main(String[] args) {

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;

/**Write an application that asks the user to enter two


* integers, obtains them from the user and prints their
* sum, product, difference and quotient (division).
*
* @author asc
*/
public class Application2 {
public static void main(String[]args){

int sum=1, product=0, difference=1,quotient=0;


int number1,
number2;

// convert numbers from type String to type int


number1 = Integer.parseInt(JOptionPane.showInputDialog( "Enter
first integer:"));
number2 = Integer.parseInt(JOptionPane.showInputDialog( "Enter
second integer:" ));

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;

/** Write an application that asks the user to enter two


* integers, obtains them from the user and displays the larger number
* followed by the words "is larger". If the numbers are equal,
* print the message "These numbers are equal".
*
* @author Server
*/
public class Application3 {
public static void main (String[]args){

String result;
int number1,
number2;

number1 = Integer.parseInt(JOptionPane.showInputDialog( "Enter


first integer:" ) );
number2 = Integer.parseInt( JOptionPane.showInputDialog( "Enter
second integer:" ));

if ( number1 > number2 )


result = number1 + " is larger.";
else if ( number1 < number2 )
result = number2 + " is larger.";
else
result = "These numbers are equal.";

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;

/**Write an application that inputs three integers


* from the user and displays the sum, average, product,
* smallest and largest of the numbers.
* [Note: The calculation of the average in this exercise should result
in an integer
* representation of the average. So if the sum
* of the values is 7, the average should be 2, not 2.3333….]
*
* @author asc
*/
public class Application4 {
public static void main(String[]args){

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;

/** Write an application that reads five integers,


* determines and prints the largest
* and smallest integers in the group.
*
* @author asc
*/
public class Application5 {
public static void main(String[]args){

int max, min;

int number1,
number2,
number3,
number4,
number5
;

number1 = Integer.parseInt(JOptionPane.showInputDialog( "Enter


first integer:" ) );
number2 = Integer.parseInt( JOptionPane.showInputDialog( "Enter
second integer:" ));
number3=Integer.parseInt( JOptionPane.showInputDialog( "Enter
third integer:" ));
number4=Integer.parseInt( JOptionPane.showInputDialog( "Enter
fourth integer:" ));
number5=Integer.parseInt( JOptionPane.showInputDialog( "Enter
fifth integer:" ));

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;

/**. Write an application that reads an


* integer and determines and prints whether it
* is odd or even. [Hint: Use the remainder operator. An even number
* is a multiple of 2. Any multiple of 2 leaves a remainder of 0 when
divided by 2.]
*
* @author asc
*/
public class Application6 {
public static void main(String[]args){
String input,
result;
int number;

input =JOptionPane.showInputDialog( "Enter integer:" );

number = Integer.parseInt( input );

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;

/**Write an application that reads two integers,


* determines whether the first is a multiple of the second
* and prints the result. [Hint: Use the remainder operator.]
*
* @author asc
*/
public class Application7 {
public static void main(String[]args){
String result = null;
int number1,
number2,
product=1;

number1 = Integer.parseInt(JOptionPane.showInputDialog( "Enter


first integer:" ) );
number2 = Integer.parseInt( JOptionPane.showInputDialog( "Enter
second integer:" ));
product=number1*number2;

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;

/**Java can also represent floating-point numbers that contain decimal


points,
* such as 3.14159. Write an application that inputs from the user the
radius
* of a circle as an integer and prints the circle’s diameter,
circumference and
* area using the floating-point value 3.14159 for . [Note: You may
also use
* the predefined constant Math.PI for the value of . This constant is
more
* precise than the value 3.14159. Class Math is defined in package
java.lang.
* Classes in that package are imported automatically, so you do not
need to import
* class Math to use it.] Use the following formulas (r is the radius):
diameter = 2r
circumference = 2r
area = r2
Do not store the results of each calculation in a variable. Rather,
specify each
* calculation as the value that will be output in a System.out.printf
statement.
* Note that the values produced by the circumference and area
calculations are
* floating-point numbers. Such values can be output with the format
specifier
* %f in a System.out.printf statement.

*
* @author asc
*/
public class Application8 {
public static void main(String[]args){
String input,
result;
int radius;

input =JOptionPane.showInputDialog( "Enter radius:" );

radius = Integer.parseInt( input );

result = "Diameter is " + ( 2 * radius ) +

"\nCircumference is " + ( 2 * Math.PI * radius )+

"\nArea is " + ( Math.PI


* radius * 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;

/**Write an application that inputs one number consisting of five digits


from
* the user, separates the number into its individual digits and prints
the
* digits separated from one another by three spaces each. For example,
if the
* user types in the number 42339, the program should print

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;

/**Using only the programming techniques you learned in this chapter,


* write an application that calculates the squares and cubes of the
numbers
* from 0 to 10 and prints the resulting values in table format, as
shown below.
* [Note: This program does not require any input from the user.]
*
* @author asc
**/
public class Application10 {
public static void main(String[]args){

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;

/**Write a program that inputs five numbers and determines and


* prints the number of negative numbers input, the number of positive
* numbers input and the number of zeros input.
*
* @author asc
**/
public class Application11 {
public static void main(String[] args) {
int num1,num2,num3,num4,num5,negative = 0,positive = 0,zero = 0;
Scanner input = new Scanner(System.in);
System.out.println("Enter first number: ");
num1 = input.nextInt();
if(num1<0){
negative=1;
}
if (num1>0){
positive=1;
}
if (num1==0){
zero=1;
}
System.out.println("Enter second number: ");
num2 = input.nextInt();
if(num2<0){
negative=1+negative;
}
if (num2>0){
positive=1+positive;
}
if (num2==0){
zero=1+zero;
}
System.out.println("Enter third number: ");
num3 = input.nextInt();
if(num3<0){
negative=1+negative;
}
if (num3>0){
positive=1+positive;
}
if (num3==0){
zero=1+zero;
}
System.out.println("Enter fourth number: ");
num4 = input.nextInt();
if(num4<0){
negative=1+negative;
}
if (num4>0){
positive=1+positive;
}
if (num4==0){
zero=1+zero;
}
System.out.println("Enter fifth number: ");
num5 = input.nextInt();
if(num5<0){
negative=1+negative;
}
if (num5>0){
positive=1+positive;
}
if (num5==0){
zero=1+zero;
}
System.out.println("The number of negative input: "+negative+
"\nThe number of positive input: "+positive+
"\nThe number of zeros input:"+zero);

}
}

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package ict7ybanez;

/**Java can also represent uppercase letters, lowercase letters and a


considerable
* variety of special symbols. Every character has a corresponding
integer
* representation. The set of characters a computer uses and the
corresponding
* integer representations for those characters is called that
computer’s character
* set. You can indicate a character value in a program simply by
enclosing that
* character in single quotes, as in 'A'. You can determine the integer
equivalent
* of a character by preceding that character with (int), as in (int)
'A'
This form is called a cast operator. The following statement outputs a
character
* and its integer equivalent:
System.out.printf(
"The character %c has the value %d\n", 'A', ( (int) 'A' ) );
When the preceding statement executes, it displays the character A and
the value
* 65 (from the Unicode ® character set) as part of the string. Note
that the format
* specifier %c is a placeholder for a character (in this case, the
character 'A').
Using statements similar to the one shown earlier in this exercise,
write an application
* that displays the integer equivalents of some uppercase letters,
lowercase letters,
* digits and special symbols. Display the integer equivalents of the
following:
* A B C a b c 0 1 2 $ * + / and the blank character.

*
* @author asc
*/
public class Application12 {
public static void main(String[]args){

System.out.println( "The character " + 'A' +


" has the value " + ( int ) 'A' );
System.out.println( "The character " + 'B' +
" has the value " + ( int ) 'B' );
System.out.println( "The character " + 'C' +
" has the value " + ( int ) 'C' );
System.out.println( "The character " + 'a' +
" has the value " + ( int ) 'a' );
System.out.println( "The character " + 'b' +
" has the value " + ( int ) 'b' );
System.out.println( "The character " + 'c' +
" has the value " + ( int ) 'c' );
System.out.println( "The character " + '0' +
" has the value " + ( int ) '0' );
System.out.println( "The character " + '1' +
" has the value " + ( int ) '1' );
System.out.println( "The character " + '2' +
" has the value " + ( int ) '2' );
System.out.println( "The character " + '$' +
" has the value " + ( int ) '$' );
System.out.println( "The character " + '*' +
" has the value " + ( int ) '*' );
System.out.println( "The character " + '/' +
" has the value " + ( int ) '/' );

/*
* 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){

MaxDisplaymenu MyDisplay= new MaxDisplaymenu ();


MyDisplay.Display();
MaxCalculation mycalculation=new MaxCalculation();
mycalculation.Quantity();

/*
* 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 {

public void Quantity(){


int con = 1, x = 1, y = 1, z = 1, q = 1;
int trans = 0, price=0, qty, qtotal = 0;
int pay, change, total = 0, ord;
String order = "", menu=order, transaction = " ";
MaxDisplaymenu Cal=new MaxDisplaymenu();
Cal.Display();
switch (Cal.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, 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;

} while (qty == 1);


// continue;

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 {

total = price * qty;


qtotal += total;
order = order + menu + " " + qty + "@" + price + "="
+ total + "\n";

break;
}

} while (con == 1);

do {
con = Integer.parseInt(JOptionPane.showInputDialog(null,
"Continue (1)Yes or(2)No"));
if (con == 1) {
// continue outer;

} else if (con == 2){

JOptionPane.showMessageDialog(null, transaction + "Display


transaction :"+ qtotal+ "\n Total Sales :"+total);
JOptionPane.showMessageDialog(null, "You are about
to exit");

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 = " ";

JOptionPane.showMessageDialog(null, "Welcome to MAX's


Restaurant");
outer: while (x == 1) {

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;

} while (qty == 1);


continue;

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 {

total = price * qty;


qtotal += total;
order = order + menu + " " + qty + " @ Php " + price
+ ".00 = Php " + total +".00"+ "\n";
JOptionPane.showMessageDialog(null, order);
break;
}

// continue;
} while (con == 1);

inner:do {
con = Integer.parseInt(JOptionPane.showInputDialog(null,
"Continue (1)Yes or(2)No"));
if (con == 1) {
continue outer;

} else if (con == 2){


JOptionPane.showMessageDialog(null, "Display
transaction :\n"+order+"\n Total Sales : Php "+qtotal+".00");
JOptionPane.showMessageDialog(null, "You are about
to exit");
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
:\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 {

public static void main(String[]args){

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)

JOptionPane.showMessageDialog(null,"The total cost:" +totalcost);

/*
* 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++){

int Entershelfnumbers =Integer.parseInt


(JOptionPane.showInputDialog(null,"ShelfNumbers="));
String
searchtitles=JOptionPane.showInputDialog(null,"Titles=");
String
searchdirectors=JOptionPane.showInputDialog(null , "Directors=");
int
searchlenght=Integer.parseInt( JOptionPane.showInputDialog(null,"Lenght=
"));
String searchrating=
JOptionPane.showInputDialog(null,"Ratings=");
int searchprices=
Integer.parseInt( JOptionPane.showInputDialog(null,"Prices="+"$")) ;

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 ;

public Employee(String firstn,String lastn,double monthlysry){


this.firstname=firstn;
this.lastname=lastn;
this.monthlysalary=monthlysry;
if(monthlysalary<0)
monthlysalary=0;

public String getFirstname() {


return firstname;
}

public void setFirstname(String firstname) {


this.firstname = firstname;
}

public String getLastname() {


return lastname;
}

public void setLastname(String lastname) {

this.lastname = lastname;
}

public double getMonthlysalary() {


return monthlysalary;
}

public void setMonthlysalary(double monthlysalary) {

this.monthlysalary = monthlysalary;
}

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package Method;

/**3. Create a class called Employee that includes three pieces


* of information as instance variables—a first name (type String)
* , a last name (type String) and a monthly salary (double). Your
* class should have a constructor that initializes the three
* instance variables. Provide a set and a get method for each
* instance variable. If the monthly salary is not positive, set
* it to 0.0. Write a test application named EmployeeTest that
* demonstrates class Employee’s capabilities. Create two Employee
* objects and display each object’s yearly salary. Then give each
* Employee a 10% raise and display each Employee’s yearly salary
again.
*
*
* @author asc
*/
public class EmployeeTest {
public static void main(String[]args){
// String
// jen;
// String jin;
Employee Em= new Employee(" Joligen","Ybanez",500);
Employee Jm= new Employee("Grace","Malina",250);

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 {

private String Partnumber;


private String PartDescription;
private int Quantity;
private double price;

Invoice(String Pnum, String Pdes, int qty, double prce) {


Partnumber = Pnum;
PartDescription = Pdes;
Quantity = qty;
price = prce;

public String getPartnumber() {


return Partnumber;
}

public void setPartnumber(String Partnumber) {


this.Partnumber = Partnumber;
}
public String getPartDescription() {
return PartDescription;
}

public void setPartDescription(String PartDescription) {


this.PartDescription = PartDescription;
}

public int getQuantity() {


return Quantity;
}

public void setQuantity(int Quantity) {


this.Quantity = Quantity;
Quantity = ((Quantity < 0) ? Quantity : 0);
}

public double getPrice() {


return price;

public void setPrice(double price) {


this.price = price;
price = ((price < 0) ? price : 0);
}

public double getInvoiceAmount() {


return Quantity * price;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package Method;

/**Create a class called Invoice that a hardware store might use to


* represent an invoice for an item sold at the store. An Invoice
* should include four pieces of information as instance variables— a
* part number (type String), a part description (type String), a
quantity
* of the item being purchased (type int) and a price per item (double).
* Your class should have a constructor that initializes the four
instance
* variables. Provide a set and a get method for each instance variable.
* In addition, provide a method named getInvoiceAmount that calculates
the
* invoice amount (i.e., multiplies the quantity by the price per item),
then
* returns the amount as a double value. If the quantity is not
positive,
* it should be set to 0. If the price per item is not positive, it
should
* be set to 0.0. Write a test application named InvoiceTest that
demonstrates
* class Invoice’s capabilities.

*
* @author asc
*/

public class InvoiceTest {


public static void main(String[]args){
Invoice myInvoice= new Invoice("Factory","candy",0,0);

System.out. printf("An Invoice of Part number:%s\n",


myInvoice.getPartnumber());

System.out. printf("An Invoice of Part Description:%s\n",


myInvoice.getPartDescription());

System.out. printf("An Invoice of Quantity:%d\n",


myInvoice.getQuantity());

System.out. printf("An Invoice of Price:%.2f\n",


myInvoice.getPrice());
System.out. printf("The total Amount:
%.2f",myInvoice.getInvoiceAmount());

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

public String getFirstnane() {


return Firstnane;
}

public void setFirstnane(String Firstnane) {


this.Firstnane = Firstnane;
}

public String getLastname() {


return Lastname;
}

public void setLastname(String Lastname) {


this.Lastname = Lastname;
}

public String getSocialsecuritynumber() {


return Socialsecuritynumber;
}

public void setSocialsecuritynumber(String Socialsecuritynumber) {


this.Socialsecuritynumber = Socialsecuritynumber;
}

public double getGrosssales() {


return grosssales;
}

public void setGrosssales(double grosssales) {

this.grosssales = grosssales;
}

public double getCommisionrate() {


return commisionrate;
}

public void setCommisionrate(double commisionrate) {

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

Invoice2 myin= new Invoice2("Grace","Malaya","0976",8000,.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"};

//... Variables to keep track of the counts.


int democraticCount = 0;
int republicanCount = 0;
int noAnswerCount = 0;
int mybusiness = 0;

//... "Infinite" loop, terminated by call to System.exit(0)


while (true) {
int response = JOptionPane.showOptionDialog(null, "M[1] =
kilo sa bulad Marot = 120\n" +" bolinaW= 100", "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:
//... 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);
}

//... Display the accumulated results so far.


JOptionPane.showMessageDialog(null, "Response = " + response
+ "\nDem = " +
democraticCount
+ "\nRep = " +
republicanCount
+ "\nOther = " +
noAnswerCount
+ "\nmy="+ mybusiness);
}

}
}

/*
* 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){

String[] choices = {"Democratic", "Republican",


"Antipartylist","My business", "Cancel"};

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

JOptionPane.showMessageDialog(null, "Response = " + response


+ "\nDem = " + democraticCount
+ "\nRep = " + republicanCount
+ "\nOther = " + noAnswerCount
+ "\nmy="+ mybusiness);
}

}
}

/*
* 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{

String name = "";


String a="";
BufferedReader jy= new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Type your name:");
try
{
name=jy.readLine();
System.out.println("Type your age:");
a=jy.readLine();
int age=Integer.parseInt(a);
System.out.println("Name:\t\t"+name+"\nAge:\t\t"+age);
}
catch(Exception e){
System.out.println("YOU ENTERED An Invalid value");
e.getMessage();

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package July21_10;

/**
*
* @author asc
*/
public class Quiz1 {

public static void main(String[]args){


int j=0,i=9,k=0;
System.out.print("Print number:"+"\n");

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());

Scanner input = new Scanner(System.in);


double deposit;

System.out.printf("Enter deposit amount for account1: ");


deposit = input.nextDouble();
System.out.printf("\nadding %.2f to account1 balance\n\n",
deposit);

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

System.out.printf("Account balance: $%.2f\n",


account1.getBalance());
System.out.printf("Account balance: $%.2f\n",
account2.getBalance());
System.out.println();

double withdraw;

System.out.printf("Enter withdrawal amount for account1: ");


withdraw = input.nextDouble();
System.out.printf("\ndeducting %.2f to account1 balance\n\n",
withdraw);

account1.setBalancedebit(withdraw);

System.out.printf("Account balance:$%.2f\n",
account1.getBalance());
System.out.printf("Account balance:$%.2f\n\n",
account2.getBalance());

System.out.printf("Enter withdrawal amount for account2: ");

withdraw = input.nextDouble();

System.out.printf("\ndeducting %.2f to account2 balance\n\n",


withdraw);

account2.setBalancedebit(withdraw);

System.out.printf("Account balance: $%.2f\n",


account1.getBalance());
System.out.printf("Account balance: $%.2f\n",
account2.getBalance());
System.out.println();
}

class Account {

private double balance;

Account(double ibalance){
if(ibalance>0.00)
balance=ibalance;
}
//the balance
public double getBalance() {
return balance;
}

//balance the balance to set

public void setBalanceCredit(double amount) {

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

String longest ="";


int i=0,j=0;
for(i=0;i<1;i++){
for(j=0;j<3;j++){
input[i]=JOptionPane.showInputDialog(null,"Please Enter first
Name");
input[i+1]=JOptionPane.showInputDialog(null,"Please Enter last
Name");
names[j][i]=input[i]+" "+input[i+1];
calculate = names[j][i].length();//Convert the name to integer
and count the letters of each input
// because you cannot procceed
to find the highest value without converting it to integer value
max=(max>calculate)?max:calculate;// finds the highest number of
letter in each input
if(longest.length()==calculate){
longest=longest+names[j][i];
}
if(max==calculate){// if the program already searched the
highest number
longest=names[j][i];//the current array will be assign to my
variable "longest" variable

} // that will tell you the longest word

System.out.println("Input "+names[j][i]);

JOptionPane.showMessageDialog(null,"The Longest name(s) is "+longest+"


with the number of "+ max +" letters");
System.out.println("The Longest name(s) is "+longest+" with the number
of "+ max +" letters");

}
}

Das könnte Ihnen auch gefallen