docu filor

  • View
    214

  • Download
    0

Embed Size (px)

Text of docu filor

  • 8/2/2019 docu filor

    1/22

    Objectives:

    In order to make a java program that is able to convert Philippine Peso,United State Dollar and European Union Euro to different countries.

    In order to make use of Java language packages, input output functions,concatenation operators, etc.

    In order to observe the nature of Java programming.

    To re-master the lessons learned in the previous lessons.

    To familiarize us with the concepts involved in constructing such program.

    Conceptual Frameworks:

    Pseudocode1. The program will ask the user to choose an option from Convert, View,

    Save and Quit.

    2. When the user picked the option Convert, the program will again askthe user to choose an option from A, B, C, D and Quit.

    3. After picking an option, the program will again ask the user to choosean option from 1-7 depending on what currency the user wants.

    4. After choosing a currency, the program will now ask the user to input amoney value.

    5. After the user finished inputting a money value, the program will nowconvert it to the desired currency.

    6. When done, the program will go back to the main option.

  • 8/2/2019 docu filor

    2/22

    7. When the user has decided to choose the View button, the programwill display all the money values that the user converted recently.

    8. By clicking OK, it will return again to the main menu.9. When the user clicks the Save button, the program will generate a

    receipt-like notepad that will display all the converted values.

    10.The program will return to the main menu until the user quits theprogram.

    OperatorsImport javax.swing.*- is the primary Java GUI widget toolkit. It is part

    ofOracle's Java Foundation Classes

    Import java.util.* - To generate a series of random numbers as a unit.

    Import java.io.* - Reader, streams and buffers and readers.

    Static void main (String [] args) a java program signature method that

    serves as the entry point of a java program.

    Printwriter supports the print () and println () methods for all types

    including:

    Parse

    String

    Scanner

    a statement that serves as a hybrid counterpart of printf and

    scanf in Java programming.

    JOptionPane.showMessageDialog a statement that serves as a single

    counterpart of printf in Java that is used to display prompts to the user.

    http://en.wikipedia.org/wiki/Java_(programming_language)http://en.wikipedia.org/wiki/GUIhttp://en.wikipedia.org/wiki/Widget_toolkithttp://en.wikipedia.org/wiki/Oracle_Corporationhttp://en.wikipedia.org/wiki/Java_Foundation_Classeshttp://en.wikipedia.org/wiki/Java_Foundation_Classeshttp://en.wikipedia.org/wiki/Oracle_Corporationhttp://en.wikipedia.org/wiki/Widget_toolkithttp://en.wikipedia.org/wiki/GUIhttp://en.wikipedia.org/wiki/Java_(programming_language)
  • 8/2/2019 docu filor

    3/22

    Switch statement a type of conditional statement for restricted choices

    of a decisive part of a program.

    Do-While Loop - continually executes a block of statements while a

    particular condition is true.

    Procedures The user inputs the amount they want to convert from peso to any

    currency or from any currency to peso.

    The program now computes for the equivalent amount in the selectedmode of computation.

    The program now shows the requested currency requested by the user.

    Data and Resultsimport javax.swing.*;

    import java.io.*;

    import java.util.*;

    public class finalmoney {

    public static void main(String args[]) throws Exception {

    Scanner ins= new Scanner(System.in);

    double DOLLAR = 44.42;

    double YEN = 0.52;

    double POUND = 68.24;

  • 8/2/2019 docu filor

    4/22

    double EURO = 56.36;

    double FRANC = 43.97;

    double DIRHAM = 12.09;

    double WON = 0.03;

    double PESO = 42.72;

    double dollarpeso=42.72;

    double dollarpound=0.64;

    double dollaryen=82.17;

    double dollarfranc=0.92;

    double dollareuro=0.76;

    double dollaruae=3.67;

    double dollarwon=1123.91;

    double europeso=56.06;

    double eurodollar=1.30;

    double euroyen=107.93;

    double eurofranc=1.25;

    double eurouae=4.82;double europound=0.84;

    double eurowon=1466.42;

    ArrayList aw=new ArrayList();

    double hold;

    double it1;

    double ctr;

    String peso;

    int reply;

    int rep;

    int reposed;

    int reposted;

  • 8/2/2019 docu filor

    5/22

    int reposting;

    int response;

    String raphy[]={"Convert", "View", "Save", "Quit"};

    String money[]={"A", "B","C", "D","Quit"};

    String choice[]={"1","2","3","4","5","6","7"};

    ArrayList name=new ArrayList();

    File receipt=new File("Receipt.txt");

    PrintWriter type=new PrintWriter(receipt);

    Scanner input=new Scanner(receipt);

    while(input.hasNext()){

    name.add(input.nextLine());

    }

    do{

    response=JOptionPane.showOptionDialog(null,

    " [Money Conversion Values to Philippine Peso]\n

    DOLLAR = 44.42\n YEN = 0.52\nPOUND = 68.24\n EURO = 56.36\n

    FRANC = 43.97\n DIRHAM = 12.09\n

    WON = 0.03\n\nGood day! Welcome to the Money Converter, please

    choose an option.\n", "Money Changer",

    JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE,

    null, raphy, raphy[1]);

    switch(response){

    case 0: reply=JOptionPane.showOptionDialog(null,

    "[A] - Exchange Philippine Peso (PhP) to other currency.\n[B] - Exchange

    other currency to Philippine Peso (PhP). \n[C] - Exchange US Dollar to other

  • 8/2/2019 docu filor

    6/22

    currency. \n[D] - Exchange Euro Dollar to other currency.", "Hey user, please

    choose an option!",

    JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null,

    money,money[2]); {

    switch(reply) {

    case 0:

    rep=JOptionPane.showOptionDialog(null,

    "[1] - United States - Dollar (USD)\n[2] - Japan - Yen (JPY)\n[3] - United

    Kingdom - Pound (GBP)\n[4] - European Monetary Union - Euro (EUR)\n[5] -

    Switzerland - Franc (CHF)\n[6] - United Arab Emirates - Dirham (AED) \n[7] -

    South Korea - Won (KRW)", "Hey user, please choose a currency!",

    JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null,

    choice,choice[2]);

    switch(rep) {

    case 0:

    String a=JOptionPane.showInputDialog(null, "Please enter the

    amount in Philippine Peso.");

    hold=Double.parseDouble(a);ctr= hold / DOLLAR;

    JOptionPane.showMessageDialog(null, "$"+ctr);

    name.add( "USD " +ctr);

    break;

    case 1:

    String b=JOptionPane.showInputDialog(null, "Please enter the

    amount in Philippine Peso.");

    hold=Double.parseDouble(b);

    ctr= hold / YEN;

    JOptionPane.showMessageDialog(null, "Yen "+ctr);

    name.add( "JPY " +ctr);

  • 8/2/2019 docu filor

    7/22

    break;

    case 2:

    String c=JOptionPane.showInputDialog(null, "Please enter the

    amount in Philippine Peso.");

    hold=Double.parseDouble(c);

    ctr= hold / POUND;

    JOptionPane.showMessageDialog(null, "GBP "+ctr);

    name.add( "GBP " +ctr);

    break;

    case 3:

    String d=JOptionPane.showInputDialog(null, "Please enter the

    amount in Philippine Peso.");

    hold=Double.parseDouble(d);

    ctr= hold / EURO;

    JOptionPane.showMessageDialog(null, "EUR "+ctr);

    name.add( "EUR " +ctr);

    break;

    case 4:

    String e=JOptionPane.showInputDialog(null, "Please enter the

    amount in Philippine Peso.");

    hold=Double.parseDouble(e);

    ctr= hold / FRANC;

    JOptionPane.showMessageDialog(null, "CHF "+ctr);

    name.add("CHF "+ctr);

    break;

    case 5:

  • 8/2/2019 docu filor

    8/22

    String f=JOptionPane.showInputDialog(null, "Please enter the

    amount in Philippine Peso.");

    hold=Double.parseDouble(f);

    ctr= hold / DIRHAM;

    JOptionPane.showMessageDialog(null, "AED "+ctr);

    name.add( "AED " +ctr);

    break;

    case 6:

    String g=JOptionPane.showInputDialog(null, "Please enter the

    amount in Philippine Peso.");

    hold=Double.parseDouble(g);

    ctr= hold / WON;

    JOptionPane.showMessageDialog(null, "KRW "+ctr);

    name.add( "KRW " +ctr);

    }

    break;

    case 1:

    reposed=JOptionPane.showOptionDialog(null,

    "[1] - United States - Dollar (USD)\n[2] - Japan - Yen (JPY)\n[3] - United

    Kingdom - Pound (GBP)\n[4] - European Monetary Union - Euro (EUR)\n[5] -

    Switzerland - Franc (CHF)\n[6] - United Arab Emirates - Dirham (AED) \n[7] -

    South Korea - Won (KRW)", "Hey user, please choose a currency!",

    JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null,

    choice,choice[2]);

    switch(reposed) {

    case 0:

  • 8/2/2019 docu filor

    9/22

    String h=JOptionPane.showInputDialog(null, "Please enter the

    amount in Dollar.");

    hold=Double.parseDouble(h);

    ctr= hold * DOLLAR;

    JOptionPane.showMessageDialog(null, "PhP "+ctr);

    name.add( "PhP " +ctr);

    break;

    case 1:

    String i=JOptionPane.showInputDialog(null, "Please enter the

    amount in Yen.");

    hold=Double.parseDouble(i);

    ctr= hold * YEN;

    JOptionPane.showMessageDialog(null, "PhP "+ctr);

    name.add( "PhP " +ctr);

    break;

    case 2:

    String j=JOptionPane.showInputDialog(null, "Please enter theamount in Pound");

    hold=Double.parseDouble(j);

    ctr= hold * POUND;

    JOptionPane.showMessageDialog(null, "PhP "+ctr);

    name.add( "PhP " +ctr);

    break;

    case 3:

    String k=JOptionPane.showInputDialog(null, "Please enter the

    amount in Euro.");

    hold=Double.parseDouble(k);

    ctr= hold * EURO;