
-----------------------------------
goboenomo
Fri Oct 21, 2005 11:26 am

Basic Class
-----------------------------------
Im taking a programming class at my high school
its really easy...
hahah i have so much extra time... i can submit one of the programs we had to make

import java.io.*;
public class Invoice
{
    public static void main (String[] args)
        throws java.io.IOException
    {
        BufferedReader br = new BufferedReader (new InputStreamReader (System.in));

        String name;
        String addy;
        String city;
        String prov;
        String postcode;
        String scds;
        int cds;
        String sdvds;
        int dvds;
        double subtot;
        double gst;
        double pst;
        double total;

        double cdc = 16.99;
        double dvdc = 24.99;

        System.out.println ("What is your name?");
        name = br.readLine ();
        System.out.println ("What is your address?");
        addy = br.readLine ();
        System.out.println ("What province do you live in?");
        prov = br.readLine ();
        System.out.println ("What city do you live in?");
        city = br.readLine ();
        System.out.println ("What is your postal code?");
        postcode = br.readLine ();
        System.out.println ("CDs are $16.99, how many would you like to buy?");
        scds = br.readLine ();
        System.out.println ("DVDs are $24.99, how many would you like to buy?");
        sdvds = br.readLine ();

        cds = Integer.parseInt (scds);
        dvds = Integer.parseInt (sdvds);

        subtot = (cds * cdc) + (dvds * dvdc);
        gst = subtot * .07;
        pst = subtot * .08;
        total = subtot + gst + pst;

        System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");


        System.out.println ("                                    INVOICE");
        System.out.println ("");
        System.out.println (name);
        System.out.println (addy);
        System.out.println (city + ", " + prov);
        System.out.println (postcode);
        System.out.println ("");
        System.out.println ("");
        System.out.println ("                                    CDs - QUANTITY    " + cds);
        System.out.println ("                                             xCOST    $" + cdc);
        System.out.println ("");
        System.out.println ("                                    DVDs - QUANTITY   " + dvds);
        System.out.println ("                                              xCOST   $" + dvdc);
        System.out.println ("");
        System.out.println ("                                           SUBTOTAL   $" + subtot);
        System.out.println ("                                                GST   $" + gst);
        System.out.println ("                                                PST   $" + pst);
        System.out.println ("                                              TOTAL   $" + total);
        System.out.println ("\n\n\n\n\n");
    }
}

*Yawn*
We got 2 classes (2hours and 30 mins) to work on this.. it took me 20 minutes
hahahahah

-----------------------------------
wtd
Fri Oct 21, 2005 1:59 pm


-----------------------------------
int cds = Integer.parseInt(br.readLine());

And lose the:

String scds;

int cds;

scds = br.readLine();

And:

cds = Integer.parseInt(scds);

Lines.

-----------------------------------
goboenomo
Sun Oct 23, 2005 10:38 pm


-----------------------------------
right now in class we have to promt the user and recieve as a string then change to int... so for now i need those variables

-----------------------------------
1of42
Mon Oct 24, 2005 3:16 pm


-----------------------------------
What wtd is doing is the exact same thing, but he uses an anonymous variable for the String input, and puts intialization and assignment on one line.

-----------------------------------
goomba
Sun Oct 30, 2005 9:20 pm


-----------------------------------
Very easy, says the newbie. :D Since you have sooo much extra time, how about skipping ahead of your class and reading up on how to write proper OOP code?

If you want to show off some real Java skillz, try rewriting your program to consist of an InvoiceApp class and an Invoice class. The Invoice class should have methods to get, set, and calculate values as well as one or two constructors to set common values on instantiation. The InvoiceApp class should generate Invoices based on user input and store these in a list of some sort.

:P

-----------------------------------
goboenomo-855
Sun Oct 30, 2005 10:38 pm


-----------------------------------
Very easy, says the newbie. :D Since you have sooo much extra time, how about skipping ahead of your class and reading up on how to write proper OOP code?

If you want to show off some real Java skillz, try rewriting your program to consist of an InvoiceApp class and an Invoice class. The Invoice class should have methods to get, set, and calculate values as well as one or two constructors to set common values on instantiation. The InvoiceApp class should generate Invoices based on user input and store these in a list of some sort.

:P
i would, u fucking asshole...
but my teacher wont let me

-----------------------------------
goomba
Sun Oct 30, 2005 11:33 pm


-----------------------------------
Yeah, cause teachers HATE it when you go above the requirements. :roll:

-----------------------------------
Hikaru79
Sun Oct 30, 2005 11:46 pm


-----------------------------------

i would, u ****ing *******...
but my teacher wont let me
If your teacher won't let you use real, correct code perhaps you should just drop the class, because it will hurt you more than help you at that rate...
