Exer 1
//programmer: junnaliza Arreglado
//programme name: hello object program
// date started: march 17, 2009
// date ended: march 17, 2009
//purpose: manipulate String..
import javax.swing.*;
public class wordReverse {
public static void main(String[] args) {
String input; // Used for the input string.
String reversed; // Reversed form or the input string.
input = JOptionPane.showInputDialog(null, "Enter a string"); // get the string from the user
reversed = "";
for (int i=0; i reversed = input.substring(i, i+1) + reversed;
}
JOptionPane.showMessageDialog(null, "Reversed:\n" + reversed); //the output of the reveresed string from the user
}
}
sample output:
enter a String:
Go to the main menu
unem niam eht ot oG
__________________________________________________________________
exer4
//programmer: junnaliza Arreglado
//programme name: hello object program
// date started: march 17, 2009
// date ended: march 17, 2009
//purpose: manipulate String.
import java.util.*;
import java.io.*;
public class nameEcho {
public static void main(String[] args) throws IOException
{
String yourName;
String firstName;
String lastname;
System.out.println("Enter your name:");
Scanner input = new Scanner(System.in);
yourName = input.nextLine();
firstName = yourName.substring(0,yourName.indexOf(" "));
lastname= yourName.substring(yourName.indexOf(" "),yourName.length()).toUpperCase();
System.out.println();
System.out.print(firstName);
System.out.print(lastname);
System.out.println();
}
}
sample output:
Enter your name:
junnaliza arreglado
junnaliza ARREGLADO
Process completed.
__________________________________________________________________
Exer 5
//programmer: junnaliza Arreglado
//programme name: hello object program
// date started: march 17, 2009
// date ended: march 17, 2009
//purpose: manipulate inputs..
import java.util.Scanner;
public class helloObject
{
public static void main(String[] args)
{
String greetings; // Used for the input string.
Scanner input=new Scanner(System.in);
System.out.println("Enter Greeting:");
greetings=input.nextLine();
System.out.println();
System.out.println(greetings);
}
}
sample output:
Enter Greeting:
hello mars!
hello mars!
Process completed
Wednesday, March 18, 2009
Saturday, March 7, 2009
User-Friendly Division by:Junnaliza Arreglado
//Programmer: Junnaliza Arreglado
//Date Started: March 6,2009
//Date Finished:March 7,2009
//Programme Name: User-Friendly Division
//Purpose: To use Exception handling in the Programme
import java.util.*; //importing the java util package that holds the InputMismatch and the Scanner class
public class jhong
{
public static int quo(int num, int div)throws ArithmeticException
{
return num/div; //holds the aithmetic exeption of the try block
}
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
int num=0;
int div=0;
String quit="exit";
char x=quit.charAt(0); //String class initialization
while(x!='q' || x!='Q') //to initialize the quit of the program
{
if(x!='q' || x != 'Q') //to initialize the quit of the program
{
try //starting the try block
{
System.out.println("Enter the numerator:");
if((input.next().charAt(0)=='q')||(input.next().charAt(0)=='Q'))
{
x=input.next().charAt(0);
}
else
{
num=input.nextInt();
System.out.println("Enter the divisor:");
div=input.nextInt();
int finalQ=quo(num,div);
System.out.println(num+"/"+div+" is "+finalQ);
}
} //end of the try block
catch(ArithmeticException wrongDiv) //wrong denominator-the 0
{
System.err.println("You can't divide "+num+" by "+div); //error message
}
catch(InputMismatchException stringNum) //catch for wrong input of the numerator
{
System.err.println("You entered bad data.\nPlease try again."); //error message
}
}
else
{
x='q'; //quiting
}
}
}
}
//Date Started: March 6,2009
//Date Finished:March 7,2009
//Programme Name: User-Friendly Division
//Purpose: To use Exception handling in the Programme
import java.util.*; //importing the java util package that holds the InputMismatch and the Scanner class
public class jhong
{
public static int quo(int num, int div)throws ArithmeticException
{
return num/div; //holds the aithmetic exeption of the try block
}
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
int num=0;
int div=0;
String quit="exit";
char x=quit.charAt(0); //String class initialization
while(x!='q' || x!='Q') //to initialize the quit of the program
{
if(x!='q' || x != 'Q') //to initialize the quit of the program
{
try //starting the try block
{
System.out.println("Enter the numerator:");
if((input.next().charAt(0)=='q')||(input.next().charAt(0)=='Q'))
{
x=input.next().charAt(0);
}
else
{
num=input.nextInt();
System.out.println("Enter the divisor:");
div=input.nextInt();
int finalQ=quo(num,div);
System.out.println(num+"/"+div+" is "+finalQ);
}
} //end of the try block
catch(ArithmeticException wrongDiv) //wrong denominator-the 0
{
System.err.println("You can't divide "+num+" by "+div); //error message
}
catch(InputMismatchException stringNum) //catch for wrong input of the numerator
{
System.err.println("You entered bad data.\nPlease try again."); //error message
}
}
else
{
x='q'; //quiting
}
}
}
}
Monday, March 2, 2009
ArrayList and Iterators
// programmer name: Arreglado, Junnaliza
// date started: march 2, 2009
// date finished: march2, 2009
// prgramme name: making array ang traversing through the use of iterators
import java.util.ListIterator;
import java.util.ArrayList;
import java.util.Iterator;
public class Ar_iter
{
public static void main(String args[])throws Exception
{
ArrayList list = new ArrayList(); //importing an arraylist class within the util package and naming an object list
list.add("jhong");
list.add("mhing");
list.add("yhang"); //initialization of the arraylist
list.add("jhen");
list.add("lhyn");
list.add("phau");
System.out.print("the contents of the arraylist list are: ");
Iterator iterator1 = list.iterator(); //the class iterator making an object iterator1
while (iterator1.hasNext())
{ //iterator method hasNext()-used to traverse next values or elements
String values = iterator1.next();
System.out.print(values + " "); //used to print out the values of the array list using an iterator
}
System.out.println();
ListIterator listanditerate = list.ListIterator(); //making an object from the listiterator class of java naming it as listanditerate
while (listanditerate.hasNext())
{
String values = listanditerate.next(); //traversing while the list has still an element-next element
}
System.out.print("making a backward list of the values within the arraylist: ");
while (listanditerate.hasPrevious())
{
String values = listanditerate.previous(); //traversing the vales while it has a previous element
System.out.print(values " "); //printing the values of the list while it has a previous element
}
}
}
note: The code is just modified. It came from the web.
Date: March 2, 2009
Things that i learned:
// date started: march 2, 2009
// date finished: march2, 2009
// prgramme name: making array ang traversing through the use of iterators
import java.util.ListIterator;
import java.util.ArrayList;
import java.util.Iterator;
public class Ar_iter
{
public static void main(String args[])throws Exception
{
ArrayList list = new ArrayList(); //importing an arraylist class within the util package and naming an object list
list.add("jhong");
list.add("mhing");
list.add("yhang"); //initialization of the arraylist
list.add("jhen");
list.add("lhyn");
list.add("phau");
System.out.print("the contents of the arraylist list are: ");
Iterator iterator1 = list.iterator(); //the class iterator making an object iterator1
while (iterator1.hasNext())
{ //iterator method hasNext()-used to traverse next values or elements
String values = iterator1.next();
System.out.print(values + " "); //used to print out the values of the array list using an iterator
}
System.out.println();
ListIterator listanditerate = list.ListIterator(); //making an object from the listiterator class of java naming it as listanditerate
while (listanditerate.hasNext())
{
String values = listanditerate.next(); //traversing while the list has still an element-next element
}
System.out.print("making a backward list of the values within the arraylist: ");
while (listanditerate.hasPrevious())
{
String values = listanditerate.previous(); //traversing the vales while it has a previous element
System.out.print(values " "); //printing the values of the list while it has a previous element
}
}
}
note: The code is just modified. It came from the web.
Date: March 2, 2009
Things that i learned:
- To create an list of array, we should import the UTIL package of the java technology
- The Arraylist package has several useful method
- One class that is used to manipulate the arraylist is the iterators.
- To use the iterators we need to import also the iterrator class of the util package.
- Iterators also has useful methods (some are used in the code)
- arraylist and iterators is very useful in making codes or even in the real world application.
Sunday, February 8, 2009
Program Solution for Direct Clothing by: Arreglado, Junnaliza
/*programmer: Junnaliza Arreglado
*programme name: Direct Clothing Case Study(customer class)
*date started: february 7, 2009
*date ended: february 8, 2009
*programme purpose: to be able to make sulotion for the direct clothing problem*/
public class Customer
{
//customer variable declaration...
private int customerid;
private String name;
private String address;
private int phonenumber;
private String emailaddress;
//customer constructor declaration...
public Customer()
{
}
public Customer(int c, String n, String a, int p, String e)
{
customerid=c;
name=n;
address=a;
phonenumber=p;
emailaddress=e;
}
//customer method declarations...
public void customergreetings(String newname)
{
name=newname;
System.out.println("Hello "+name+" Welcome to DIRECT CLOTHING");
}
public void customerprofile(String newname, int newid, String newaddress, int newphonenumber, String newemailaddress)
{
name=newname;
address=newaddress;
customerid=newid;
phonenumber=newphonenumber;
emailaddress=newemailaddress;
System.out.println("customer's Profile");
System.out.println("Name: "+name+ "\nCustomer ID: "+customerid+"\nAddress:"+address+"\nPhone Number: "+phonenumber+"\nE-mail address: "+emailaddress);
}
}
________________________________________________________________________
/*programmer: Junnaliza Arreglado
*programme name: Direct Clothing Case Study(catalog class)
*date started: february 7, 2009
*date ended: february 8, 2009
*programme purpose: to be able to make sulotion for the direct clothing problem*/
public class Catalog
{
//variable declaration
private int shirtid;
private double price;
private String color;
private String description;
private int quantityinstock;
//costructor declaration
public Catalog()
{
}
public Catalog(int s, double p, String c, String d, int q)
{
shirtid=s;
price=p;
color=c;
description=d;
quantityinstock=q;
}
//method declaration
public void addashirt(int newshirtid, double newprice, String newcolor, String newdescription, int newquantityinstock)
{
shirtid=newshirtid;
price=newprice;
color=newcolor;
description=newdescription;
quantityinstock=newquantityinstock;
System.out.println("Shirt number: "+shirtid+ "\nPrice: "+price+"\nColor: "+color+"\nDescription: "+description+"\nQuantity in Stock: "+quantityinstock);
System.out.println("The information above has been succesfully added");
}
public void removeashirt(int newshirtid)
{
shirtid=newshirtid;
System.out.println("The Shirt number"+shirtid+"is succesfully remove from the order");
}
}
________________________________________________________________________
/*programmer: Junnaliza Arreglado
*programme name: Direct Clothing Case Study(formofpayment class)
*date started: february 7, 2009
*date ended: february 8, 2009
*programme purpose: to be able to make sulotion for the direct clothing problem*/
public class Formofpayment
{
//variable declaration...
private int checknumber;
private int creditcardnumber;
private String expirationdate;
// constructor declaration..
public Formofpayment()
{
}
public Formofpayment(int c, int cc, String e)
{
checknumber=c;
creditcardnumber=cc;
expirationdate=e;
}
public void verifycreditcard()
{
System.out.println("Your credit card is OK, we will less the amount of this transaction to your credit card");
}
public void verifycheckpayment()
{
System.out.println("OK! You must send the Check in the company before we are going to Send to you your orders!");
}
}
/*programmer: Junnaliza Arreglado
*programme name: Direct Clothing Case Study(shirt class)
*date started: february 7, 2009
*date ended: february 8, 2009
*programme purpose: to be able to make sulotion for the direct clothing problem*/
public class Shirt
{
//variable declaration
private int shirtid;
private double price;
private String color;
private String description;
private int quantityinstock;
//constructor declaration
public Shirt()
{
}
public Shirt(int s, double p, String c, String d, int q)
{
shirtid=s;
price=p;
color=c;
description=d;
quantityinstock=q;
}
//method declaration
public void addshirttoorder(int newshirtid)
{
shirtid=newshirtid;
System.out.println("You have just added Shirt number "+shirtid+" to your orders");
}
public void removeshirttoorder(int newshirtid)
{
shirtid=newshirtid;
System.out.println("Shirt number " +shirtid+ "is successfully remove from the orders");
}
public void displayshirtinformation()
{
System.out.println("Shirt number: "+shirtid+ "\nPrice: "+price+"\nColor: "+color+"\nDescription: "+description+"\nQuantity in Stock: "+quantityinstock);
}
public void addstock(int newshirtid, double newprice, String newcolor, String newdescription, int newquantityinstock)
{
shirtid=newshirtid;
price=newprice;
color=newcolor;
description=newdescription;
quantityinstock=newquantityinstock;
System.out.println("Shirt number: "+shirtid+ "\nPrice: "+price+"\nColor: "+color+"\nDescription: "+description+"\nQuantity in Stock: "+quantityinstock);
System.out.println("The information above has been succesfully added");
}
public void removestock(int newshirtid)
{
shirtid=newshirtid;
System.out.println("The Shirt number "+shirtid+" is succesfully remove from the stock");
}
}
/*programmer: Junnaliza Arreglado
*programme name: Direct Clothing Case Study(Order class)
*date started: february 7, 2009
*date ended: february 8, 2009
*programme purpose: to be able to make sulotion for the direct clothing problem*/
public class Order
{
//variable declaration
private int orderid;
private double totalprice;
private String status;
//constuctor declaration
public Order()
{
}
public Order(int o, double t, String s)
{
orderid=o;
totalprice=t;
status=s;
}
//method declaration..
public void placeorder(int newo, double newt, String news)
{
orderid=newo;
totalprice=newt;
status=news;
}
public void removeorder(int o)
{
orderid=o;
System.out.println("Order number "+orderid+" is cancelled succesfully");
}
public void submitorder()
{
System.out.println("You have succesfully submitted the order number "+orderid);
}
public void putorderonhold()
{
System.out.println("The order is still to be proccess by the company.\nJust wait for any reply.");
}
}
/*programmer: Junnaliza Arreglado
*programme name: Direct Clothing Case Study(DirectClotingTester class)
*date started: february 7, 2009
*date ended: february 8, 2009
*programme purpose: to be able to make sulotion for the direct clothing problem*/
import java.util.*;
public class DirectClothingTester
{
public static void main(String args[])
{
String name;
int customerid;
String address;
int phonenumber;
String emailaddress;
int q1;
int q2;
int q3;
int q4;
int cq1;
int cq2;
int shirtid;
double price;
String color;
String description;
int quantity;
int payment;
int ordernumber;
System.out.println("WELCOME TO DIRECT CLOTHING CASE STUDY");
System.out.println("\n");
System.out.println("\n The Company's Side");
System.out.println("\n");
System.out.println("The Shirt in the direct clothing that is currently available is/are:");
System.out.println("\n");
Shirt shirt1=new Shirt(1,258.00,"white and black","Very comfortable to wear",15);
shirt1.displayshirtinformation();
System.out.println("\n");
Scanner z=new Scanner(System.in);
System.out.println("Would you like to add another in the stock?");
System.out.println("enter 1 if yes, 0 if no!");
cq1=z.nextInt();
if(cq1==1)
{
Scanner y=new Scanner(System.in);
System.out.println("Enter the following information:");
System.out.println("Shirt ID:");
shirtid=y.nextInt();
Scanner x=new Scanner(System.in);
System.out.println("Price:");
price=x.nextDouble();
Scanner w=new Scanner(System.in);
System.out.println("Color:");
color=w.nextLine();
Scanner v=new Scanner(System.in);
System.out.println("Description:");
description=v.nextLine();
Scanner u=new Scanner(System.in);
System.out.println("Quantity:");
quantity=u.nextInt();
Shirt shirt2=new Shirt();
shirt2.addstock(shirtid, price, color, description, quantity);
System.out.println("\n");
System.out.println("The Shirt in the direct clothing that is currently available is/are:");
System.out.println("\n");
shirt1.displayshirtinformation();
System.out.println("\n");
shirt2.displayshirtinformation();
}
else
{
System.out.println("OK");
}
System.out.println("\n");
Scanner t=new Scanner(System.in);
System.out.println("Would you like to to remove a stock?");
System.out.println("enter 1 if yes, 0 if no!");
cq2=t.nextInt();
if(cq2==1)
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the Shirt ID number:");
System.out.println("note:just enter shirt id number 1 because it is the only available");
shirtid=s.nextInt();
shirt1.removestock(shirtid);
}
else
{
System.out.println("OK");
}
System.out.println("\n");
System.out.println("WELCOME TO DIRECT CLOTHING CASE STUDY");
System.out.println("\n");
System.out.println("\n The Customer's Side");
System.out.println("\n");
Scanner a=new Scanner(System.in);
System.out.println("Enter your id number:");
customerid=a.nextInt();
Scanner b=new Scanner(System.in);
System.out.println("Enter your name:");
name=b.nextLine();
Scanner c=new Scanner(System.in);
System.out.println("Enter your Address:");
address=c.nextLine();
Scanner d=new Scanner(System.in);
System.out.println("Enter your phone number:");
phonenumber=d.nextInt();
Scanner e=new Scanner(System.in);
System.out.println("Enter your E-mail address:");
emailaddress=e.nextLine();
System.out.println("\n");
Customer customer1=new Customer();
customer1.customergreetings(name);
System.out.println("\n");
customer1.customerprofile(name,customerid,address,phonenumber,emailaddress);
System.out.println("\n");
Scanner f=new Scanner(System.in);
System.out.println("Would you like to make an order?");
System.out.println("enter 1 if yes, 0 if no!");
q1=f.nextInt();
if(q1==1)
{
System.out.println("\n");
System.out.println("Here is the catalog");
System.out.println("\n");
shirt1.displayshirtinformation();
System.out.println("\n");
Scanner g=new Scanner(System.in);
System.out.println("What item you would like to order?");
System.out.println("note:Just enter the shirt id of the item you would like to order");
System.out.println("note:just enter the items available in the catalog");
shirtid=g.nextInt();
System.out.println("\n");
shirt1.addshirttoorder(shirtid);
Scanner h=new Scanner(System.in);
System.out.println("\n");
System.out.println("What type of payment that this transaction will cover?");
System.out.println("Press 1 for check 0 for credit?");
payment=h.nextInt();
if(payment==1)
{
Formofpayment formofpayment1=new Formofpayment();
formofpayment1.verifycheckpayment();
}
else
{
Formofpayment formofpayment1=new Formofpayment();
formofpayment1.verifycreditcard();
}
System.out.println("\n");
Scanner i=new Scanner(System.in);
System.out.println("Would you like to submit your order now?");
System.out.println("enter 1 if yes, 0 if no!");
q2=i.nextInt();
if(q2==1)
{
System.out.println("\n");
Order order1=new Order(1,258,"OK");
order1.submitorder();
order1.putorderonhold();
Scanner j=new Scanner(System.in);
System.out.println("Would you like to remove a shirt from your orders?");
System.out.println("enter 1 if yes, 0 if no!");
q3=j.nextInt();
if(q3==1)
{
System.out.println("\n");
Scanner k=new Scanner(System.in);
System.out.println("Enter the Shirt number that you would like to remove:");
shirtid=k.nextInt();
shirt1.removeshirttoorder(shirtid);
}
else
{
System.out.println("OK!");
}
}
else
{
System.out.println("OK!");
Scanner j=new Scanner(System.in);
System.out.println("Would you like to remove a shirt from your orders?");
System.out.println("enter 1 if yes, 0 if no!");
q3=j.nextInt();
if(q3==1)
{
System.out.println("\n");
Scanner k=new Scanner(System.in);
System.out.println("Enter the Shirt number that you would like to remove:");
shirtid=k.nextInt();
shirt1.removeshirttoorder(shirtid);
}
else
{
System.out.println("OK!");
}
}
}
else
{
System.out.println("OK");
}
Scanner l=new Scanner(System.in);
System.out.println("Would you like to cancel an orders?");
System.out.println("enter 1 if yes, 0 if no!");
q4=l.nextInt();
if(q4==1)
{
System.out.println("\n");
Scanner m=new Scanner(System.in);
System.out.println("Enter the order number that you would like to cancel:");
ordernumber=m.nextInt();
Order order1=new Order(ordernumber,258,"OK");
order1.removeorder(ordernumber);
}
else
{
System.out.println("OK!");
}
}
}
*programme name: Direct Clothing Case Study(customer class)
*date started: february 7, 2009
*date ended: february 8, 2009
*programme purpose: to be able to make sulotion for the direct clothing problem*/
public class Customer
{
//customer variable declaration...
private int customerid;
private String name;
private String address;
private int phonenumber;
private String emailaddress;
//customer constructor declaration...
public Customer()
{
}
public Customer(int c, String n, String a, int p, String e)
{
customerid=c;
name=n;
address=a;
phonenumber=p;
emailaddress=e;
}
//customer method declarations...
public void customergreetings(String newname)
{
name=newname;
System.out.println("Hello "+name+" Welcome to DIRECT CLOTHING");
}
public void customerprofile(String newname, int newid, String newaddress, int newphonenumber, String newemailaddress)
{
name=newname;
address=newaddress;
customerid=newid;
phonenumber=newphonenumber;
emailaddress=newemailaddress;
System.out.println("customer's Profile");
System.out.println("Name: "+name+ "\nCustomer ID: "+customerid+"\nAddress:"+address+"\nPhone Number: "+phonenumber+"\nE-mail address: "+emailaddress);
}
}
________________________________________________________________________
/*programmer: Junnaliza Arreglado
*programme name: Direct Clothing Case Study(catalog class)
*date started: february 7, 2009
*date ended: february 8, 2009
*programme purpose: to be able to make sulotion for the direct clothing problem*/
public class Catalog
{
//variable declaration
private int shirtid;
private double price;
private String color;
private String description;
private int quantityinstock;
//costructor declaration
public Catalog()
{
}
public Catalog(int s, double p, String c, String d, int q)
{
shirtid=s;
price=p;
color=c;
description=d;
quantityinstock=q;
}
//method declaration
public void addashirt(int newshirtid, double newprice, String newcolor, String newdescription, int newquantityinstock)
{
shirtid=newshirtid;
price=newprice;
color=newcolor;
description=newdescription;
quantityinstock=newquantityinstock;
System.out.println("Shirt number: "+shirtid+ "\nPrice: "+price+"\nColor: "+color+"\nDescription: "+description+"\nQuantity in Stock: "+quantityinstock);
System.out.println("The information above has been succesfully added");
}
public void removeashirt(int newshirtid)
{
shirtid=newshirtid;
System.out.println("The Shirt number"+shirtid+"is succesfully remove from the order");
}
}
________________________________________________________________________
/*programmer: Junnaliza Arreglado
*programme name: Direct Clothing Case Study(formofpayment class)
*date started: february 7, 2009
*date ended: february 8, 2009
*programme purpose: to be able to make sulotion for the direct clothing problem*/
public class Formofpayment
{
//variable declaration...
private int checknumber;
private int creditcardnumber;
private String expirationdate;
// constructor declaration..
public Formofpayment()
{
}
public Formofpayment(int c, int cc, String e)
{
checknumber=c;
creditcardnumber=cc;
expirationdate=e;
}
public void verifycreditcard()
{
System.out.println("Your credit card is OK, we will less the amount of this transaction to your credit card");
}
public void verifycheckpayment()
{
System.out.println("OK! You must send the Check in the company before we are going to Send to you your orders!");
}
}
/*programmer: Junnaliza Arreglado
*programme name: Direct Clothing Case Study(shirt class)
*date started: february 7, 2009
*date ended: february 8, 2009
*programme purpose: to be able to make sulotion for the direct clothing problem*/
public class Shirt
{
//variable declaration
private int shirtid;
private double price;
private String color;
private String description;
private int quantityinstock;
//constructor declaration
public Shirt()
{
}
public Shirt(int s, double p, String c, String d, int q)
{
shirtid=s;
price=p;
color=c;
description=d;
quantityinstock=q;
}
//method declaration
public void addshirttoorder(int newshirtid)
{
shirtid=newshirtid;
System.out.println("You have just added Shirt number "+shirtid+" to your orders");
}
public void removeshirttoorder(int newshirtid)
{
shirtid=newshirtid;
System.out.println("Shirt number " +shirtid+ "is successfully remove from the orders");
}
public void displayshirtinformation()
{
System.out.println("Shirt number: "+shirtid+ "\nPrice: "+price+"\nColor: "+color+"\nDescription: "+description+"\nQuantity in Stock: "+quantityinstock);
}
public void addstock(int newshirtid, double newprice, String newcolor, String newdescription, int newquantityinstock)
{
shirtid=newshirtid;
price=newprice;
color=newcolor;
description=newdescription;
quantityinstock=newquantityinstock;
System.out.println("Shirt number: "+shirtid+ "\nPrice: "+price+"\nColor: "+color+"\nDescription: "+description+"\nQuantity in Stock: "+quantityinstock);
System.out.println("The information above has been succesfully added");
}
public void removestock(int newshirtid)
{
shirtid=newshirtid;
System.out.println("The Shirt number "+shirtid+" is succesfully remove from the stock");
}
}
/*programmer: Junnaliza Arreglado
*programme name: Direct Clothing Case Study(Order class)
*date started: february 7, 2009
*date ended: february 8, 2009
*programme purpose: to be able to make sulotion for the direct clothing problem*/
public class Order
{
//variable declaration
private int orderid;
private double totalprice;
private String status;
//constuctor declaration
public Order()
{
}
public Order(int o, double t, String s)
{
orderid=o;
totalprice=t;
status=s;
}
//method declaration..
public void placeorder(int newo, double newt, String news)
{
orderid=newo;
totalprice=newt;
status=news;
}
public void removeorder(int o)
{
orderid=o;
System.out.println("Order number "+orderid+" is cancelled succesfully");
}
public void submitorder()
{
System.out.println("You have succesfully submitted the order number "+orderid);
}
public void putorderonhold()
{
System.out.println("The order is still to be proccess by the company.\nJust wait for any reply.");
}
}
/*programmer: Junnaliza Arreglado
*programme name: Direct Clothing Case Study(DirectClotingTester class)
*date started: february 7, 2009
*date ended: february 8, 2009
*programme purpose: to be able to make sulotion for the direct clothing problem*/
import java.util.*;
public class DirectClothingTester
{
public static void main(String args[])
{
String name;
int customerid;
String address;
int phonenumber;
String emailaddress;
int q1;
int q2;
int q3;
int q4;
int cq1;
int cq2;
int shirtid;
double price;
String color;
String description;
int quantity;
int payment;
int ordernumber;
System.out.println("WELCOME TO DIRECT CLOTHING CASE STUDY");
System.out.println("\n");
System.out.println("\n The Company's Side");
System.out.println("\n");
System.out.println("The Shirt in the direct clothing that is currently available is/are:");
System.out.println("\n");
Shirt shirt1=new Shirt(1,258.00,"white and black","Very comfortable to wear",15);
shirt1.displayshirtinformation();
System.out.println("\n");
Scanner z=new Scanner(System.in);
System.out.println("Would you like to add another in the stock?");
System.out.println("enter 1 if yes, 0 if no!");
cq1=z.nextInt();
if(cq1==1)
{
Scanner y=new Scanner(System.in);
System.out.println("Enter the following information:");
System.out.println("Shirt ID:");
shirtid=y.nextInt();
Scanner x=new Scanner(System.in);
System.out.println("Price:");
price=x.nextDouble();
Scanner w=new Scanner(System.in);
System.out.println("Color:");
color=w.nextLine();
Scanner v=new Scanner(System.in);
System.out.println("Description:");
description=v.nextLine();
Scanner u=new Scanner(System.in);
System.out.println("Quantity:");
quantity=u.nextInt();
Shirt shirt2=new Shirt();
shirt2.addstock(shirtid, price, color, description, quantity);
System.out.println("\n");
System.out.println("The Shirt in the direct clothing that is currently available is/are:");
System.out.println("\n");
shirt1.displayshirtinformation();
System.out.println("\n");
shirt2.displayshirtinformation();
}
else
{
System.out.println("OK");
}
System.out.println("\n");
Scanner t=new Scanner(System.in);
System.out.println("Would you like to to remove a stock?");
System.out.println("enter 1 if yes, 0 if no!");
cq2=t.nextInt();
if(cq2==1)
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the Shirt ID number:");
System.out.println("note:just enter shirt id number 1 because it is the only available");
shirtid=s.nextInt();
shirt1.removestock(shirtid);
}
else
{
System.out.println("OK");
}
System.out.println("\n");
System.out.println("WELCOME TO DIRECT CLOTHING CASE STUDY");
System.out.println("\n");
System.out.println("\n The Customer's Side");
System.out.println("\n");
Scanner a=new Scanner(System.in);
System.out.println("Enter your id number:");
customerid=a.nextInt();
Scanner b=new Scanner(System.in);
System.out.println("Enter your name:");
name=b.nextLine();
Scanner c=new Scanner(System.in);
System.out.println("Enter your Address:");
address=c.nextLine();
Scanner d=new Scanner(System.in);
System.out.println("Enter your phone number:");
phonenumber=d.nextInt();
Scanner e=new Scanner(System.in);
System.out.println("Enter your E-mail address:");
emailaddress=e.nextLine();
System.out.println("\n");
Customer customer1=new Customer();
customer1.customergreetings(name);
System.out.println("\n");
customer1.customerprofile(name,customerid,address,phonenumber,emailaddress);
System.out.println("\n");
Scanner f=new Scanner(System.in);
System.out.println("Would you like to make an order?");
System.out.println("enter 1 if yes, 0 if no!");
q1=f.nextInt();
if(q1==1)
{
System.out.println("\n");
System.out.println("Here is the catalog");
System.out.println("\n");
shirt1.displayshirtinformation();
System.out.println("\n");
Scanner g=new Scanner(System.in);
System.out.println("What item you would like to order?");
System.out.println("note:Just enter the shirt id of the item you would like to order");
System.out.println("note:just enter the items available in the catalog");
shirtid=g.nextInt();
System.out.println("\n");
shirt1.addshirttoorder(shirtid);
Scanner h=new Scanner(System.in);
System.out.println("\n");
System.out.println("What type of payment that this transaction will cover?");
System.out.println("Press 1 for check 0 for credit?");
payment=h.nextInt();
if(payment==1)
{
Formofpayment formofpayment1=new Formofpayment();
formofpayment1.verifycheckpayment();
}
else
{
Formofpayment formofpayment1=new Formofpayment();
formofpayment1.verifycreditcard();
}
System.out.println("\n");
Scanner i=new Scanner(System.in);
System.out.println("Would you like to submit your order now?");
System.out.println("enter 1 if yes, 0 if no!");
q2=i.nextInt();
if(q2==1)
{
System.out.println("\n");
Order order1=new Order(1,258,"OK");
order1.submitorder();
order1.putorderonhold();
Scanner j=new Scanner(System.in);
System.out.println("Would you like to remove a shirt from your orders?");
System.out.println("enter 1 if yes, 0 if no!");
q3=j.nextInt();
if(q3==1)
{
System.out.println("\n");
Scanner k=new Scanner(System.in);
System.out.println("Enter the Shirt number that you would like to remove:");
shirtid=k.nextInt();
shirt1.removeshirttoorder(shirtid);
}
else
{
System.out.println("OK!");
}
}
else
{
System.out.println("OK!");
Scanner j=new Scanner(System.in);
System.out.println("Would you like to remove a shirt from your orders?");
System.out.println("enter 1 if yes, 0 if no!");
q3=j.nextInt();
if(q3==1)
{
System.out.println("\n");
Scanner k=new Scanner(System.in);
System.out.println("Enter the Shirt number that you would like to remove:");
shirtid=k.nextInt();
shirt1.removeshirttoorder(shirtid);
}
else
{
System.out.println("OK!");
}
}
}
else
{
System.out.println("OK");
}
Scanner l=new Scanner(System.in);
System.out.println("Would you like to cancel an orders?");
System.out.println("enter 1 if yes, 0 if no!");
q4=l.nextInt();
if(q4==1)
{
System.out.println("\n");
Scanner m=new Scanner(System.in);
System.out.println("Enter the order number that you would like to cancel:");
ordernumber=m.nextInt();
Order order1=new Order(ordernumber,258,"OK");
order1.removeorder(ordernumber);
}
else
{
System.out.println("OK!");
}
}
}
Wednesday, February 4, 2009
Cube Programme
// programmer:Junnaliza L.Arreglado
// date started: February 4, 2009
// date ended: February 4, 2009
// Programme name: Cube
// programme purpose: To create classes using Visibility Modifiers
public class Cube{
// variable declarations
private double width;
private double length;
private double height;
private double volume;
private double area;
// constructor declaration
public Cube(double w, double h, double l)
{
width=w;
height=h;
length=l;
}
public Cube()
{
}
// method declarationS
private double volume()
{
return (width*length*height);
}
private double area()
{
return (width*length);
}
public void setDimension(double newLength, double newHeight, double newWidth)
{
length=newLength;
width=newWidth;
height=newHeight;
}
public void displayCube()
{
System.out.println("Cube Dimensions:");
System.out.println("The VOLUME of the Cube is" +volume());
System.out.println("The AREA of the Cube is" +area());
}
}
___________________________________________________________________
// programmer:Junnaliza L.Arreglado
// date started: February 4, 2009
// date ended: February 4, 2009
// Programme name: Cube
// programme purpose: To create classes using Visibility Modifiers
import java.util.Scanner;
class CubeTester1
{
public static void main(String args[])
{
double l;
double w;
double h;
System.out.println("\n\n");
System.out.println("The Cube object with a parameter");
Cube firstCube=new Cube(2,2,2);;
firstCube.displayCube();
System.out.println("The Cube object without a parameter");
System.out.println("\n\n");
Scanner a=new Scanner(System.in);
System.out.println("enter the value of the length:");
l=a.nextDouble();
Scanner b=new Scanner(System.in);
System.out.println("enter the value of the height:");
w=b.nextDouble();
Scanner c=new Scanner(System.in);
System.out.println("enter the value of the width:");
h=c.nextDouble();
System.out.println("The Cube object without a parameter");
System.out.println("\n\n");
Cube secondCube=new Cube();
secondCube.setDimension(l,w,h);
secondCube.displayCube();
}
}
// date started: February 4, 2009
// date ended: February 4, 2009
// Programme name: Cube
// programme purpose: To create classes using Visibility Modifiers
public class Cube{
// variable declarations
private double width;
private double length;
private double height;
private double volume;
private double area;
// constructor declaration
public Cube(double w, double h, double l)
{
width=w;
height=h;
length=l;
}
public Cube()
{
}
// method declarationS
private double volume()
{
return (width*length*height);
}
private double area()
{
return (width*length);
}
public void setDimension(double newLength, double newHeight, double newWidth)
{
length=newLength;
width=newWidth;
height=newHeight;
}
public void displayCube()
{
System.out.println("Cube Dimensions:");
System.out.println("The VOLUME of the Cube is" +volume());
System.out.println("The AREA of the Cube is" +area());
}
}
___________________________________________________________________
// programmer:Junnaliza L.Arreglado
// date started: February 4, 2009
// date ended: February 4, 2009
// Programme name: Cube
// programme purpose: To create classes using Visibility Modifiers
import java.util.Scanner;
class CubeTester1
{
public static void main(String args[])
{
double l;
double w;
double h;
System.out.println("\n\n");
System.out.println("The Cube object with a parameter");
Cube firstCube=new Cube(2,2,2);;
firstCube.displayCube();
System.out.println("The Cube object without a parameter");
System.out.println("\n\n");
Scanner a=new Scanner(System.in);
System.out.println("enter the value of the length:");
l=a.nextDouble();
Scanner b=new Scanner(System.in);
System.out.println("enter the value of the height:");
w=b.nextDouble();
Scanner c=new Scanner(System.in);
System.out.println("enter the value of the width:");
h=c.nextDouble();
System.out.println("The Cube object without a parameter");
System.out.println("\n\n");
Cube secondCube=new Cube();
secondCube.setDimension(l,w,h);
secondCube.displayCube();
}
}
Subscribe to:
Posts (Atom)