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();

Similar Messages

  • 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 :-)

  • 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.

  • 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

  • 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

  • HELP.....with some home work

    hey everyone.....i was wondering if any one can help me out......i am doing a project for school and need some help with my program......here is my program.....
    ....i am having trouble with trying to bring up the NameOfColleges array...i want to use the information that is in that array....in the main method.....i do not know how
    to bring it from the fillStudent method to the main.....i bold the stuff that i need help with....thanks in advance......
    import javax.swing.JOptionPane;
    public class Student {
         public java.util.Date getAcceptDate;
         public static void main(String[] args) {
              College[] student = new College[100];
              int count = 0;
              do {
                   student[count] = fillStudent();
                   count++;
              } while(JOptionPane.showConfirmDialog(null, "Is there another student?") == JOptionPane.YES_OPTION);
              *for(int i = 0; i < count; i++){*
    *               String output = "Date Aquired: " +student.todaysDate() + "\n\n" +*
    *                         "Student Name: " + student[i].getName() + "\n" +*
    *                         "Student GPA: " + student[i].getGPA();*
    *          for (int j = 0; j < NameOfColleges.length; j++){*
    *               String output2 = "College " + (j+1) + NameOfColleges[j] + "\n";*
         private static College fillStudent() {
              College one = new College();
              String name, collegeName;
              double GPA;
              int numOFcoll;
              name = JOptionPane.showInputDialog("Please enter the student's name:");
              one.setName(name);
              GPA = Double.parseDouble(JOptionPane.showInputDialog("Please enter " + name + "'s Grade Point Average: (example: 3.6"));
              while (GPA <= 0.0 || GPA >= 4.0){
                   do{
                        GPA = Double.parseDouble(JOptionPane.showInputDialog("ERROR!! The number must be between 0.0 and 4.0. Please enter " + name + "'s Grade Point Average:"));
                   }while (GPA <= 0.0 || GPA >= 4.0);
              one.setGPA(GPA);
              numOFcoll = Integer.parseInt(JOptionPane.showInputDialog("Please enter the number of colleges that " + name + " applied to: (example: 3)"));
              one.setNumofColl(numOFcoll);
              String[] NameOfColleges = new String[numOFcoll];
              for (int i = 0; i < NameOfColleges.length; i++){
                   collegeName = JOptionPane.showInputDialog("Please enter the name of college " + (i+1) +": ");
                   NameOfColleges[i] = collegeName;
              for (int j = 0; j < NameOfColleges.length; j++){
              if (JOptionPane.showConfirmDialog(null, "Did this student get accepted into " + NameOfColleges[j] +"?") == JOptionPane.YES_OPTION) {
                   one.setAccept(true);
              } else
                   one.setAccept(false);
              return one;

    dude dont mess up code like this. Think before you go for writing some code.

  • 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 some fundamentals...

    OK, still trying to play catchup after some years away from Java. I'm slowly getting back up to speed with the help of some of the gurus present on this site.
    Here's the background: Working on examples from a Wrox book on JSP and moving to database connections. Programs compile fine but run into this NoClassDefFoundError. Here is a simple example:
    public class HelloWorld
    public static void main(String args[])
    System.out.println("Hello World!");
    Simple, heh? Compiles fine and when it is ran from the command line, this comes back:
    Exception in thread "main" java.lang.NoClassDefFoundError: com\wrox\db\HelloWorl
    d (wrong name: HelloWorld)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    On reading some help from others in previous questions, I set up a little batch file named setClassPath.bat. This file is to insure that the classpath for the programs in each of the chapters is part of the classpath. Here it is below:
    rem Contents of setClassPath.bat file:
    set CLASSPATH=%CLASSPATH%;<path to the java files under Tomcat server>
    What am I forgetting or missing?

    Note the train of events:
    C:\Documents and Settings\Dave Fliger\My Documents\apache-tomcat-6.0.14\webapps\begjsp-ch15\WEB-INF\classes>cd C:\Wrox
    C:\Wrox>dir
    Volume in drive C has no label.
    Volume Serial Number is C825-3EAA
    Directory of C:\Wrox
    10/03/2007 02:59 PM <DIR> .
    10/03/2007 02:59 PM <DIR> ..
    10/03/2007 02:59 PM 2,139 HelloWorld.java
    1 File(s) 2,139 bytes
    2 Dir(s) 47,145,979,904 bytes free
    C:\Wrox>javac HelloWorld.java
    C:\Wrox>java HelloWorld
    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
    C:\Wrox>
    Class compiled:
    public class HelloWorld
    public static void main(String args[])
    System.out.println("Hello World!");
    }

  • [8i] Need help with some workday calculations

    At the beginning of the month, I got help with a workday calculation in: [8i] Help with function with parameters (for workday calculation)
    Now, as it turns out, I was able to locate a function in the database that does what I want, however, it is much slower to use the function than to join two copies of the CALN table (Please see referenced thread for details. I can copy them to this thread if necessary.) I need to verify that the pre-existing function has 'DETERMINISTIC' in it, as I would guess that if it doesn't, it would be much slower than it could be.
    But now, I've come across a situation where I have to do multiple workday calculations in the same query--enough that I have to join 6 copies of my CALN table. I can't imagine that is at all efficient. I believe it was Frank K. who said (in the original thread) that if the function was slow, I should consider alternatives. Can anyone help me identify some of those alternatives? I'm definitely at that point now. (This query is one I'm using as the base for a report in Oracle BI, and let's just say it doesn't like my query, even though my syntax appears to be correct, and I would guess that joining 6 copies of one table is at least partly to blame for this).
    Note: I'm working with Oracle 8i

    OK, I finally have some sample data... I tried to make it thorough. I've included data in the CALN table YTD + tomorrow, so that any workday calculations using SYSDATE will work.
    CREATE TABLE caln
    (     clndr_dt     DATE          NOT NULL
    ,     clndr_yr     NUMBER
    ,     shop_day     NUMBER
    ,     shop_dt          DATE
    ,     shop_wk          NUMBER
    ,     shop_yr          NUMBER
    ,     shop_days     NUMBER
    ,     clndr_days     NUMBER
         CONSTRAINT caln_pk PRIMARY KEY (clndr_dt)
    INSERT INTO     caln
    VALUES (To_Date('12/23/2009','mm/dd/yyyy'),2009,247,To_Date('12/23/2009','mm/dd/yyyy'),51,2009,7631,10950);
    INSERT INTO     caln
    VALUES (To_Date('01/01/2010','mm/dd/yyyy'),2010,0,To_Date('12/23/2009','mm/dd/yyyy'),52,2009,7631,10959);
    INSERT INTO     caln
    VALUES (To_Date('01/02/2010','mm/dd/yyyy'),2010,0,To_Date('12/23/2009','mm/dd/yyyy'),52,2009,7631,10960);
    INSERT INTO     caln
    VALUES (To_Date('01/03/2010','mm/dd/yyyy'),2010,0,To_Date('12/23/2009','mm/dd/yyyy'),1,2010,7631,10961);
    INSERT INTO     caln
    VALUES (To_Date('01/04/2010','mm/dd/yyyy'),2010,1,To_Date('01/04/2010','mm/dd/yyyy'),1,2010,7632,10962);
    INSERT INTO     caln
    VALUES (To_Date('01/05/2010','mm/dd/yyyy'),2010,2,To_Date('01/05/2010','mm/dd/yyyy'),1,2010,7633,10963);
    INSERT INTO     caln
    VALUES (To_Date('01/06/2010','mm/dd/yyyy'),2010,3,To_Date('01/06/2010','mm/dd/yyyy'),1,2010,7634,10964);
    INSERT INTO     caln
    VALUES (To_Date('01/07/2010','mm/dd/yyyy'),2010,4,To_Date('01/07/2010','mm/dd/yyyy'),1,2010,7635,10965);
    INSERT INTO     caln
    VALUES (To_Date('01/08/2010','mm/dd/yyyy'),2010,5,To_Date('01/08/2010','mm/dd/yyyy'),1,2010,7636,10966);
    INSERT INTO     caln
    VALUES (To_Date('01/09/2010','mm/dd/yyyy'),2010,0,To_Date('01/08/2010','mm/dd/yyyy'),1,2010,7636,10967);
    INSERT INTO     caln
    VALUES (To_Date('01/10/2010','mm/dd/yyyy'),2010,0,To_Date('01/08/2010','mm/dd/yyyy'),2,2010,7636,10968);
    INSERT INTO     caln
    VALUES (To_Date('01/11/2010','mm/dd/yyyy'),2010,6,To_Date('01/11/2010','mm/dd/yyyy'),2,2010,7637,10969);
    INSERT INTO     caln
    VALUES (To_Date('01/12/2010','mm/dd/yyyy'),2010,7,To_Date('01/12/2010','mm/dd/yyyy'),2,2010,7638,10970);
    INSERT INTO     caln
    VALUES (To_Date('01/13/2010','mm/dd/yyyy'),2010,8,To_Date('01/13/2010','mm/dd/yyyy'),2,2010,7639,10971);
    INSERT INTO     caln
    VALUES (To_Date('01/14/2010','mm/dd/yyyy'),2010,9,To_Date('01/14/2010','mm/dd/yyyy'),2,2010,7640,10972);
    INSERT INTO     caln
    VALUES (To_Date('01/15/2010','mm/dd/yyyy'),2010,10,To_Date('01/15/2010','mm/dd/yyyy'),2,2010,7641,10973);
    INSERT INTO     caln
    VALUES (To_Date('01/16/2010','mm/dd/yyyy'),2010,0,To_Date('01/15/2010','mm/dd/yyyy'),2,2010,7641,10974);
    INSERT INTO     caln
    VALUES (To_Date('01/17/2010','mm/dd/yyyy'),2010,0,To_Date('01/15/2010','mm/dd/yyyy'),3,2010,7641,10975);
    INSERT INTO     caln
    VALUES (To_Date('01/18/2010','mm/dd/yyyy'),2010,11,To_Date('01/18/2010','mm/dd/yyyy'),3,2010,7642,10976);
    INSERT INTO     caln
    VALUES (To_Date('01/19/2010','mm/dd/yyyy'),2010,12,To_Date('01/19/2010','mm/dd/yyyy'),3,2010,7643,10977);
    INSERT INTO     caln
    VALUES (To_Date('01/20/2010','mm/dd/yyyy'),2010,13,To_Date('01/20/2010','mm/dd/yyyy'),3,2010,7644,10978);
    INSERT INTO     caln
    VALUES (To_Date('01/21/2010','mm/dd/yyyy'),2010,14,To_Date('01/21/2010','mm/dd/yyyy'),3,2010,7645,10979);
    INSERT INTO     caln
    VALUES (To_Date('01/22/2010','mm/dd/yyyy'),2010,15,To_Date('01/22/2010','mm/dd/yyyy'),3,2010,7646,10980);
    INSERT INTO     caln
    VALUES (To_Date('01/23/2010','mm/dd/yyyy'),2010,0,To_Date('01/22/2010','mm/dd/yyyy'),3,2010,7646,10981);
    INSERT INTO     caln
    VALUES (To_Date('01/24/2010','mm/dd/yyyy'),2010,0,To_Date('01/22/2010','mm/dd/yyyy'),4,2010,7646,10982);
    INSERT INTO     caln
    VALUES (To_Date('01/25/2010','mm/dd/yyyy'),2010,16,To_Date('01/25/2010','mm/dd/yyyy'),4,2010,7647,10983);
    INSERT INTO     caln
    VALUES (To_Date('01/26/2010','mm/dd/yyyy'),2010,17,To_Date('01/26/2010','mm/dd/yyyy'),4,2010,7648,10984);
    INSERT INTO     caln
    VALUES (To_Date('01/27/2010','mm/dd/yyyy'),2010,18,To_Date('01/27/2010','mm/dd/yyyy'),4,2010,7649,10985);
    INSERT INTO     caln
    VALUES (To_Date('01/28/2010','mm/dd/yyyy'),2010,19,To_Date('01/28/2010','mm/dd/yyyy'),4,2010,7650,10986);
    INSERT INTO     caln
    VALUES (To_Date('01/29/2010','mm/dd/yyyy'),2010,20,To_Date('01/29/2010','mm/dd/yyyy'),4,2010,7651,10987);
    INSERT INTO     caln
    VALUES (To_Date('01/30/2010','mm/dd/yyyy'),2010,0,To_Date('01/29/2010','mm/dd/yyyy'),4,2010,7651,10988);
    INSERT INTO     caln
    VALUES (To_Date('01/31/2010','mm/dd/yyyy'),2010,0,To_Date('01/29/2010','mm/dd/yyyy'),5,2010,7651,10989);
    INSERT INTO     caln
    VALUES (To_Date('02/01/2010','mm/dd/yyyy'),2010,21,To_Date('02/01/2010','mm/dd/yyyy'),5,2010,7652,10990);
    INSERT INTO     caln
    VALUES (To_Date('02/02/2010','mm/dd/yyyy'),2010,22,To_Date('02/02/2010','mm/dd/yyyy'),5,2010,7653,10991);
    INSERT INTO     caln
    VALUES (To_Date('02/03/2010','mm/dd/yyyy'),2010,23,To_Date('02/03/2010','mm/dd/yyyy'),5,2010,7654,10992);
    INSERT INTO     caln
    VALUES (To_Date('02/04/2010','mm/dd/yyyy'),2010,24,To_Date('02/04/2010','mm/dd/yyyy'),5,2010,7655,10993);
    INSERT INTO     caln
    VALUES (To_Date('02/05/2010','mm/dd/yyyy'),2010,25,To_Date('02/05/2010','mm/dd/yyyy'),5,2010,7656,10994);
    INSERT INTO     caln
    VALUES (To_Date('02/06/2010','mm/dd/yyyy'),2010,0,To_Date('02/05/2010','mm/dd/yyyy'),5,2010,7656,10995);
    INSERT INTO     caln
    VALUES (To_Date('02/07/2010','mm/dd/yyyy'),2010,0,To_Date('02/05/2010','mm/dd/yyyy'),6,2010,7656,10996);
    INSERT INTO     caln
    VALUES (To_Date('02/08/2010','mm/dd/yyyy'),2010,26,To_Date('02/08/2010','mm/dd/yyyy'),6,2010,7657,10997);
    INSERT INTO     caln
    VALUES (To_Date('02/09/2010','mm/dd/yyyy'),2010,27,To_Date('02/09/2010','mm/dd/yyyy'),6,2010,7658,10998);
    INSERT INTO     caln
    VALUES (To_Date('02/10/2010','mm/dd/yyyy'),2010,28,To_Date('02/10/2010','mm/dd/yyyy'),6,2010,7659,10999);
    INSERT INTO     caln
    VALUES (To_Date('02/11/2010','mm/dd/yyyy'),2010,29,To_Date('02/11/2010','mm/dd/yyyy'),6,2010,7660,11000);
    INSERT INTO     caln
    VALUES (To_Date('02/12/2010','mm/dd/yyyy'),2010,30,To_Date('02/12/2010','mm/dd/yyyy'),6,2010,7661,11001);
    INSERT INTO     caln
    VALUES (To_Date('02/13/2010','mm/dd/yyyy'),2010,0,To_Date('02/12/2010','mm/dd/yyyy'),6,2010,7661,11002);
    INSERT INTO     caln
    VALUES (To_Date('02/14/2010','mm/dd/yyyy'),2010,0,To_Date('02/12/2010','mm/dd/yyyy'),7,2010,7661,11003);
    INSERT INTO     caln
    VALUES (To_Date('02/15/2010','mm/dd/yyyy'),2010,31,To_Date('02/15/2010','mm/dd/yyyy'),7,2010,7662,11004);
    INSERT INTO     caln
    VALUES (To_Date('02/16/2010','mm/dd/yyyy'),2010,32,To_Date('02/16/2010','mm/dd/yyyy'),7,2010,7663,11005);
    INSERT INTO     caln
    VALUES (To_Date('02/17/2010','mm/dd/yyyy'),2010,33,To_Date('02/17/2010','mm/dd/yyyy'),7,2010,7664,11006);
    INSERT INTO     caln
    VALUES (To_Date('02/18/2010','mm/dd/yyyy'),2010,34,To_Date('02/18/2010','mm/dd/yyyy'),7,2010,7665,11007);
    INSERT INTO     caln
    VALUES (To_Date('02/19/2010','mm/dd/yyyy'),2010,35,To_Date('02/19/2010','mm/dd/yyyy'),7,2010,7666,11008);
    INSERT INTO     caln
    VALUES (To_Date('02/20/2010','mm/dd/yyyy'),2010,0,To_Date('02/19/2010','mm/dd/yyyy'),7,2010,7666,11009);
    CREATE TABLE ords
    (     ord_nbr          NUMBER          NOT NULL
    ,     sub_nbr          NUMBER          NOT NULL
    ,     ord_stat     VARCHAR2(2)
    ,     ord_qty          NUMBER
    ,     part_nbr     VARCHAR2(5)
         CONSTRAINT ords_pk PRIMARY KEY (ord_nbr, sub_nbr)
    INSERT INTO     ords
    VALUES (1,1,'CL',10,'PART1');
    INSERT INTO     ords
    VALUES (1,2,'CL',5,'PART1');
    INSERT INTO     ords
    VALUES (25,1,'CL',15,'PART2');
    INSERT INTO     ords
    VALUES (14,1,'OP',12,'PART3');
    INSERT INTO     ords
    VALUES (33,1,'CL',25,'PART1');
    INSERT INTO     ords
    VALUES (33,2,'CL',15,'PART1');
    INSERT INTO     ords
    VALUES (33,3,'OP',10,'PART1');
    INSERT INTO     ords
    VALUES (7,1,'PL',18,'PART2');
    INSERT INTO     ords
    VALUES (96,1,'PL',10,'PART3');
    INSERT INTO     ords
    VALUES (31,1,'CL',20,'PART2');
    CREATE TABLE oops
    (     ord_nbr          NUMBER          NOT NULL
    ,     sub_nbr          NUMBER          NOT NULL
    ,     op_nbr          VARCHAR2(4)     NOT NULL
    ,     mach_id          VARCHAR2(4)
    ,     oper_stat     VARCHAR2(2)
    ,     plan_start_dt     DATE
    ,     plsu          NUMBER
    ,     plrn          NUMBER
         CONSTRAINT ords_pk PRIMARY KEY (ord_nbr, sub_nbr, op_nbr)
    -- NOTE:
    -- for the orders with a status of 'CL' or 'PL' in the 'ords' table, I'm not bothering to put
    -- in more than two operations (though in reality more would be there) since they should be
    -- ignored in the final result anyway
    INSERT INTO     oops
    VALUES (1,1,'0010','123A','CL',TO_DATE('01/11/2010','mm/dd/yyyy'),2,0.2);
    INSERT INTO     oops
    VALUES (1,1,'0015','259B','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.15);
    INSERT INTO     oops
    VALUES (1,2,'0010','123A','CP',TO_DATE('01/11/2010','mm/dd/yyyy'),2,0.2);
    INSERT INTO     oops
    VALUES (1,2,'0015','259B','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.15);
    INSERT INTO     oops
    VALUES (25,1,'0005','123A','CP',TO_DATE('01/18/2010','mm/dd/yyyy'),2,0.25);
    INSERT INTO     oops
    VALUES (25,1,'0030','110C','CL',TO_DATE('01/19/2010','mm/dd/yyyy'),4,0.1);
    INSERT INTO     oops
    VALUES (14,1,'0010','127A','CP',TO_DATE('01/11/2010','mm/dd/yyyy'),2,0.25);
    INSERT INTO     oops
    VALUES (14,1,'0025','110C','CL',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
    INSERT INTO     oops
    VALUES (14,1,'0040','050C','CP',TO_DATE('01/13/2010','mm/dd/yyyy'),1.3,0.15);
    INSERT INTO     oops
    VALUES (14,1,'0050','220B','WK',TO_DATE('01/14/2010','mm/dd/yyyy'),4,0.25);
    INSERT INTO     oops
    VALUES (14,1,'0065','242B','AV',TO_DATE('01/18/2010','mm/dd/yyyy'),1.5,0.1);
    INSERT INTO     oops
    VALUES (14,1,'0067','150G','NA',TO_DATE('01/19/2010','mm/dd/yyyy'),2,0.1);
    INSERT INTO     oops
    VALUES (14,1,'0100','250G','NA',TO_DATE('01/20/2010','mm/dd/yyyy'),2.1,0.2);
    INSERT INTO     oops
    VALUES (33,1,'0010','123A','CL',TO_DATE('01/11/2010','mm/dd/yyyy'),1.9,0.2);
    INSERT INTO     oops
    VALUES (33,1,'0015','259B','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
    INSERT INTO     oops
    VALUES (33,2,'0010','123A','CL',TO_DATE('01/11/2010','mm/dd/yyyy'),1.9,0.2);
    INSERT INTO     oops
    VALUES (33,2,'0015','259B','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
    INSERT INTO     oops
    VALUES (33,3,'0010','123A','CL',TO_DATE('01/11/2010','mm/dd/yyyy'),1.9,0.2);
    INSERT INTO     oops
    VALUES (33,3,'0015','259B','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
    INSERT INTO     oops
    VALUES (33,3,'0020','220B','NA',TO_DATE('01/12/2010','mm/dd/yyyy'),1.7,0.15);
    INSERT INTO     oops
    VALUES (33,3,'0030','150G','NA',TO_DATE('01/13/2010','mm/dd/yyyy'),1.3,0.05);
    INSERT INTO     oops
    VALUES (33,3,'0055','150G','NA',TO_DATE('01/15/2010','mm/dd/yyyy'),2.1.,0.1);
    INSERT INTO     oops
    VALUES (7,1,'0005','123A','NA',TO_DATE('01/11/2010','mm/dd/yyyy'),2,0.2);
    INSERT INTO     oops
    VALUES (7,1,'0030','110C','NA',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.15);
    INSERT INTO     oops
    VALUES (96,1,'0010','127A','NA',TO_DATE('01/11/2010','mm/dd/yyyy'),2,0.25);
    INSERT INTO     oops
    VALUES (96,1,'0025','110C','NA',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
    INSERT INTO     oops
    VALUES (31,1,'0005','123A','CL',TO_DATE('01/11/2010','mm/dd/yyyy'),1.9,0.2);
    INSERT INTO     oops
    VALUES (31,1,'0030','110C','CP',TO_DATE('01/12/2010','mm/dd/yyyy'),1,0.1);
    CREATE TABLE mach
    (     mach_id          VARCHAR2(4)     NOT NULL
    ,     desc_short     VARCHAR2(9)     
    ,     group          VARCHAR2(7)
         CONSTRAINT ords_pk PRIMARY KEY (mach_id)
    INSERT INTO     mach
    VALUES     ('123A','desc here','GROUPH1');
    INSERT INTO     mach
    VALUES     ('259B','desc here','GROUPH2');
    INSERT INTO     mach
    VALUES     ('110C','desc here','GROUPJ1');
    INSERT INTO     mach
    VALUES     ('050C','desc here','GROUPK2');
    INSERT INTO     mach
    VALUES     ('220B','desc here','GROUPH2');
    INSERT INTO     mach
    VALUES     ('242B','desc here','GROUPH2');
    INSERT INTO     mach
    VALUES     ('150G','desc here','GROUPL1');
    INSERT INTO     mach
    VALUES     ('250G','desc here','GROUPL2');
    INSERT INTO     mach
    VALUES     ('242B','desc here','GROUPH2');

  • Help with some simple coding

    Hello
    I am very new to Java and am currently studying a course in the language.
    I am working through a tutorial at the moment and a question has been asked and I am struggling a bit
    I have been given the code to a program that creates a window with a ball bouncing around inside the window.
    There are 2 classes (code below) - Call class - this contains all the code need to create the ball and BallWorld Class (the main Class) this create the window and moves the ball, it also detects if the ball hits the edge of the window, whne this happens it redirects the ball. I understand how all this code works
    I have been asked the following:-
    Rather than testing whether or not the ball has hit the wall in the nmain program, we could use inhertitance to provide a specialized forom of Ball. Create a class BoundedBall that inherits from the class Ball. The constructor for this class should provide the height and width of the window, which should be maintained as data fields in the class, rewrite the move method so that the ball moves outside the bound, it automatically reflects its direction. Finally rewrite the BallWorld class to use an instance of BoundedBall rather than ordianary Ball, and elimiante the bounds test in the main program.
    I am having trouble with this and I can not get my code to work, I think I may be going in completly the wrong direction with the code can sombody please provide me with a simple working code for both the BoundedBall and ammended BallWorld class, as this will help me understand whare I am going wrong
    Ball class
    //a generic round colored object that moves
    import java.awt.*;
    public class Ball {
    public Ball (Point lc, int r) {     //constructor for new ball
         //ball centre at point loc, radius rad
         loc = lc;
         rad = r;
    protected Point loc; //position in window
    protected int rad; //radius of ball
    protected double changeInX = 0.0; //horizontal change in ball position in one cycle
    protected double changeInY = 0.0; //vertical change in ball position in one cycle
    protected Color color = Color.blue; //colour of ball
    //methods that set attributes of ball
    public void setColor(Color newColor) {color = newColor;}
    public void setMotion(double dx,double dy)
    {changeInX = dx; changeInY = dy;}
    //methods that access attributes of ball
    public int radius() {return rad;}
    public Point location() {return loc;}
    //methods to reverse motion of the ball
    public void reflectVert(){ changeInY = -changeInY; }
    public void reflectHorz(){ changeInX = -changeInX; }
    //methods to move the ball
    public void moveTo(int x, int y) {loc.move(x,y);}
    public void move(){loc.translate((int)changeInX, (int)changeInY);}
    //method to display ball
    public void paint (Graphics g) {
    g.setColor(color);
    g.fillOval(loc.x-rad, loc.y-rad, 2*rad, 2*rad);
    BallWorld class
    //A bouncing ball animation
    import java.awt.*;          //import the awt package
    import javax.swing.JFrame;     //import the JFrame class from the swing package
    public class BallWorld extends JFrame{
         public static void main (String [] args){
              BallWorld world = new BallWorld(Color.red);
              world.show();
    for(int i = 0; i < 1000; i++) world.run();
    System.exit(0);
         public static final int FrameWidth = 600;
         public static final int FrameHeight = 400;
    private Ball aBall = new Ball(new Point (50,50),20);
         private BallWorld(Color ballColor) {     //constructor for new window
              //resize frame, initialize title
         setSize(FrameWidth, FrameHeight);
         setTitle("Ball World");
    //set colour and motion of ball
         aBall.setColor(ballColor);
         aBall.setMotion(3.0, 6.0);
         public void paint (Graphics g) {
    //first draw the ball
    super.paint(g);
         aBall.paint(g);
    public void run(){
              //move ball slightly
         aBall.move();
    Point pos =aBall.location();
    if ((pos.x < aBall.radius()) ||
    (pos.x > FrameWidth - aBall.radius()))
    aBall.reflectHorz();
    if ((pos.y < aBall.radius()) ||
    (pos.y > FrameHeight - aBall.radius()))
    aBall.reflectVert();
    repaint();
    try{
    Thread.sleep(50);
    } catch(InterruptedException e) {System.exit(0);}

    Here - you can study this :0))import java.awt.*;
    import javax.swing.*;
    public class MovingBall extends JFrame {
       mapPanel map   = new mapPanel();
       public MovingBall() {
          setBounds(10,10,400,300);
          setContentPane(map);
       public class mapPanel extends JPanel {
          Ball ball  = new Ball(this);
          public void paintComponent(Graphics g) {
            super.paintComponent(g);
            ball.paint(g);
    public class Ball extends Thread {
       mapPanel map;
       int x  = 200, y = 20, xi = 1, yi = 1;
    public Ball(mapPanel m) {
       map = m;
       start();
    public synchronized void run(){
       while (true) {
          try{
            sleep(10);
          catch(InterruptedException i){
            System.out.print("Interrupted: ");
          move();
    public void move() {
        map.repaint(x-1,y-1,22,22);
           if (x > map.getWidth()-20 || x < 0)  xi = xi*-1;
           if (y > map.getHeight()-20 || y < 0) yi = yi*-1;
           x = x + xi;
           y = y + yi;
           map.repaint(x-1,y-1,22,22);
        public void paint(Graphics g) {
           Graphics2D g2 = (Graphics2D)g;
           g2.setColor(Color.red);
           g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                               RenderingHints.VALUE_ANTIALIAS_ON);
           g2.fillOval(x,y,20,20);
           g2.dispose();
    public static void main(String[] args) {
       new MovingBall().show();
    }

  • Help with some ACLs for VACL

    I need some help with acls for a vacl. Goal - have the 1.1.1.0/24 subnet only communicate with certain IP.
    So, they cannot get out to anywhere else and no one except that IP can get in.
    Here is what I have so far:
    access-list acl1 permit tcp 1.1.1.0 255.255.255.0 host 1.2.3.4
    access-list acl1 permit tcp host 1.2.3.4 1.1.1.0 255.255.255.0
    access-list acl1 ip 1.1.1.0 255.255.255.0 any log
    access-list acl1 ip deny any any log
    vlan access-map vacl1 1
    match ip address set acl1
    action forward
    exit
    vlan filter vacl1 vlan-list 11
    Will this work as I expect it to?
    Thanks for any help

    Hi,
    I implemented this on my 6509 and it didn't work. I even modified it to look like the following and it didn't work (I could RDP to one of the boxes on that the subnet).
    ip access-list extended rapt_acl
    deny ip any any
    deny tcp any any
    deny udp any any
    vlan access-map rapt_vacl 10
    match ip address set rapt_acl
    action forward
    vlan filter rapt_vacl vlan-list 90
    Any thoughts what I may be missing?

  • Need a little help with some errors.

    Receiving some errors..
    btn2.addActionListener(new ActionListener() {
    and also
    frame.setLocation(400,400);
    frame.setVisible(true);
    }<<~~has 2 errors here...
    Both above have class or interface expected errors..clueless on what i'm missing at the moment.
    Anyone mind pointing out what {'s and }'s i'm missing?
         btn1.addActionListener(new ActionListener() {
                             public void actionPerformed(ActionEvent evt) {
                                  btn1actions();
              private void btn1actions() {
                   if (radio1.isSelected()) System.out.println("Radio Button 1 is selected.");
                   if (radio2.isSelected()) System.out.println("Radio Button 2 is selected.");
         btn2.addActionListener(new ActionListener() {
                                       public void actionPerformed(ActionEvent evt) {
                                            btn2actions();
                        private void btn2actions() {
                             if (radio1.isSelected()) System.out.println("Radio Button 1 is selected.");
                             if (radio2.isSelected()) System.out.println("Radio Button 2 is selected.");
                   btn3.addActionListener(new ActionListener() {
                                       public void actionPerformed(ActionEvent evt) {
                                            btn1actions();
                        private void btn3actions() {
                             txt1.setText("");
                             txt1.requestFocus();
    public static void main(String[] args) {
        Test2 frame = new Test2();
        frame.setTitle("Test Frame");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 300);
        frame.setLocation(400,400);
        frame.setVisible(true);
    }

    All my code..finally posted...just need help with more errors.
    F:\DocumentsTest2.java:169: ';' expected
              btn1.addActionListener(new ActionListener()) {
    ^
    F:\Documents\Test2.java:176: illegal start of expression
              private void btn1actions() {
    ^
    F:\Documents\Test2.java:191: illegal start of expression
              private void btn2actions() {
    ^
    F:\Documents\.java:202: illegal start of expression
              private void btn3actions() {
    ^
    4 errors
    Tool completed with exit code 1
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Test2 extends JFrame{
         static JButton btn1,btn2,btn3;
         static JTextField txt1;
         static JRadioButton radio1,radio2;
           public Test2() {
             Container container = getContentPane();
             container.setLayout(new BorderLayout());
              //Create Panels
                JPanel Panel1 = new JPanel();
                JPanel Panel2 = new JPanel();
                JPanel Panel3 = new JPanel();
                JPanel Panel4 = new JPanel();
                JPanel Panel5 = new JPanel();
                JPanel Panel6 = new JPanel();
                JPanel Panel7 = new JPanel();
                JPanel Panel8 = new JPanel();
                JPanel Panel9 = new JPanel();
                JPanel Panel10 = new JPanel();
              //Set Layout for Panels
              Panel3.setLayout(new BorderLayout());
              Panel4.setLayout(new BorderLayout());
              Panel5.setLayout(new BorderLayout());
              Panel6.setLayout(new BorderLayout());
              Panel10.setLayout(new BorderLayout());
              //Create the Various Fonts and Colors for this GUI
              Font font1 = new Font("SansSerif", Font.BOLD, 20);
              Font font2 = new Font("Serif", Font.PLAIN, 15);
              Color color1 = new Color(3,15,125);//A Dark Blue Color
              Color color2 = new Color(201,29,10);//A Red Color
              Color color3 = new Color(127,127,127);//A Grey Color
              //Create Buttons and Labels
             btn1 = new JButton("Submit");
             btn2 = new JButton("Display Schedule");
             btn3 = new JButton("Enter New Name");
             JLabel label1 = new JLabel("Student Name");
             JLabel label2 = new JLabel("Course Number");
              JLabel label3 = new JLabel("Welcome to the Java Community College");
              JLabel label4 = new JLabel("Registration System!");
              //Declare Text Field For Entering Student Names
              txt1 = new JTextField(15);
              //"Put Course Number from another Method Here"
              String[] courseStrings = { "CISM2230 A", "CISM2230 B", "CISM1110 A", "CISM1110 B", "CISM1120 A", "CISM1120 B" };
              JComboBox Combo1 = new JComboBox(courseStrings);
              //Declare Radio Buttons for Add and Drop Course
              radio1 = new JRadioButton("Add a Course", false);
              radio2 = new JRadioButton("Drop a Course", false);
              ButtonGroup radioButtons = new ButtonGroup();
              radioButtons.add(radio1);
              radioButtons.add(radio2);
              //Panel 10 is the Main Displaying Panel
              Panel10.add(Panel3, BorderLayout.NORTH);
              Panel10.add(Panel4, BorderLayout.CENTER);
              Panel10.add(Panel8, BorderLayout.SOUTH);
              //Panel 3 Used to Display Label 3 and 4 using Panels 1 and 2
              Panel3.add(Panel1, BorderLayout.NORTH);
              Panel3.add(Panel2, BorderLayout.CENTER);
              Panel1.add(label3);
             Panel2.add(label4);
              //Panel 4 Used to Display Student Name, Txt1, Course Number, Combo Box and Radio Buttons
             Panel5.add(label1, BorderLayout.NORTH);
             Panel5.add(txt1, BorderLayout.CENTER);
             Panel6.add(label2, BorderLayout.NORTH);
              Panel6.add(Combo1, BorderLayout.CENTER);
              Panel7.add(radio1, BorderLayout.NORTH);
              Panel7.add(radio2, BorderLayout.CENTER);
              Panel4.add(Panel5, BorderLayout.NORTH);
              Panel4.add(Panel6, BorderLayout.CENTER);
              Panel4.add(Panel7, BorderLayout.SOUTH);
              //Panel 8 Used to Display the Buttons
              Panel9.add(btn1, BorderLayout.CENTER);
              Panel9.add(btn2, BorderLayout.CENTER);
              Panel9.add(btn3, BorderLayout.SOUTH);
              Panel8.add(Panel9, BorderLayout.CENTER);
              //Setting Background, ForeGround and Font of all Text.
             Panel1.setBackground(color3);
             Panel2.setBackground(color3);
             Panel3.setBackground(color3);
             Panel4.setBackground(color3);
             Panel5.setBackground(color3);
             Panel6.setBackground(color3);
             Panel7.setBackground(color3);
             Panel8.setBackground(color3);
             Panel9.setBackground(color3);
             Panel10.setBackground(color3);
             btn1.setBackground(color3);
             btn2.setBackground(color3);
             btn3.setBackground(color3);
             radio1.setBackground(color3);
             radio2.setBackground(color3);
             btn1.setFont(font2);
             btn2.setFont(font2);
             btn3.setFont(font2);
             Combo1.setFont(font2);
             Combo1.setBackground(color3);
             Combo1.setForeground(color1);
             label1.setFont(font2);
             label2.setFont(font2);
             label3.setFont(font1);
             label4.setFont(font1);
             label1.setForeground(color2);
             label2.setForeground(color2);
             label3.setForeground(color1);
             label4.setForeground(color1);
             container.add(Panel10);
              //Setting Keyboard Shortcuts to Radio Buttons and Regular Buttons
              btn1.setMnemonic('S');
              btn2.setMnemonic('D');
              btn3.setMnemonic('E');
              radio1.setMnemonic('A');
              radio2.setMnemonic('C');
              //ActionListener
              btn1.addActionListener(new ActionListener()) {
                   public void actionPerformed(ActionEvent evt) {
                        btn1actions();
              private void btn1actions() {
                   if (radio1.isSelected()){ System.out.println("Radio Button 1 is selected. Button 1")};
                   if (radio2.isSelected()){ System.out.println("Radio Button 2 is selected. Button 1")};
              btn2.addActionListener(new ActionListener()) {
                   public void actionPerformed(ActionEvent evt) {
                                            btn2actions();
              private void btn2actions() {
                   if (radio1.isSelected()) System.out.println("Radio Button 1 is selected(Button 2).");
                   if (radio2.isSelected()) System.out.println("Radio Button 2 is selected.Button 2");
              btn3.addActionListener(new ActionListener()) {
                   public void actionPerformed(ActionEvent evt) {
                        btn1actions();
              private void btn3actions() {
                   txt1.setText("");
                   txt1.requestFocus();
         public static void main(String[] args) {
             JavaCollegeTest2 frame = new JavaCollegeTest2();
             frame.setTitle("Project 4");
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             frame.setSize(400, 300);
             frame.setLocation(400,400);
             frame.setVisible(true);
    }

  • Urgeant help with a java script

    I really nead some help with an essay that i have for tommorow. Ok it goes like this: I have to build in java and with help of the awt library a proper interface that whill allow people to make reservation for tickets in a cinema. With the proper graphics the interface must allow the users to chose time , movie , date , and a spot in the cinema! the spot should be selected from a "picture" (like a diagramm or something) of the cinema which will be displayed on the screen...
    thanx in advance!!!

    What do you need "help" with? No one is going to do your homework for you here. If you have a specific question or problem, feel free to ask. You have to get started yourself though.. Thought college was going to be easy?

  • Please help with some problems with my N96

    Hi there,
    I have spent a fair bit of money on my Nokia N96 and unfortunately it is out of its warranty etc.And I have few issues with it.
    So can anyone advise me as to how about I can overcome some issues:
    Firstly, in my message inbox only the numbers display instead of the names (e.g.. +447770260.. Instead of Peter), has anyone had this issue or can help with this? I have gone into the message setting and nothing sticks out and says click me for number or name to be displayed.
    Secondly, the vibrating device doesn't seem to work at all some days and other days it seems fine? Is this a common fault or is it my phone. Also, is there anywhere on the phone to adjust the vibrating force which maybe getting in the way?
    Many thanks for any advise or for merely looking, and grateful for any help.
    Adam  

    /discussions/board/message?board.id=smartphones&message.id=112590&query.id=115949#M112590
    read the above thread in regards to the contacts issue. it is a common issue for the s60 phones no fix as yet and it has been few years now.
    there is no way you can adjust the vibration force. its either on or off. the vibration should work at all times if you have it set to work. it should not be random. you might want to take it to nokia care for them to have a look at it despite the fact that it is out of warranty.  
    You know what I love about you the most, the fact that you are not me ! In love with technology and all that it can offer. Join me in discovery....

Maybe you are looking for