Help with some java login code

hey,
I am a new member but used to visit the site regularly. I am undergoing a java project and I cannot seem to get my head around how to code when users log in, there name must appear at the top of each page they visit.
User enters name into a text box. Do I use getter and setter methods? any bit of help would be of some advantage to me.
Thanks for your time and I'll help with anyone else who is stuck.

if JSP or servlet use Session...
if you are using frame you have to consider... which frame is a top parent. that top frame will have the set and get method.. for you to set and retrieve the user name.. bear in mind that different object will have different user...
so you have to play fair game ...hehehehe :-)

Similar Messages

  • Help with some java work ... :(

    Hi, I was wondering can anyone here give me some help or show me the way with this programming assignment. This is my first week of programming in Java and is really struggling ...
    I already have some very useful help from some people on here but still have no luck.
    Below is what my assignment is about and what I've done so far, sorry if it's very basic but I'm trying my hardest.
    You are required to write a program in Java that can store the details of three books. Their details are
    Author
    Shelf location
    Availability
    The program should give each book a unique shelf location starting from 0001. The details should be entered from the keyboard. The program should, on request, be able to print the details of each book to the screen. The program should terminate on request. The program should first ask for a preset password to be given before continuing executing any operation described above
    public class Library {
    public static void main(String[] args) {
    String[][] books =
         { "Shelf Location", "Author   ", "Book Name     ", "Availability" },
    { "0001          ", "A. Smith ", "Hello World   ", "1           " },
    { "0002          ", "C. Jones ", "Goodbye World ", "0           " },
    { "0003          ", "D. Wan   ", "Whatever      ", "5           " }
    for (int i = 0; i < books.length; i++) {
         System.out.print(books[0] + " ");
    for (int j = 1; j < books[i].length; j++) {
         System.out.print(books[i][j] + " ");
         System.out.println();
    import java.io.*;
    public class Login2
    private static BufferedReader in;
    private static BufferedReader keyboard;
    public static void main(String[] args) throws IOException
    keyboard = new BufferedReader(
    new InputStreamReader(System.in));
    String input;
    boolean done = false;
    while (!done)
    System.out.print("Enter Password in UPPERCASE (QUIT to exit)");
    input = keyboard.readLine();
    if ((input.equals("LOGIN")) || (input.equalsIgnoreCase("QUIT")))
    done =
    true;
    return.Library();
    I was told to use cases, instances, etc ... nothing complicated is needed but it is still to much for me. I saw some examples of people's work and they only have approx 1.5 pages of code.
    Thanx very much for people who reads this thread and offers me help.

    Here's something to play around with (minimal error handling)
    import java.io.*;
    class Library
      private final String password = "java";
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      private String books[][] = new String[3000][];
      int bookTotal = 0;
      public Library() throws IOException
        options();
      private void options() throws IOException
        System.out.print("\nLibrary Options - \n0 - quit\n1 - Enter book details"+
              "\n2 - List book details\n\nPlease enter selection number: ");
        int selection = Integer.parseInt(br.readLine());
        if(selection == 0) goodBye();
        else
          checkPassword();
          if(selection == 1) newBook();
          else listBook();
      private void newBook() throws IOException
        String another="";
        do
          if(bookTotal == books.length)
            System.out.println("Unable to add more books");
            return;
          books[bookTotal] = new String[4];
          System.out.print("\nEnter title details: ");
          books[bookTotal][0] = br.readLine();
          System.out.print("Enter author details: ");
          books[bookTotal][1] = br.readLine();
          System.out.print("Enter shelf location details: ");
          books[bookTotal][2] = br.readLine();
          System.out.print("\n0 - out of stock\n1 - available\n2 - on loan"+
                                           "\nEnter availability details: ");
          books[bookTotal][3] = br.readLine();
          bookTotal++;
          System.out.print("\nEnter another book? (y/n): ");
          another = br.readLine();
        }while(another.toLowerCase().equals("y"));
        options();
      private void listBook() throws IOException
        String another="";
        String titles = "\n";
        String availability[] = {"out of stock","available","on loan"};
        for(int i=0;i<bookTotal;i++) titles += (i+1)+" - "+books[0]+"\n";
    int selection = 0;
    if(bookTotal > 0)
    do
    System.out.print(titles+ "Please enter selection number: ");
    selection = Integer.parseInt(br.readLine()) - 1;
    System.out.println("\nBook title = "+books[selection][0]);
    System.out.println("Book author = "+books[selection][1]);
    System.out.println("Book shelf location = "+books[selection][2]);
    System.out.println("Availability = "+availability[Integer.parseInt(books[selection][3])]);
    System.out.print("\nList another book? (y/n): ");
    another = br.readLine();
    }while(another.toLowerCase().equals("y"));
    else System.out.println("\nno books to list\n");
    options();
    private void goodBye()
    System.out.println("\nThank you for using the Library program.\nGoodbye.\n");
    System.exit(0);
    private void checkPassword() throws IOException
    System.out.print("\nEnter password to continue: ");
    String pwd = br.readLine();
    if(!pwd.equals(password)) goodBye();
    public static void main(String args[]) throws IOException
    new Library();

  • Help with some Java Programs

    Hi all ..
    i am a new in Java and i need some help with my School Project ,,,
    Will you help me ??
    regards,
    Toota

    People here will answer questions and comment on your code, but don't ecpect them to debug your source nor do your homework for you.

  • Help with some explanation of code

    Hi
    could some one explain how the code in italics works below.  Is the varaiable currentObject which has a data type of DragDrop an
    array as well that gets loaded up with the string values of the dragdrops array?
    public class Map extends MovieClip
            var dragdrops:Array;
            public function Map()
                // constructor code
                dragdrops = [deathvalley,goldengate,grapes,hollywood,
                 joshuatree,laketahoe,mission,redwood];
              var currentObject:DragDrop;
                for (var i:uint = 0; i < dragdrops.length; i++)
                    currentObject = dragdrops[i];
                    currentObject.target = getChildByName(currentObject.name + "_target");
    AND THIS CODE I THINK TESTS FOR IF THE OBJECT HITS ITS TARGET BUT I DON'T UNDERSTAND HOW IT WORKS?
    if (hitTestObject(target))
                    visible = false;
                    target.alpha = 1;
                    Object(parent).match();

    Hi ,
    Try to write the code in this type of format.
    I think this may help you.
    TABLES: bapiache08, bapiacgl08,bapiaccr08, bapiret2.
    DATA: t_bapiache08 LIKE TABLE OF bapiache08 WITH HEADER LINE,
    t_bapiacgl08 LIKE TABLE OF bapiacgl08 WITH HEADER LINE,
    t_bapiaccr08 LIKE TABLE OF bapiaccr08 WITH HEADER LINE,
    t_bapiret2 LIKE TABLE OF bapiret2 WITH HEADER LINE,
    ct_bapiret2 LIKE TABLE OF bapiret2 WITH HEADER LINE.
    t_bapiache08-obj_type = 'BKPFF'. "BKPFF
    t_bapiache08-obj_key = '010000000000062005'.
    t_bapiache08-obj_sys = 'T90CLNT800'. "T09CLNT800
    t_bapiache08-username = 'SSI4'.
    t_bapiache08-header_txt = 'DOCUMENT POSTING'.
    t_bapiache08-comp_code = '1000'.
    t_bapiache08-fisc_year = '2005'.
    t_bapiache08-doc_date = '20050805'.
    t_bapiache08-pstng_date = '20050805'.
    t_bapiache08-fis_period = '07'.
    t_bapiache08-doc_type = 'SA'.
    t_bapiache08-compo_acc = 'FI'. "GL
    APPEND t_bapiache08.
    t_bapiacgl08-itemno_acc = '031'.
    t_bapiacgl08-gl_account = '160000'.
    t_bapiacgl08-comp_code = '1000'.
    t_bapiacgl08-pstng_date = '20050805'.
    t_bapiacgl08-doc_type = 'SA'.
    t_bapiacgl08-fisc_year = '2005'.
    t_bapiacgl08-fis_period = '07'.
    t_bapiacgl08-stat_con = 'X'.
    t_bapiacgl08-vendor_no = '1920'. "ACCOUNTING NO.FOR VENDOR/CREDITOR.
    t_bapiacgl08-item_text = 'LINE ITEM TEXT BY VIN'.
    APPEND t_bapiacgl08.
    t_bapiaccr08-itemno_acc = '031'.
    t_bapiaccr08-currency_iso = 'EUR'.
    t_bapiaccr08-amt_doccur = '2000'.
    APPEND t_bapiaccr08.
    CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'
    EXPORTING
    documentheader = t_bapiache08
    IMPORTING
    OBJ_TYPE =
    OBJ_KEY =
    OBJ_SYS =
    TABLES
    accountgl = t_bapiacgl08
    currencyamount = t_bapiaccr08
    return = t_bapiret2
    EXTENSION1 =
    Thanks & Regards,
    Ravi Kanth Yechuri.

  • Get some help with some java questions

    Parameters are formal arguments passed to:
    methods, constructors, events handlers and objects or all?
    What arithmetic operator can be used with characters?
    If you pass an argument to a math method that is not a number, it returns?
    If anyone could give me some insight on these questions or tell me where I could read up on them I would appreciate it

    How To Ask Questions The Smart Way

  • Could someone help with some pathfinding game code using Director please?

    Hey guys, i`m new to director and am trying to create a very basic graffiti game with pathfinding code. any links to online tutorials or code sites would be much appreciated! thanks in advance!

    I don't understand how pathfinding relates to graffiti, but here is a Lingo implementation of the A* algorithm

  • Help with some beginner code

    Hello, I am new to java and I need a bit of help with some code that I'm writing. here is the code:
    import javax.swing.*;
    public class Test{
         public static void main(String[] args){
         JOptionPane.showMessageDialog(null,"We will now build a block with *'s","Block",1);
         String input=JOptionPane.showInputDialog(null,"Type a number: ","Number",3);
         int number=Integer.parseInt(input);
         int count=0; int count2=0;
         for(count2=0; count2<number; count2++){
              for(count=0; count<number; count++){
              System.out.print("* ");
    System.exit(0);
    }Now, all I need is to build a block of *'s with the number that the user inputs. With the code that I wrote I get the correct number of *'s but not in the form of a block. They just print out in a straight line. I know this is a very simple task but could someone please help me out? What do I need to modify in my code so that the *'s print out arranged as a block like so:
    **********

    Your code only uses the print method which prints without a carriage return/line feed. So you need to add a line of code to print a carriage return/line feed. Where? well that is your task to work out.

  • Want a complete migration guide to upgrade 11.1.0.7 to 11.2.0.3 database using DBUA..We are implementing R12.1.3 version and then have to migrate the default 11gR1 database to 11.2.0.3 version. Please help with some step by step docs

    Want a complete migration guide to upgrade 11.1.0.7 to 11.2.0.3 database using DBUA..We are implementing R12.1.3 version and then have to migrate the default 11gR1 database to 11.2.0.3 version. Please help with some step by step docs

    Upgrade to 11.2.0.3 -- Interoperability Notes Oracle EBS R12 with Oracle Database 11gR2 (11.2.0.3) (Doc ID 1585578.1)
    Upgrade to 11.2.0.4 (latest 11gR2 patchset certified with R12) -- Interoperability Notes EBS 12.0 and 12.1 with Database 11gR2 (Doc ID 1058763.1)
    Thanks,
    Hussein

  • I need help with some simple code! Please read!

    hi everyone.
    I'm having problems with a piece of code, and i'd be extremely greatful if somebody could give me a hand with it. I'm totally new to java and have to make a program for my university degree, but i'm finding it extremely difficult, mainly due to my total lack of apptitude for this type of thing. I know this is easy stuff, but the books I have are no use so any help would be greatly appreciated.
    I have to write a program which uses two class files. I want one with the code to produce a simple button, and one to invoke it several times at different locations. I decided to write the program as one class file at first, and thought i'd be able to split it up at later. The program works fine when it is one class file. My book said that to split the two classes up, all i needed to do was change the second class to public, although this seems to not work at all. I'm at my wits end on this, and if anyone could correct my code I'd be eternally greatful.
    Here is the first class... (sorry about the lack of indentation)
    >>>>>>>>>>
    import java.awt.*;
    import java.applet.Applet;
    public class Phone extends Applet {
    private Image image;
    public void init() {
    setLayout(null);
    image = getImage(getDocumentBase(), "phone.jpg");}
    public void paint (Graphics g) {
    g.drawImage(image, 0, 0, 700, 530, this);
    PhoneButton myButton;
    myButton = new PhoneButton(20,20);
    >>>>>>>
    This is the second class....
    >>>>>>>
    public class PhoneButton {
    private Button butt;
    public PhoneButton(int a, int b, int c){
    setLayout(null);
    butt = new Button();
    butt.setBounds(a,b,20,20);
    add(butt);
    >>>>>>>>
    My compiler generates errors relating to Button, but i can't do anything to please it.
    Also, could anyone give me some pointers on how to add a different number or symbol to each button. That is what I added int c for, but i couldn't get it to work.
    Cheers in advance.
    Michael Morgan

    I found that there are 5 error in your code.
    1. You should import the "java.awt" package to the PhoneButton.java
    2. The PhoneButton is not a kind of Component. You cannot not add it to the Phone class
    3. the myButton = new PhoneButton(20, 20) does not provide enough parameters to create PhoneButton
    4. You cannot add a Button to a PhoneButton. Becaue the PhoneButton is not a kind of Container
    Fixed code:
    import java.awt.*;
    public class PhoneButton extends Button {
    public PhoneButton(int a, int b, int c){
         setBounds(a, b, 20, 20);
         setLabel(String.valueOf(c));
    ===========================================
    import java.awt.*;
    import java.applet.Applet;
    public class Phone extends Applet {
    private Image image;
    public void init() {
    setLayout(null);
    image = getImage(getDocumentBase(), "phone.jpg");}
    public void paint (Graphics g) {
    g.drawImage(image, 0, 0, 700, 530, this);
    PhoneButton myButton;
    myButton = new PhoneButton(20,20, 1);
    ======================
    Visual Paradigm for UML - Full Features UML CASE tool
    http://www.visual-paradigm.com/

  • Hello, im new to mac and I need some help with a java problem.

    Hello, im new to mac. I just need someone who can help with a problem ive come across when playing online games that run java. The game is arcanists. its on the funorb website. really fun game and i love it, but i cant play it without my screen keep scrolling or my character not responding at all. please get back at me ASAP. thx apple friends!

    FF has an extention that can be used to increase the conection speed. Its called Tweak Network 1.1 I see a difference on my iMac G5. Its not huge but it may be a big difference on yours.
    http://www.bitstorm.org/extensions/tweak/

  • Help with implementing a login page - ADF Faces & 10.1.3

    I am having trouble getting a basic login page working and am hoping someone can help. I'd like to have a login page with username and password fields and a submit button. When submitted, I would like to authenticate the user and either send them to a second page if I find the username & password, or return them to the login page and display a global JSF message if I can't find the username/password info. Pretty standard stuff.
    I've got an app module that contains a read-only view object, which has a custom method (in MyViewImpl.java) that checks the username & password against a database table and returns a boolean. I don't have an entity object since it's a read-only view.
    I've tried 2 different approaches:
    1) Binding the username and pw inputText fields to the parameters of my custom method, and binding the submit button to the custom method, all done by drag and drop from my data controls.
    The problem with this approach is that I cannot figure out how to set the global message if the username/password combo is invalid. Once my method is invoked, it returns an "action" String and page navigation occurs (In this case, I have my custom method return a String instead of a boolean). If login fails, at what point do I set the global message?
    2) Using a backing bean for my login page and binding the fields and the button to the bean, and setting the button's action to a method in the bean, which then calls my custom method. Finally, either set the message or navigate based on the boolean returned from my method.
    This seems the better approach, since it keeps the navigation and error message in the ViewController. The problem here is that I can't figure out how to call my custom method from my backing bean. I've seen a few examples, including one using a managed property and calling the action binding's invoke() method, but haven't had any luck (see #51 on this page: http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html). The invoke() method does not return a value, so I cannot get the boolean value I need.
    So, I'm apparently missing a piece (or two or three) of the puzzle here. Any guidance is most welcome! And I'm fine with changing any piece of this puzzle if there's a better way of accomplishing this.
    Thanks,
    Andy

    Frank,
    Thanks for your reply. I'm not sure if container managed authentication is a good fit or not for my current application, so I will have to look into the details of how it works. Thanks for the suggestion. Whether I use it or not, I will still need to authenticate against a database and not a flat file due to the fact that users may come and go and change passwords frequently, and my application will not be handling the management of that.
    So, I would be still left with the task of accessing the ViewObject and navigating/displaying a message based on the results of that lookup. Fortunately, after slogging through my code and consulting the ADF documentation that is scattered throughout the Oracle website, I was able to get the login page working as I wanted (I found the "Accessing Bindings and Binding Containers from JSF Backing Beans" section of http://www.oracle.com/technology/products/jdev/tips/muench/1013eabinding/index.html to be especially helpful). I used the submit button's action to call a method in the backing bean that sent the username and password to my application module's custom authentication method. When I got the boolean result, I either returned a "success" action or set a global JSF message and returned "null".
    Needless to say, I am looking forward to the ADF/JSF version of the Toystore application, along with some sort of comprehensive framework documentation.
    Thanks,
    Andy

  • Need help with this Pascal Triangle code....

    Hey everyonr i am totally new to Java... so need your help with this code...
    the function makeRows gives me problems... main is correct ... can someone fix my makeRows... i don't see what's wrong
    public class Pascal {
      /** Return ragged array containing the first nRows rows of Pascal's
       *  triangle.
      public static int[][] makeRows(int nRows) {
            int[][] mpr  = new int[nRows+1][];
            int l=0; int r=0;
            for (int row = 0; row < nRows; row++) {
              mpr[row] = new int[row+1];  //index starts at 0
              if (row==0) {
                mpr[0][0]= 1;
                    if (row==1) {
                mpr[1][0]= 1;
                mpr[1][1]= 1;
              if (row>=2) {
                 for (int j = 0; j <= row; j++) {
                    if (j==0)               {l=0;} else {l=mpr[row-1][j-1];}
                    if (j==mpr[row].length-1) {r=0;} else{r=mpr[row-1][j];}
                    mpr[row][j] = l + r;
            return mpr;
      public static void main(String[] args) {
             if (args.length != 1) {
               System.out.println("usage: java " + Pascal.class.getName() + " N_ROWS");
               System.exit(1);
             int nRows = Integer.parseInt(args[0]);
             if (nRows > 0) {
               int[][] pascal = makeRows(nRows);
               for (int[] row : pascal) {
              for (int v : row) System.out.print(v + " ");
              System.out.println("");
         }this makeRows function should return ragged array containing the first nRows rows of Pascal's triangle
    thanks
    Edited by: magic101 on May 9, 2008 4:03 PM

    magic,
    i think corlettk meant that some people might not know what pascal's triangle is.
    also, you didnt say what was wrong with your code, just that it was wrong.
    asking smart questions is about giving as much information you can to get the
    best answer. i would throw a System.out.print between every line of your
    algorithm. i would also supply us with the values you are getting for each row.
    also, this question is asked all the time here. do a forum search.
    1
    11
    121
    1331
    14641

  • HELP WITH AN OLDER VERSION CODE!!!!!

    I am trying to figure out how to convert a code from an older version into JDK1.3.1_01.
    Please HELP!
    Here is my code............
    mport java.awt.*;
    import java.applet.*;
    public class Race extends Applet {
    private Button myButton; //use a button to start the race.
    int race_square; //record the race square 70.
    int t_square; //record the tortoise's position.
    int h_square; //record the hare's position.
    int clock; //record clock ticks.
    public void init()
    myButton=new Button("Start Clock") ; //add button to the top of panel.
    add("North",myButton);
    reset_v();
    public void reset_v()
    race_square=70; // total squares is 70
    t_square=1; //start point =1
    h_square=1; //start point=1
    clock=0; //reset the clock to zero.
    public void race() {
    int i=0; //set some integer varibles.
    int t_random=0; //random number for tortoise.
    int h_random=0; //random number for hare.
    Graphics g=getGraphics(); //define graphics.
    Rectangle r = bounds(); //define painting boundary.
    g.drawString("BANG !!!!!",100,r.height/2-80);
    g.drawString("AND THEY'RE OFF !!!!!",100,r.height/2-70);
    g.drawString(Integer.toString(clock),r.width/2,50); //show the zero clock time.
    do{
    try { Thread.sleep(1000);} //clock ticks 1 second.
    catch (InterruptedException e){}
    clock++;
    g.setColor(Color.lightGray); //clear all the old drawings
    g.fillRect(0,0,r.width,r.height);
    g.setColor(Color.black);
    g.drawString(Integer.toString(clock),r.width/2,50); //show the clock time.
    t_random=getrandom(); // FOR TORTOISE
    if (t_random<=5) t_square+=3; // 50% fast plod: 3 squares to the right.
    else if (t_random>5 && t_random<=7)t_square-=6; // 20% slip: 6 squares to the left.
    else t_square+=1; // 30% slow plod: 1 square to the right.
    h_random=getrandom(); //FOR HARE
    if (h_random<=2) {} // 20% sleep: not move at all.
    else if (h_random>2 && h_random<=4)h_square+=9;// 20% big hop: 9 squares to the right.
    else if (h_random==5) h_square-=12; // 10% big slip: 12 squares to the left.
    else if (h_random>5 && h_random<=8)h_square+=1;// 30% slow hop: 1 square to the right.
    else h_square-=2; // 20% small slip: 2 aquares to the left.
    if(t_square<=0) t_square=1; //always start from 1.
    if(t_square>race_square)t_square=race_square;
    if(h_square<=0) h_square=1; //always start from 1.
    if(h_square>race_square)h_square=race_square;
    g.setColor(Color.red); //draw the tortoise's path: use red color.
    g.fillRect(5,r.height/2-5,5*t_square,5);
    g.drawString("T",5*t_square,r.height/2-7);
    g.setColor(Color.blue); //draw the hare path: use blue color.
    g.fillRect(5,r.height/2+1,5*h_square,5);
    g.drawString("H",5*h_square,r.height/2+17);
    g.setColor(Color.black); //draw the race squares.
    g.drawLine(5,r.height/2,5+5*race_square,r.height/2);
    for(i=5;i<=5+5*race_square;i+=5)
    g.drawLine(i,r.height/2-5,i,r.height/2+5);
    if (t_square==h_square &&t_square!=race_square) // tortoise bites the hare.
    g.drawString("OUCH!!!",5+5*h_square,r.height/2-16);
    }while ( t_square=race_square && h_square=race_square && t_square<=5+5*race_square;i+=5)
    g.drawLine(i,r.height/2-5,i,r.height/2+5);
    g.drawString("T",5,r.height/2-7); //mark tortoise
    g.drawString("H",5,r.height/2+17); //mark hare
    public int getrandom()
    return( 1+(int)(Math.random()*10)); // generating the random number 1 to 10.
    public boolean action(Event e, Object arg)
    if (e.target instanceof Button)
    reset_v(); //reset the initial variables.
    race(); //use the button the start the race.
    return true;

    You posted this yesterday, at
    http://forum.java.sun.com/thread.jsp?forum=54&thread=185330
    The code you've posted doesn't seem to include Ilikejava's suggested changes - which are, as far as I can tell, the major changes required to bring your applet in line with Java 1.3.
    It will be easier to help if you show what is wrong with your code, if it's generating a compiler error message or throwing an exception.
    Regards,
    -Troy

  • Help with program plz (long code)

    anyone know how i can fix these 2 errors:
    Driver2.java:47: code is already defined in main(java.lang.String[])
    String code = JOptionPane.showInputDialog(
    ^
    Driver2.java:51: incompatible types
    found : java.lang.String
    required: int
    int val = bc.getCode();
    ^
    the case 2 in the driver is where it messes up, i believe..it works with just the case 1...any help/advice is appreciated(i am aware of spacing errors)
    import javax.swing.JOptionPane;
    import java.util.Scanner;
    public class Driver2
       public static void main(String[] args)
          String userChoice;
          int choice;
    Scanner keyboard = new Scanner(System.in);
    userChoice = JOptionPane.showInputDialog("Enter 1 to enter a numeric zip code:\n"
    + "Enter 2 to enter a bar code:\n"
    + "Enter 3 to exit program:\n");
    choice = Integer.parseInt(userChoice);
    while (choice != 3)
           switch (choice)
           case 1:
           String input = JOptionPane.showInputDialog( "Please enter a five-digit zip code: ");
    int num = Integer.parseInt(input);
    BarCode bc = new BarCode(num);
    String code = bc.getCode();
    JOptionPane.showMessageDialog(null, "The barcode of the zip is: " + code);
    System.exit(0);
    break;
    case 2:
    String code = JOptionPane.showInputDialog( "Please enter bar code: ");
    int val = bc.getCode();
    if (val >= 0)
    System.out.println("The zip code is: " + val);
    else
    System.out.println("Incorrect bar code data");
    System.exit(0);
    break;
    case 3:
    break;
    userChoice = JOptionPane.showInputDialog("Enter 1 to enter a numeric zip code:\n"
    + "Enter 2 to enter a bar code:\n"
    + "Enter 3 to exit program:\n");
       public BarCode(int n)
          zip = n;
       public String getCode()
          String barCode = "|";
          int sum = 0;
          int temp = 0;
          temp = zip / 10000;
          sum = sum + temp;
          Digit d1 = new Digit(temp);
          barCode = barCode + d1.getCode();
          zip = zip % 10000;
          temp = zip / 1000;
          sum = sum + temp;
          Digit d2 = new Digit(temp);
          barCode = barCode + d2.getCode();
          zip = zip % 1000;
          temp = zip / 100;
          sum = sum + temp;
          Digit d3 = new Digit(temp);
          barCode = barCode + d3.getCode();
          zip = zip % 100;
          temp = zip / 10;
          sum = sum + temp;
          Digit d4 = new Digit(temp);
          barCode = barCode + d4.getCode();
          zip = zip % 10;
          temp = zip;
          sum = sum + temp;
          Digit d5 = new Digit(temp);
          barCode = barCode + d5.getCode();
          temp = 10 - (sum % 10);
          Digit d6 = new Digit(temp);
          barCode = barCode + d6.getCode() + "|";
          return barCode;
       private int zip;
    public class BarCode1
       public BarCode1(int n)
          zip = n;
       public String getCode()
          String barCode = "|";
          int sum = 0;
          int temp = 0;
          temp = zip / 10000;
          sum = sum + temp;
          Digit d1 = new Digit(temp);
          barCode = barCode + d1.getCode();
          zip = zip % 10000;
          temp = zip / 1000;
          sum = sum + temp;
          Digit d2 = new Digit(temp);
          barCode = barCode + d2.getCode();
          zip = zip % 1000;
          temp = zip / 100;
          sum = sum + temp;
          Digit d3 = new Digit(temp);
          barCode = barCode + d3.getCode();
          zip = zip % 100;
          temp = zip / 10;
          sum = sum + temp;
          Digit d4 = new Digit(temp);
          barCode = barCode + d4.getCode();
          zip = zip % 10;
          temp = zip;
          sum = sum + temp;
          Digit d5 = new Digit(temp);
          barCode = barCode + d5.getCode();
          temp = 10 - (sum % 10);
          Digit d6 = new Digit(temp);
          barCode = barCode + d6.getCode() + "|";
          return barCode;
       private int zip;
    public class Digit
       public Digit(int n)
          zip = n;
       public String getCode()
          String bar = "";
          if (zip == 1)
             bar = ":::||";
          else if (zip == 2)
             bar = "::|:|";
          else if (zip == 3)
             bar = "::||:";
          else if (zip == 4)
             bar = ":|::|";
          else if (zip == 5)
             bar = ":|:|:";
          else if (zip == 6)
             bar = ":||::";
          else if (zip == 7)
             bar = "|:::|";
          else if (zip == 8)
             bar = "|::|:";
          else if (zip == 9)
             bar = "|:|::";
          else
             bar = "||:::";
          return bar;
       private int zip;
    public class Digit1
       public Digit1(int n)
          zip = n;
       public String getCode()
          String bar = "";
          if (zip == 1)
             bar = ":::||";
          else if (zip == 2)
             bar = "::|:|";
          else if (zip == 3)
             bar = "::||:";
          else if (zip == 4)
             bar = ":|::|";
          else if (zip == 5)
             bar = ":|:|:";
          else if (zip == 6)
             bar = ":||::";
          else if (zip == 7)
             bar = "|:::|";
          else if (zip == 8)
             bar = "|::|:";
          else if (zip == 9)
             bar = "|:|::";
          else
             bar = "||:::";
          return bar;
       private int zip;
    }

    > i got it to compile now...i can toy around w/
    it..thanks for the help
    Good.
    Stick with this handle, ok?I must say I am not thrilled with
    a) when I questioned the first post of WhiteSox asking if it was bugz or a classmate or what I was ignored by the OP
    b) I guess the OP is trying to distance himself from his very first thread where somebody did part of his homework for him with results that are now plainly evident. As I predicted at the end of the last thread.
    http://forum.java.sun.com/thread.jspa?threadID=703258 Reply 11
    I hope that matsabigman and others who help homework posters by doing it for them will take note of the results of this help thus far. Not much good has come of this.
    BigMan/WhiteSox I am still detecting a fundamental lack of basic concepts on your part. This is the underlying cause of your compile errors but those are only a symptom. You can continue treating the symptoms but it would be a better use of your time to treat the disease, which in this case means spending some time getting a better grasp of Java fundamentals.

Maybe you are looking for

  • Safari doesn't "Reopen All Windows From Last Session" and links from Mail

    After a crash I found myself trying to "Reopen All Windows From Last Session", then I found that if I click a link from Mail it does not open it ... as well from any other application. It's like only workin' within itself and can't interact with any

  • Transfering custom EQ settings to iPod?

    Hello! I have a great Equalizer setting on my Mac that I would love to transfer to my iPod - it works well for my small earbuds (not the default Apple earbuds) in loud places. However, the iPod (still!) won't support custom settings! I know one work

  • Import all users and their objects without doing full database import

    Hi Guys, I have a task to that involves Importing all existing users and their objects in production to the test database without doing a full database import - Please how do i do this? Pls i need your help urgently.

  • Customizing loan calculations

    Hi. How can I change loan calculations?Is there any Schema to do that? Should I utilize ABAP codes and programmers to do that? Best regards

  • I can't activate iMessage

    I can't activate iMessage on my iPhone 4 since upgrading operating systems....help!