Friday, March 20, 2009

Cube

public class Cube{

private double width;
private double length;
private double height;
private double volume;
private double area;

public Cube(double w,double h,double l)
{
width=w;
height=h;
length=l;
}

public Cube()
{
}

private double volume()
{
return=width*length*height;
}

private double area()
{
return=width*length;
}

public void Dimension(double nLength, double nHeight, double nWidth)
{
length=nLength;
width=nWidth;
height=nHeight;
}

public void displayCube()
{
System.out.println("The volume of the Cube:"+volume());
System.out.println("the area of the Cube:"+area());
}

}

ArrayList and Iterators

Programmer:Jenelyn Dongiapon
Program Name: Array and Iterators
Date: march 20,2009

import java.util.ArrayList;
import java.util.Iterator;
import java.lang.Object;
import java.util.ListIterator;
public class iterator1

{ public static void main(String args[])
{
ArrayList list = new ArrayList( 100 );
list.add( "miat" );
list.add( "yhang" );
list.add( "peu" );
list.add( "mhine" );


System.out.print("list: ");
Iterator list2 =list.iterator();
while (list2.hasNext())
{
Iteratorelement =list2.next();
System.out.print(element + " ");
}
System.out.println();
ListIterator list3 =list.listIterator();
while (list3.hasNext())
{
Iteratorelement=list3.next();
list3.set(element + "+");
}
System.out.println("before additions: " + list.size());
list.remove(1);
{
System.out.println("after deletions: " + list.size());
System.out.println("new lists: " + list );
}
}
}



Things I learned:

1. Arraylist cannot be applied in primitive data types.

2. Arraylist is modified version of array.

3. Iterators is use to manipulate arraylist.

Assignment No4: Name Echo

Exer #4: Name Echo

Programmer: Dongiapon, Jenelyn
Program name: Name Echo
Purpose: To Learned how to program the name echo problems
Date: March 20,2009
Instructor: Dony Dongiapon

import java.util.Scanner;
import java.io.*;
public class reverse {


public static void main(String[] args) throws IOException
{
// Sentence that is going to be reversed.
System.out.print("Enter Name: ");
Scanner in=new Scanner(System.in);
String words = in.nextLine();

String reverse2="";

String Word1=words.substring(words.indexOf(" "),words.length()).toUpperCase();
String Word2=words.substring(0,words.indexOf(" "));

// Print the normal string
System.out.println("Normal : " + words);
// Print the string in reversed order
System.out.println("Reverse: " +Word2+ " "+Word1);
}

}

User-Freindly Division

Programmer: Jenelyn Dongiapon
Date Started: March 6,2009
Date Ended: March 20, 2009


import javax.swing.*;
public class UserFriendlyDivision{
public staic void main(String args[]){
char ans='y';
while(ans=='y'){

double x=Integer.parseInt(JOptionPane.showInputDialog("Enter numerator:"));//ask user input
double y=Integer.parseInt(JOptionPane.showInputDialog("Enter divisor:"));//ask user second input

double answer=x/y; //formula to get the answer

System.out.println(+ x + " / " + ); //display the input ask
System.out.println("The quotient is:"+answer); //display the answer

if(y==0)//conditional method
{
System.out.println("You cannot divide the " + x + " to 0. ");// display th econditional staement
}

String a=(JOptionPane.showInputDialog("Do you want to continue?");//ask user to continue the program
ans=a.chartAt(0);//get the input
}
}

Assignment No2: Color Cycle

Programmer Name: Dongiapon, Jenelyn E.
Program name: Color Cycle
Date: March 16, 2009
Instructor: Mr. Dony Dongiapon


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

public class ButtonDemo extends JPanel implements ActionListener {

private static boolean USE_CROSS_PLATFORM_UI = false;

int buttonLabelIndex = 0;
String buttonLabels[] = { "Green", "blue", "Gray", "Red" };
Color buttonColors[] = { Color.GREEN, Color.BLUE, Color.GRAY, Color.RED,};

JButton button;

public ButtonDemo() {
super(new BorderLayout());

button = new JButton(buttonLabels[buttonLabelIndex]);
// In the default UI look and feel you cannot easily alter the background color
// for buttons since it is designed to match the OS X UI.
if(USE_CROSS_PLATFORM_UI) {
button.setBackground(buttonColors[buttonLabelIndex]);
} else {
button.setForeground(buttonColors[buttonLabelIndex]);
}

button.addActionListener(this);


this.add(button, BorderLayout.CENTER);

this.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
}

public void actionPerformed(ActionEvent e) {
buttonLabelIndex = ++buttonLabelIndex < buttonLabels.length?buttonLabelIndex:0;

button.setText(buttonLabels[buttonLabelIndex]);
this.setBackground(buttonColors[buttonLabelIndex]);
button.setBackground(buttonColors[buttonLabelIndex]);

}


private static void run() {
if(USE_CROSS_PLATFORM_UI) {
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
}
}

JFrame frame = new JFrame("Button Demo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

JComponent contentPane = new ButtonDemo();
contentPane.setOpaque(true);

frame.setContentPane(contentPane);
frame.pack();

frame.setVisible(true);
}

public static void main(String[] args) {
run();
}

}

Assignment no1: Word Reverser

Exer #1: Word Reverser

Programmer Name: Dongiapon, Jenelyn E.
Program name: Word Reverser
Date: March 16, 2009
Instructor: Mr. Dony Dongiapon



public class Reverse
{
public static void main(String[] args)
{
// Sentence that is going to be reversed:
String words = "Reverse this word:";

String reverse2="";
String reverse = new StringBuffer(words).reverse().toString();
String Word1=words.substring(words.indexOf(" "),words.length());
reverse= new StringBuffer(Word1).reverse().toString();
String Word2=words.substring(0,words.indexOf(" "));

reverse2=new StringBuffer(Word2).reverse().toString();


// Print normal string

System.out.println("Normal : " + words);


// Print string in reversed order
System.out.println("Reverse: " +reverse2+ " "+reverse);
}
}

Sunday, February 8, 2009

Program Solution of Direct Clothing Case Study By: Jenelyn Dongiapon

//Programmer Name: Jenelyn Dongiapon
// Program Name:Direct Clothing Case Study Solution (Shirt Class)
//Date Started:February 7,2009
//Date Ended: February 8,2009

public class Shirt{

private int shirtid;
private double price;
private String color;
private String description;
private String quantityofshirt;

// class shirt constructor

public Shirt(int ID,double P,String C,String D,String QOS)
{
shirtid=ID;
price=P;
color=C;
description=D;
quantityofshirt=QOS;
}

// class shirt methods

// methods for adding shirt into stock

public void addShirtIntoStock(int newShirtid)
{
shirtid=newShirtid;
System.out.println("Add shirt into stock?");
}

// methods for removing shirt from stock

public void removeshirtfromstock (int deleteShirtid )
{
shirtid=deleteShirtid;
System.out.println("Want to removed shirt?");
}
//display info

public void displayinfo(int viewInfo)
{
shirtid=viewInfo;
System.out.println("Want to view information?");

}

}



//Programmer Name: Jenelyn Dongiapon
// Program Name:Direct Clothing Case Study Solution (Order Class)
//Date Started:February 7,2009
//Date Ended: February 8,2009

public class Order{

private int orderid;
private double totalprice;
private String status;
private String shirt;
private String FormOfPayment;

public Order (int oid,double tp,String s,String FOP,String shirt)
{
orderid=oid;
totalprice=tp;
status=s;
FormOfPayment=FOP;
}

//methods on adding shirt to order

public void addShirtToOrder (String newShirt)
{
shirt=newShirt;

}

//removing shirt
public void removedShirt(String deleteShirt)
{
shirt=deleteShirt;
}

//submitting an order
public void submitAnOrder(String passOrder)
{
status=passOrder;
}

}

//Programmer Name: Jenelyn Dongiapon
// Program Name:Direct Clothing Case Study Solution (Customer Class)
//Date Started:February 7,2009
//Date Ended: February 8,2009

public class Customer{

private int customerid;
private String name;
private String address;
private double PhoneNum;
private String emailAddress;

//constuctors for class Customer

public Customer(int cid,String n,String a,double PNum,String eAdd)
{
customerid=cid;
name=n;
address=a;
PhoneNum=PNum;
emailAddress=eAdd;

//methods for placing order

public void placeAnOrder(String newOrder)
{
name=newOrder;
}

//cancel order

public void cancelOrder(String newOrder)
{
customerid=newOrder;
}
}
}



//Programmer Name: Jenelyn Dongiapon
// Program Name:Direct Clothing Case Study Solution (Catalog Class)
//Date Started:February 7,2009
//Date Ended: February 8,2009

public class Catalog{

private String shirts;

public void addShirt(String newShirt)
{
shirts=newShirt;
}

public void removedShirt(String deleteShirt)
{
shirts=deleteShirt;
}
}

//Programmer Name: Jenelyn Dongiapon
// Program Name:Direct Clothing Case Study Solution (FormOfPayment Class)
//Date Started:February 7,2009
//Date Ended: February 8,2009

public class FormOfPayment{

private String checkNum;
private String Cardnum;
private String ExpiryDate;

//constructors

public FormOfPayment (String cN,String C,String ED)
{
checkNum=cN;
Cardnum=C;
ExpiryDate=ED;
}

//method on verifying Credit card
public void verifyCreditCard(String newCardNum)
{
Cardnum=newCardNum;
}
//method on checking payment
public void verifyCheckPayment(String newCheck)
{
checkNum=newCheck;
}



}
_________________________________________________________

//Programmer Name: Jenelyn Dongiapon
// Program Name:Direct Clothing Case Study Solution (DirectClothingTester Class)
//Date Started:February 7,2009
//Date Ended: February 8,2009

import java.util.Scanner;

public class DirectClothingTester{

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


}