Help me to Edit this program

Hi All,
Can anyone kind enought to help me to add the START and STOP button for this "bouncing ball" program that i got from the internet ? Below is the java coding.
import java.awt.*;
import java.applet.*;
class Obstacle
     public Rectangle r;
     Graphics g;
     public Obstacle(int x,int y,int w,int h)
          r=new Rectangle(x,y,w,h);
     public void paint(Graphics gr)
          g=gr;
          g.setColor(Color.lightGray);
          g.draw3DRect(r.x,r.y,r.width,r.height,true);
class CollideBall
     int width, height;
     public static final int diameter=20;
     //coordinates and value of increment
     double x, y, xinc, yinc, coll_x, coll_y;
     boolean collide;
     Color color;
     Graphics g;
     Rectangle r;
     //the constructor
     public CollideBall(int w, int h, int x, int y, double xinc, double yinc, Color c)
          width=w;
          height=h;
          this.x=x;
          this.y=y;
          this.xinc=xinc;
          this.yinc=yinc;          
          color=c;          
          r=new Rectangle(150,80,130,90);
     public double getCenterX() {return x+diameter/2;}
     public double getCenterY() {return y+diameter/2;}
     public void alterRect(int x, int y, int w, int h)
          r.move(x,y);
          r.resize(w,h);
     public void move()
          if (collide)
               double xvect=coll_x-getCenterX();
               double yvect=coll_y-getCenterY();
               if((xinc>0 && xvect>0) || (xinc<0 && xvect<0))
                    xinc=-xinc;
               if((yinc>0 && yvect>0) || (yinc<0 && yvect<0))
                    yinc=-yinc;
               collide=false;
          x+=xinc;
     y+=yinc;
          //when the ball bumps against a boundary, it bounces off
     if(x<6 || x>width-diameter)
          xinc=-xinc;
               x+=xinc;
          if(y<6 || y>height-diameter)
          yinc=-yinc;
               y+=yinc;
          //cast ball coordinates to integers
          int x=(int)this.x;
          int y=(int)this.y;
          //bounce off the obstacle
          //left border
          if(x>r.x-diameter&&x<r.x-diameter+7&&xinc>0&&y>r.y-diameter&&y<r.y+r.height)
          xinc=-xinc;
               x+=xinc;
          //right border
          if(x<r.x+r.width&&x>r.x+r.width-7&&xinc<0&&y>r.y-diameter&&y<r.y+r.height)
          xinc=-xinc;
               x+=xinc;
          //upper border
          if(y>r.y-diameter&&y<r.y-diameter+7&&yinc>0&&x>r.x-diameter&&x<r.x+r.width)
               yinc=-yinc;
               y+=yinc;
          //bottom border
          if(y<r.y+r.height&&y>r.y+r.height-7&&yinc<0&&x>r.x-diameter&&x<r.x+r.width)
               yinc=-yinc;
               y+=yinc;
     public void hit(CollideBall b)
          if(!collide)
               coll_x=b.getCenterX();
               coll_y=b.getCenterY();
               collide=true;
     public void paint(Graphics gr)
          g=gr;
          g.setColor(color);
          //the coordinates in fillOval have to be int, so we cast
          //explicitly from double to int
          g.fillOval((int)x,(int)y,diameter,diameter);
          g.setColor(Color.white);
          g.drawArc((int)x,(int)y,diameter,diameter,45,180);
          g.setColor(Color.darkGray);
          g.drawArc((int)x,(int)y,diameter,diameter,225,180);
public class BouncingBalls extends Applet implements Runnable
     Thread runner;     
     Image Buffer;
Graphics gBuffer;          
CollideBall ball[];
     Obstacle o;
//how many balls?
static final int MAX=10;
     boolean intro=true,drag,shiftW,shiftN,shiftE,shiftS;
     boolean shiftNW,shiftSW,shiftNE,shiftSE;
     int xtemp,ytemp,startx,starty;
     int west, north, east, south;
     public void init()
          Buffer=createImage(size().width,size().height);
          gBuffer=Buffer.getGraphics();                         
          ball=new CollideBall[MAX];
          int w=size().width-5;
          int h=size().height-5;          
          //our balls have different start coordinates, increment values
          //(speed, direction) and colors
          ball[0]=new CollideBall(w,h,50,20,1.5,2.0,Color.orange);
ball[1]=new CollideBall(w,h,60,210,2.0,-3.0,Color.red);
ball[2]=new CollideBall(w,h,15,70,-2.0,-2.5,Color.pink);
ball[3]=new CollideBall(w,h,150,30,-2.7,-2.0,Color.cyan);
ball[4]=new CollideBall(w,h,210,30,2.2,-3.5,Color.magenta);
          ball[5]=new CollideBall(w,h,360,170,2.2,-1.5,Color.yellow);
          ball[6]=new CollideBall(w,h,210,180,-1.2,-2.5,Color.blue);
          ball[7]=new CollideBall(w,h,330,30,-2.2,-1.8,Color.green);
          ball[8]=new CollideBall(w,h,180,220,-2.2,-1.8,Color.black);
          ball[9]=new CollideBall(w,h,330,130,-2.2,-1.8,Color.gray);
          o=new Obstacle(150,80,130,90);
          west=o.r.x;
          north=o.r.y;
          east=o.r.x+o.r.width;
          south=o.r.y+o.r.height;
     public void start()
          if (runner == null)
               runner = new Thread (this);
               runner.start();
public void stop()
          if (runner != null)
     runner.stop();
     runner = null;
     public void run()
          while(true)
               Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
               try {runner.sleep(15);}
     catch (Exception e) { }               
               //move our balls around
               for(int i=0;i<MAX;i++)
                    ball.move();
               handleCollision();
               repaint();     
     boolean collide(CollideBall b1, CollideBall b2)
          double wx=b1.getCenterX()-b2.getCenterX();
          double wy=b1.getCenterY()-b2.getCenterY();
          //we calculate the distance between the centers two
          //colliding balls (theorem of Pythagoras)
          double distance=Math.sqrt(wx*wx+wy*wy);
          if(distance<b1.diameter)                         
               return true;          
               return false;     
     void changeCursor(int x, int y)
          Rectangle r=new Rectangle(o.r.x+1,o.r.y+1,o.r.width-1,o.r.height-1);
          Frame BrowserFrame;
          Component ParentComponent;
          ParentComponent = getParent();
          while ( ParentComponent != null &&
          !(ParentComponent instanceof Frame))           
          ParentComponent = ParentComponent.getParent();          
          BrowserFrame = (Frame) ParentComponent;
          if(shiftNW||shiftSE)
               BrowserFrame.setCursor(Frame.SE_RESIZE_CURSOR);
          else if(shiftNE||shiftSW)
               BrowserFrame.setCursor(Frame.SW_RESIZE_CURSOR);
          else if(shiftW)
               BrowserFrame.setCursor(Frame.W_RESIZE_CURSOR);
          else if(shiftN)
               BrowserFrame.setCursor(Frame.N_RESIZE_CURSOR);
          else if(shiftE)
               BrowserFrame.setCursor(Frame.W_RESIZE_CURSOR);
          else if(shiftS)
               BrowserFrame.setCursor(Frame.N_RESIZE_CURSOR);
          else if(r.inside(x,y))
               BrowserFrame.setCursor(Frame.MOVE_CURSOR);
          else
               BrowserFrame.setCursor(Frame.DEFAULT_CURSOR);
     public boolean mouseMove(Event evt,int x,int y)
          //the corner areas of the obstacle
          Rectangle nw,sw,ne,se;
          nw=new Rectangle(o.r.x-2,o.r.y-2,4,4);
          if(nw.inside(x,y))
               shiftNW=true;
          else shiftNW=false;
          sw=new Rectangle(o.r.x-2,o.r.y+o.r.height-2,4,4);
          if(sw.inside(x,y))
               shiftSW=true;
          else shiftSW=false;
          ne=new Rectangle(o.r.x+o.r.width-2,o.r.y-2,4,4);
          if(ne.inside(x,y))
               shiftNE=true;
          else shiftNE=false;
          se=new Rectangle(o.r.x+o.r.width-2,o.r.y+o.r.height-2,4,4);
          if(se.inside(x,y))
               shiftSE=true;
          else shiftSE=false;          
          if(x>o.r.x-2&&x<o.r.x+2&&y>o.r.y&&y<o.r.y+o.r.height)
               shiftW=true;
          else shiftW=false;
          if(x>o.r.x+o.r.width-2&&x<o.r.x+o.r.width+2
               &&y>o.r.y&&y<o.r.y+o.r.height)
               shiftE=true;
          else shiftE=false;
          if(y<o.r.y+2&&y>o.r.y-2&&x>o.r.x&&x<o.r.x+o.r.width)
               shiftN=true;
          else shiftN=false;
          if(y>o.r.y+o.r.height-2&&y<o.r.y+o.r.height+2
               &&x<o.r.x+o.r.width)
               shiftS=true;
          else shiftS=false;
          changeCursor(x,y);
          return true;
     public boolean mouseDown(Event evt,int x,int y)
          Rectangle r=new Rectangle(o.r.x+2,o.r.y+2,o.r.width-4,o.r.height-4);
          if(r.inside(x,y))
               drag=true;
               startx=x;
               starty=y;
               xtemp=o.r.x;
               ytemp=o.r.y;
          else drag=false;
          changeCursor(x,y);
          return true;
     public boolean mouseDrag(Event evt,int x,int y)
          intro=false;
          Rectangle bounds=new Rectangle(5,5,size().width-5,size().height-5);
          int endx, endy;          
          endx=x-startx;
          endy=y-starty;     
          //disable mouse actions past boundaries
          if(x<5)x=5;
          if(y<5)y=5;
          if(x>bounds.width)x=bounds.width;
          if(y>bounds.height)y=bounds.height;
          if(drag)
               //disallow to move past border
               int ox=endx+xtemp;
               int oy=endy+ytemp;
               if(ox<5)ox=5;
               if(oy<5)oy=5;
               if(ox>bounds.width-o.r.width)
                    ox=bounds.width-o.r.width;
               if(oy>bounds.height-o.r.height)
                    oy=bounds.height-o.r.height;     
               o.r.move(ox,oy);                    
               west=o.r.x;
               north=o.r.y;
               east=o.r.x+o.r.width;
               south=o.r.y+o.r.height;                              
          else
               if(shiftNW){west=x;north=y;}
               else if(shiftNE){east=x;north=y;}
               else if(shiftSW){west=x;south=y;}
               else if(shiftSE){east=x;south=y;}
               else if(shiftW)west=x;
               else if(shiftE)east=x;
               else if(shiftN)north=y;
               else if(shiftS)south=y;                                                       
               //disallow resizing below 40*40
               int MIN=40;
               if(east-west<MIN)
                    //shiftNW=shiftNE=shiftSW=shiftSE=shiftW=shiftE=false;
                    if(shiftW||shiftNW||shiftSW)
                         west=east-MIN;
                    if(shiftE||shiftNE||shiftSE)
                         east=west+MIN;
               if(south-north<MIN)
                    //shiftNW=shiftNE=shiftSW=shiftSE=shiftN=shiftS=false;
                    if(shiftN||shiftNW||shiftNE)
                         north=south-MIN;
                    if(shiftS||shiftSE||shiftSW)
                         south=north+MIN;
          //report altering of obstacle to ball objects and obstacle
          for(int i=0;i<MAX;i++)
               ball[i].alterRect(o.r.x,o.r.y,o.r.width,o.r.height);
          o.r.move(west,north);
          o.r.resize(east-west, south-north);
          changeCursor(x,y);
          return true;
     private void handleCollision()
          //we iterate through all the balls, checking for collision
          for(int i=0;i<MAX;i++)
               for(int j=0;j<MAX;j++)
                         if(i!=j)
                              if(collide(ball[i], ball[j]))
                                   ball[i].hit(ball[j]);
                                   ball[j].hit(ball[i]);
     public void update(Graphics g)
          paint(g);
     public void paint(Graphics g)
          gBuffer.setColor(Color.lightGray);
          gBuffer.fillRect(0,0,size().width,size().height);
          gBuffer.draw3DRect(5,5,size().width-10,size().height-10,false);               
          //paint the obstacle rectangle
          o.paint(gBuffer);
          //paint our balls
          for(int i=0;i<MAX;i++)
                    ball[i].paint(gBuffer);     
          if(intro)
               gBuffer.setColor(Color.red);
               gBuffer.setFont(new Font("Helvetica", Font.PLAIN, 12));               
               gBuffer.drawString("You can move and resize the rectangle!",20,30);
               gBuffer.setFont(new Font("Helvetica", Font.PLAIN, 10));
          g.drawImage (Buffer,0,0, this);                    

Hello, please use code tags next time you post code. You can do so by adding [code] [/code] round blocks of code. So
[code]
class Code {
private static final String codeHere = "code here";
[/code]
will be rendered as
class Code {
  private static final String codeHere = "code here";
We will not do your homework for you, we will however help when you are stuck and point you in the right direction. So what have you tried? What happened?
Don't know how to begin? What makes the ball move?

Similar Messages

  • Which is the best way to edit this program and make it read 1 sample from each channel?

    The original program was made with Traditional NI-DAQ. I have edit it to DAQmx the best that i could. The program it's already applying the voltages that are generate in the code(Daqmx Write.vi). But i'm having problems with acquiring voltages it's giving me rare readings(Daqmx Read.vi)  i don't know if i have to make a (Daqmx Start Task.vi) for each channel in the program or if i can make it work with a single one. Notice i have not make many significant changes because this program is already running in another lab and they give to us the program so we didn't have so much problems but instead of getting the BNC-2090 they got the BNC-2090A that uses DAQmx instead of Traditional. So anyone can help?
    Solved!
    Go to Solution.
    Attachments:
    2 Lock-In, 2 V Amp, Vd Amp - 090702(MTP).vi ‏100 KB
    2 Lock-In, 2 V Amp, Vd Amp - 090702(MTP)new.vi ‏107 KB

    A BNC-2090 is just a connector block.  It has no effect on whether you need to use DAQmx or traditional DAQ.  That is determined by the DAQ card you are connecting the terminal block too.
    You might be referring to this document Differences Between the BNC-2090 and BNC-2090A Connector Blocks, but that is just saying to the change in the labels of the terminal block to accurately reflect the newer DAQ cards.
    What problems are you having with the new VI you just posted?  Are you getting an erro rmessage?  I don't know what "rare readings" mean.
    You really shoud look at some DAQmx examples in the example finder.  Some problems you are having is that your DAQ blocks are all sort of disconnected.  Generally, you should be connecting the purple wire from your create task function, throught the start, read or write, and on to the close task.  Many of your DAQ functions are just sitting out there on little islands right now.  You should also be connecting up your error wires.
    With DAQmx, you should be combining all of your analog channels in a single task.  It should look something like Dev0/AI0..AI7.  Then use an N channel 1 sample DAQmx read to get an array of the readings, which you can then use index array to break apart.
    Other things you should do is replace the stacked sequence structures with flat sequence structures.  Turn on AutoGrow for some of your structures such as the loops.  In the end, you might find you can eliminate some sequence structures.

  • Help me out with this program

    hi,
    I am trying to make a login program that connects to an access database with table 'PASSWORD' containing the username and the password.
    I have written the program but i could not continue as i am in fix with few errors which it is giving can anyone help me in doing the coding of this program..
    //***************** Create a DSN named "Login" from the Control Panel ODBC ********//
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.plaf.metal.*;
    import java.sql.*;
    public class Screen extends JFrame implements ActionListener
    JTextField txtuser;
         JPasswordField txtpass;
    public Screen()
    JPanel contentpane=(JPanel)getContentPane();
    contentpane.setLayout(new FlowLayout());
    JLabel username= new JLabel("UserName:");
    JTextField txtuser= new JTextField(18);
    JPassword Field JLabel password= new JLabel("Password:");
              txtpass = new JPasswordField(18);
              txtpass.setEchoChar('*');
    JButton login= new JButton("Login");
              login.addActionListener(this);
              login.setActionCommand("Login");
         JButton cancel= new JButton("Cancel");
              cancel.addActionListener(this);
              cancel.setActionCommand("Cancel");
    contentpane.add(username);
    contentpane.add(txtuser);
    contentpane.add(password);
    contentpane.add(txtpass);
    contentpane.add(login);
    contentpane.add(cancel);
    addWindowListener(new Screen.WindowEventHandler());
    static public void main(String[] args)
    Screen scr= new Screen();
    scr.setSize(new Dimension(300,140));
    scr.setTitle("Login Screen");
    scr.setVisible(true);
    public void actionPerformed(ActionEvent e)
         Connection con = null;
         String query;
         String id=null,pwd=null;
         ResultSet rs;
         Statement stmt;
    /* U Need to Get the Text Box values of ID and Password into "id" and "pwd" variables,
    I tried to Do this as follows , but no success ..I havent worked on SWING class before.
    so u check out the method required to get the TEXT box values into these variables...*/
    id=txtuser.getText();
    pwd=txtpass.getText();
         query = "Select Password from user where ID='"+id+"'";
    if (e.getActionCommand()=="Login")
    try
              Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
    catch( ClassNotFoundException ee)
              ee.printStackTrace();
    // Here i m using a DSN "Doctor" if u create other than this name then Specify the name of the DSN here in place of "Login"
         String dsn = "jdbc:odbc:doctor";
    try
                   con = DriverManager.getConnection(dsn);
         catch(Exception ex)
              System.out.println("Exception in Connection " + ex);
    try
         stmt = con.createStatement();
         rs=stmt.executeQuery(query);
    if(pwd==rs.getString(1))
                   System.out.println("This user is valid");
                        //** VALID USER , DO AS PER UR REQUIREMENT
              else
                   System.out.println("This user is invalid");
                   //INVALID USER , DO AS PER UR REQUIREMENT
    rs.close();
         stmt.close();
    catch(Exception ee)
              ee.printStackTrace();
    if (e.getActionCommand()=="Cancel")
    System.out.println("Cancel is pressed");
    public class WindowEventHandler extends WindowAdapter
    public void windowClosing(WindowEvent e)
    System.exit(0);
    Can Anybody Code this for me..
    Thanks in Advance........

    hi,
    i watched your program and i have changed the code as follow as this:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.plaf.metal.*;
    import java.sql.*;
    public class Screen extends JFrame implements ActionListener
    JTextField txtuser;
    JPasswordField txtpass;
    public Screen()
    JPanel contentpane=(JPanel)getContentPane();
    contentpane.setLayout(new FlowLayout());
    JLabel username= new JLabel("UserName:");
    txtuser= new JTextField(18);
    JLabel password= new JLabel("Password:");
    txtpass = new JPasswordField(18);
    txtpass.setEchoChar('*');
    JButton login= new JButton("Login");
    login.addActionListener(this);
    login.setActionCommand("Login");
    JButton cancel= new JButton("Cancel");
    cancel.addActionListener(this);
    cancel.setActionCommand("Cancel");
    contentpane.add(username);
    contentpane.add(txtuser);
    contentpane.add(password);
    contentpane.add(txtpass);
    contentpane.add(login);
    contentpane.add(cancel);
    addWindowListener(new Screen.WindowEventHandler());
    static public void main(String[] args)
    Screen scr= new Screen();
    scr.setSize(new Dimension(300,140));
    scr.setTitle("Login Screen");
    scr.setVisible(true);
    public void actionPerformed(ActionEvent e)
    Connection con = null;
    String query;
    String id=null;
    String pwd=null;
    ResultSet rs;
    Statement stmt;
    String dsn = null;
    String driver_connection = null;
    driver_connection = "sun.jdbc.odbc.JdbcOdbcDriver";
    dsn = "jdbc:odbc:Prove";
    query = "SELECT * FROM user";
    try
    id = txtuser.getText();
    pwd = txtpass.getText();
    if (e.getActionCommand().equals("Login"))
    Class.forName(driver_connection);
    con = DriverManager.getConnection(dsn);
    stmt = con.createStatement();
    rs = stmt.executeQuery(query);
    while(rs.next())
    if(id.equals(rs.getString("ID")) && pwd.equals(rs.getString("PASSWORD")))
    System.out.println("The user is valid");
    return;
    else
    System.out.println("The user is invalid");
    System.exit(0);
    rs.close();
    stmt.close();
    else if(e.getActionCommand()=="Cancel")
    System.out.println("Cancel is pressed");
    WindowEventHandler w = new WindowEventHandler();
    w.windowClosing();
    catch(Exception exception)
    System.out.println("Error: "+exception.getMessage());
    public class WindowEventHandler extends WindowAdapter
    public void windowClosing()
    System.exit(0);
    try it,
    i hope this could help you!!!!

  • Can some one help me to execute this program

    Curve is not displayed when this program is executed
    Write an applet to draw a red curve on a blue back ground which follows your mouse pointer. 
    Use anonymous inner classes.
    import java.applet.*;
    import java.awt.event.*;
    import java.awt.*;
    <applet code="Curve" width=200 height=100>
    </applet>
    public class Curve extends Applet {
         int x, y;
         String msg = " ";
         public void init() {
              setBackground(Color.blue);
              setForeground(Color.red);
              addMouseMotionListener(new MouseMotionAdapter(){
                   public void mouseMoved(MouseEvent me) {
                        msg = "*";
                        x = me.getX();
                        y = me.getY();
                        showStatus("x="+x+" "+"y="+y);
                        repaint(x, y, 1, 1);
         public void paint(Graphics g) {
              g.drawString(msg,x, y);
    }     

    I buffered it then it started working but problem is buffer size is
    limited. When the buffer is full then we have to start fresh again.You have made a buffer with two arrays of ints - and that allows you to
    paint the last 300 mouse positions. This is OK if you want the curve to
    have a fixed length: a bit like a snake following the pointer around.
    To avoid losing the whole curve you can initialise the x[] and y[] arrays
    to something "offscreen". For example fill both arrays with -100. Then
    in your paint() method you should draw all 300 positions.
    If you want the complete curve from the start with nothing lost then you
    are going to have to use a different sort of buffer. What you do is to
    create a BufferedImage the same size as your applet. When you create
    it you fill the buffered image with the background colour of your applet.
    In the mouseMoved() method you draw the * at the appropriate place into
    the buffered image. (There are other drawing strategies at this point:
    you could draw a line connecting this point to the previous one.)
    Finally in paint() you simply draw the whole buffered image into the
    applet's window.
    There is a discussion and example of using images as buffers this way
    in Sun's Tutorial here: http://java.sun.com/docs/books/tutorial/2d/images/doublebuffering.html
    repaint (int x, int y, int width, int height) - How this method works.This method says that a part of the applet's window should be
    repainted as soon as possible. repaint() without any arguments is
    used to signal that all of the window should be repainted.
    I would not worry about the 4 argument form at this stage - get
    something working first. Later you might find the 4 argument form is
    more effecient.
    Is there any reason why you're using Applet and not JApplet? If not,
    I would use the newer classes. In that case you'll get the best help in
    the Swing forum.

  • All help me to find this program its really import...

    i've nokia 6500 slide
    u know its s40 i searched on a program to make my cam into a webcam but i just found .sis programs for symbian 60 so pls help me all to find a program for that

    The only one that i've seen that's compatible with series 40 is this this one.
    Message Edited by psychomania on 12-Jun-2008 08:32 AM

  • Can anyone help me to find this program?

    I bought E90 yesterday,the first thing that i did was update the firmware.
    But i noticed one program that i love has gone.
    I cannot remember its name,but the icon and features can.
    The icons looks like a globe and from behind the globe plane coming out.
    The feautures are:
    Weather for 3 days (sometimes shows 2):
    Currency:
    World map with time:
    And some more,total of 6
    To use other 3 you have to buy the software
    The weather,currency and world map is free for use
    nokia 8210->3310->3330->8890->6800->3220->6680->n72->E-90->5310XM->5610Xm->n82->n95 8gb->5800XM 8gb->2630
    Solved!
    Go to Solution.

    Yes!
    Thank you very much!
    Message Edited by dimauae on 27-Apr-2008 08:42 PM
    nokia 8210->3310->3330->8890->6800->3220->6680->n72->E-90->5310XM->5610Xm->n82->n95 8gb->5800XM 8gb->2630

  • CAn Someone Please Help me? Turn this program in a algorithm

    DECLARE SUB RentCar ()
    DECLARE SUB PayBill ()
    DECLARE SUB Main ()
    DECLARE SUB ReadCarData ()
    DECLARE SUB FindCar ()
    TYPE Car ' User made Type To hold Car Data
    CarNumber AS INTEGER
    License AS STRING * 8
    Year AS INTEGER
    CarMaker AS STRING * 16
    CarName AS STRING * 16
    Description AS STRING * 20
    ColorOfCar AS STRING * 10
    NumberOfDoors AS INTEGER
    Price AS DOUBLE
    Rented AS INTEGER
    Customer AS INTEGER
    END TYPE
    TYPE Customer ' User made Type to hold Customer data
    CustomerNumber AS INTEGER
    CustName AS STRING * 50
    Bill AS DOUBLE
    END TYPE
    DIM SHARED Cars(1 TO 26) AS Car ' Global Variables
    DIM SHARED p(4) AS Customer
    DIM CustName AS STRING * 50
    p(0).CustName = "Kevin" ' Assign Customers who need to pay bills
    p(0).Bill = 0
    p(1).CustName = "Eljah"
    p(1).Bill = 100
    p(2).CustName = "Jared"
    p(2).Bill = 55
    p(3).CustName = "Claudwin"
    p(3).Bill = 60
    p(4).CustName = "Isaac"
    p(4).Bill = 1500
    CALL ReadCarData ' This reads the data statements into the Cars() array.
    WIDTH 80, 50 ' Formats screen and call the main part of the program
    CALL Main
    ' CAR DATA STATEMENTS
    ' LICENSE YEAR MAKER MODEL DESCRIPTION COLOR DOORS PRICE
    DATA "X-5687", 2007, "DODGE", "CALIBER", "FAMILY CAR", "DARK RED", 4, 89.99
    DATA "X-9681", 2006, "DODGE", "CHARGER", "SPORT", "GREY", 4, 47.99
    DATA "X-9684", 2006, "DODGE", "RAM 2500", "PICKUP", "BLACK", 4, 101.99
    DATA "X-9437", 2004, "FORD", "MUSTANG", "SPORT", "RED", 2, 45.99
    DATA "X-2562", 2002, "FORD", "TAURUS", "SEDAN", "LIGHT GREY", 4, 67.99
    DATA "X-3856", 2003, "FORD", "CONTOUR", "SMALL", "LIGHT BLUE", 2, 45.99
    DATA "X-2724", 2001, "FORD", "BRONCO", "JEEP", "BLACK", 4, 63.99
    DATA "X-2724", 2001, "FORD", "BRONCO", "JEEP", "DARK GREEN", 4, 63.99
    DATA "X-8568", 1998, "FORD", "ESCORT", "COMPACT", "BROWN", 2, 35.99
    DATA "X-4724", 2004, "FORD", "PROBE", "SPORT", "BLACK", 2, 58.99
    DATA "X-4724", 2004, "FORD", "PROBE", "SPORT", "RED", 2, 58.99
    DATA "X-4724", 2004, "FORD", "PROBE", "SPORT", "YELLOW", 2, 58.99
    DATA "X-4724", 2003, "FORD", "AEROSTAR", "S.U.V.", "DARK GREEN", 4, 87.99
    DATA "X-2727", 1999, "PONTIAC", "GRAND AM", "SPORT CAR", "BLACK", 2, 45.99
    DATA "X-2327", 1999, "PONTIAC", "GRAND AM", "SPORT CAR", "RED", 2, 45.99
    DATA "X-2767", 1999, "PONTIAC", "GRAND AM", "SPORT CAR", "GREY", 2, 45.99
    DATA "X-2723", 1999, "PONTIAC", "GRAND AM", "SPORT CAR", "PURPLE", 2, 45.99
    DATA "X-8486", 2005, "PONTIAC", "TRANSPORT", "S.U.V.", "WHITE", 2, 96.99
    DATA "X-3261", 2005, "PONTIAC", "AZTEC", "S.U.V.", "YELLOW", 4, 93.99
    DATA "X-1864", 2006, "PONTIAC", "TORRENT", "S.U.V.", "RED", 4, 98.99
    DATA "X-8521", 2006, "MERCURY", "COUGAR", "SPORT", "BLACK", 2, 69.99
    DATA "X-8471", 2006, "LINCOLN", "TOWN CAR", "LUXURY", "BLACK", 4, 149.99
    DATA "X-8635", 2001, "LINCOLN", "CONTINENTAL", "LUXURY", "GOLD", 4, 139.99
    DATA "X-2643", 2006, "CHEVROLET", "F-150", "PICKUP", "GREY", 2, 95.99
    DATA "X-7143", 2006, "CHEVROLET", "CORVETTE", "SPORT", "YELLOW", 2, 131.99
    DATA "X-7378", 2006, "CHEVROLET", "MALIBU", "SEDAN", "BLACK", 4, 81.99
    SUB FindCar ' This sub goes through the data to search for a car
    DIM Counter AS INTEGER 'variables need for sub
    DIM TempMaker AS STRING
    DIM TempModel AS STRING
    DIM TempColor AS STRING
    DIM TempCarType AS STRING
    DIM TempRangeFrom AS DOUBLE
    DIM TempRangeTo AS DOUBLE
    DIM TempMax AS DOUBLE
    DIM TempMin AS DOUBLE
    DIM LeaveFindCar AS INTEGER
    DIM MoreCar AS STRING
    DIM CanDisplay AS INTEGER
    DO WHILE LeaveFindCar = 0 ' Main loop to find type of car
         ' Initialize the variables
    Counter = 0
    TempMaker = ""
    TempModel = ""
    TempColor = ""
    TempRangeFrom = 0
    TempRangeTo = 0
    CLS ' Draw the screen with the search fields"
    COLOR 15
    PRINT "FIND IDEAL CAR: (Enter one or more of these items)"
         PRINT STRING$(80, CHR$(196))
         COLOR 11
         PRINT "Car Builder:"
         PRINT "Car Model:"
         PRINT "Car Color:"
         PRINT "Price Range: From: To:"
         COLOR 10 ' GetsUser can enter any search fields he wants
         LOCATE 3, 19
         INPUT TempMaker
         LOCATE 4, 19
         INPUT TempModel
         LOCATE 5, 19
         INPUT TempColor
         LOCATE 6, 19
         INPUT TempRangeFrom
         LOCATE 6, 36
         INPUT TempRangeTo
         COLOR 15
         PRINT STRING$(80, CHR$(196))
         CanDisplay = 0
         FOR Counter = 1 TO 26 '' This loop does the actual search of the matching cars
         'We compare all string type variables as an
         'uppercase (UCASE$) and Right Trimmed (RTRIM$)
         'to avoid having to compare upper and lower case
         'Values, this makes the condtions here twice
         'as short to perform.
         IF RTRIM$(TempMaker) <> "" THEN
         IF UCASE$(RTRIM$(Cars(Counter).CarMaker)) = UCASE$(RTRIM$(TempMaker)) THEN
         IF RTRIM$(TempModel) <> "" THEN
         IF UCASE$(RTRIM$(Cars(Counter).CarName)) = UCASE$(RTRIM$(TempModel)) THEN
         IF RTRIM$(TempColor) <> "" THEN
         IF UCASE$(RTRIM$(Cars(Counter).ColorOfCar)) = UCASE$(RTRIM$(TempColor)) THEN
    IF TempRangeFrom > 0 AND TempRangeTo > 0 THEN
    IF TempRangeFrom > TempRangeTo THEN
    TempMin = TempRangeTo
    TempMax = TempRangeFrom
    ELSE
    TempMin = TempRangeFrom
    TempMax = TempRangeTo
    END IF
    ' If Price of car is in between Mininum and Maximum Price
    'Allows to display the record.
    IF Cars(Counter).Price >= TempMin AND Cars(Counter).Price <= TempMax THEN
    CanDisplay = 1
    ELSE
    CanDisplay = 0
    END IF
    END IF
    ELSE
    CanDisplay = 0
    END IF
    ELSE
    ' The IF is to set Min to the smallest of
    ' the range vales and TempMax to the biggest.
    IF TempRangeFrom > 0 AND TempRangeTo > 0 THEN
    IF TempRangeFrom > TempRangeTo THEN
    TempMin = TempRangeTo
    TempMax = TempRangeFrom
    ELSE
    TempMin = TempRangeFrom
    TempMax = TempRangeTo
    END IF
    IF Cars(Counter).Price >= TempMin AND Cars(Counter).Price <= TempMax THEN
    CanDisplay = 1
    ELSE
    CanDisplay = 0
    END IF
    END IF
    END IF
    ELSE
    CanDisplay = 0
    END IF
    ELSE
    IF RTRIM$(TempColor) <> "" THEN
    IF UCASE$(RTRIM$(Cars(Counter).ColorOfCar)) = UCASE$(RTRIM$(TempColor)) THEN
    ' This IF is to set Min to the smallest of
    ' the range values and Max to the biggest.
    IF TempRangeFrom > 0 AND TempRangeTo > 0 THEN
    IF TempRangeFrom > TempRangeTo THEN
    TempMin = TempRangeTo
    TempMax = TempRangeFrom
    ELSE
    TempMin = TempRangeFrom
    TempMax = TempRangeTo
    END IF
    IF Cars(Counter).Price >= TempMin AND Cars(Counter).Price <= TempMax THEN
    CanDisplay = 1
    ELSE
    CanDisplay = 0
    END IF
    END IF
    ELSE
    CanDisplay = 0
    END IF
    ELSE
    ' The IF is to set Min to the smallest of
    ' the range vales and Max to the biggest.
    IF TempRangeFrom > 0 AND TempRangeTo > 0 THEN
    IF TempRangeFrom > TempRangeTo THEN
    TempMin = TempRangeTo
    TempMax = TempRangeFrom
    ELSE
    TempMin = TempRangeFrom
    TempMax = TempRangeTo
    END IF
    IF Cars(Counter).Price >= TempMin AND Cars(Counter).Price <= TempMax THEN
    CanDisplay = 1
    ELSE
    CanDisplay = 0
    END IF
    ELSEIF TempRangeFrom = 0 AND TempRangeTo > 0 THEN ' The IF one of the range to be 0
    TempMin = TempRangeFrom
    TempMax = TempRangeTo
    IF Cars(Counter).Price >= TempMin AND Cars(Counter).Price <= TempMax THEN
    CanDisplay = 1
    ELSE
    CanDisplay = 0
    END IF
    ELSEIF TempRangeFrom > 0 AND TempRangeTo = 0 THEN ' This IF one of the range to be 0
    TempMin = TempRangeTo
    TempMax = TempRangeFrom
    IF Cars(Counter).Price >= TempMin AND Cars(Counter).Price <= TempMax THEN
    CanDisplay = 1
    ELSE
    CanDisplay = 0
    END IF
    ELSE
    CanDisplay = 1
    END IF
    END IF
    END IF
    END IF
    ELSE
    'Same as previously, all string variables are UCASEd and
    'RTRIMmed to shorten the comparison lenghts.
    IF RTRIM$(TempModel) <> "" THEN
    IF UCASE$(RTRIM$(Cars(Counter).CarName)) = UCASE$(RTRIM$(TempModel)) THEN
    IF RTRIM$(TempColor) <> "" THEN
    IF UCASE$(RTRIM$(Cars(Counter).ColorOfCar)) = UCASE$(RTRIM$(TempColor)) THEN
    IF TempRangeFrom > 0 AND TempRangeTo > 0 THEN
    IF TempRangeFrom > TempRangeTo THEN
    ' This IF is to setMin to the smallest of
    ' the range vales and Max to the biggest
    TempMin = TempRangeTo
    TempMax = TempRangeFrom
    ELSE
    TempMin = TempRangeFrom
    TempMax = TempRangeTo
    END IF
    IF Cars(Counter).Price >= TempMin AND Cars(Counter).Price <= TempMax THEN
    CanDisplay = 1
    ELSE
    CanDisplay = 0
    END IF
    END IF
    ELSE
    CanDisplay = 0
    END IF
    ELSE
    ' This IF is to setMin to the smallest of
    ' the range vales and Max to the biggest
    IF TempRangeFrom > 0 AND TempRangeTo > 0 THEN
    IF TempRangeFrom > TempRangeTo THEN
    TempMin = TempRangeTo
    TempMax = TempRangeFrom
    ELSE
    TempMin = TempRangeFrom
    TempMax = TempRangeTo
    END IF
    IF Cars(Counter).Price >= TempMin AND Cars(Counter).Price <= TempMax THEN
    CanDisplay = 1
    ELSE
    CanDisplay = 0
    END IF
    END IF
    END IF
    ELSE
    CanDisplay = 0
    END IF
    ELSE
    IF RTRIM$(TempColor) <> "" THEN
    IF UCASE$(RTRIM$(Cars(Counter).ColorOfCar)) = UCASE$(RTRIM$(TempColor)) THEN
    ' This IF is to setMin to the smallest of
    ' the range vales and Max to the biggest
    IF TempRangeFrom > 0 AND TempRangeTo > 0 THEN
    IF TempRangeFrom > TempRangeTo THEN
    TempMin = TempRangeTo
    TempMax = TempRangeFrom
    ELSE
    TempMin = TempRangeFrom
    TempMax = TempRangeTo
    END IF
    IF Cars(Counter).Price >= TempMin AND Cars(Counter).Price <= TempMax THEN
    CanDisplay = 1
    ELSE
    CanDisplay = 0
    END IF
    ELSE
    CanDisplay = 1
    END IF
    ELSE
    CanDisplay = 0
    END IF
    ELSE
    ' This IF is to setMin to the smallest of
    ' the range vales and Max to the biggest
    IF TempRangeFrom > 0 AND TempRangeTo > 0 THEN
    IF TempRangeFrom > TempRangeTo THEN
    TempMin = TempRangeTo
    TempMax = TempRangeFrom
    ELSE
    TempMin = TempRangeFrom
    TempMax = TempRangeTo
    END IF
    IF Cars(Counter).Price >= TempMin AND Cars(Counter).Price <= TempMax THEN
    CanDisplay = 1
    ELSE
    CanDisplay = 0
    END IF
    ELSEIF TempRangeFrom = 0 AND TempRangeTo > 0 THEN
    TempMin = TempRangeFrom
    TempMax = TempRangeTo
    IF Cars(Counter).Price >= TempMin AND Cars(Counter).Price <= TempMax THEN
    CanDisplay = 1
    ELSE
    CanDisplay = 0
    END IF
    ELSEIF TempRangeFrom > 0 AND TempRangeTo = 0 THEN
    TempMin = TempRangeTo
    TempMax = TempRangeFrom
    IF Cars(Counter).Price >= TempMin AND Cars(Counter).Price <= TempMax THEN
    CanDisplay = 1
    ELSE
    CanDisplay = 0
    END IF
    ELSE
    CanDisplay = 1
    END IF
    END IF
    END IF
    END IF
    IF CanDisplay = 1 THEN ' If car match fields entered it is displayed
              COLOR 11
    PRINT Cars(Counter).CarNumber;
    PRINT " " + RTRIM$(Cars(Counter).License);
    PRINT " - " + RTRIM$(Cars(Counter).CarMaker);
    PRINT " " + RTRIM$(Cars(Counter).CarName);
    PRINT " " + RTRIM$(Cars(Counter).Description);
    PRINT " " + RTRIM$(Cars(Counter).ColorOfCar);
    PRINT TAB(60); USING " $###.##"; Cars(Counter).Price
    CanDisplay = 0
    END IF
    NEXT Counter ' displays line after listing cars
    COLOR 15
    PRINT STRING$(80, CHR$(196))
    DO WHILE UCASE$(MoreCar) <> "Y" AND UCASE$(MoreCar) <> "N"
    LOCATE CSRLIN, 1 ' This loop ask useers if they want another car search
    PRINT "Find Another Car (Y/N)"
    INPUT MoreCar
    LOOP
    IF UCASE$(MoreCar) = "N" THEN ' If user entered "n" the loop is exited
    LeaveFindCar = 1
    END IF
    MoreCar = ""
    LOOP
    END SUB
    SUB Main
    ' This SUB is the main part of the program. It displays
    ' the menu and accepts the choices from the user, when the
    ' user picks a valid value, it executes the proper choice
    DO
    CLS
    COLOR 15
    'print the menu on the screen      
    LOCATE 1, 33
    PRINT "RENT CARS PLUS"
    LOCATE 2, 1
    PRINT STRING$(80, CHR$(196))
    COLOR 11
    PRINT " 1 - Pay Bill"
    PRINT " 2 - Rent Car"
    PRINT " 3 - Find Ideal Car"
    PRINT " 999 - Exit"
    COLOR 15
    PRINT STRING$(80, CHR$(196))
    INPUT "Choice: ", Choice ' The user enters his/her choice
    IF Choice = 999 THEN END
    IF Choice <> 999 AND Choice <> 1 AND Choice <> 2 AND Choice <> 3 THEN
    PRINT " Error Please Enter Correct Choice! " ' If not valid answer user is asked to enter correct choice
    END IF
    SELECT CASE Choice ' This Select Case executes the subprograms options
    CASE 1
    CALL PayBill
    CASE 2
    CALL RentCar
    CASE 3
    CALL FindCar
    CASE 5
    END SELECT
    LOOP UNTIL Choice = 999
    END SUB
    SUB PayBill' This sub does the bill paying process.
    ' it asks a few question to the user to get the right
    ' information and be able to pay the given bill.
    DIM CustName AS STRING
    DIM MoreBill AS INTEGER
    DIM Answer AS STRING
    DIM Flag AS INTEGER
    COLOR 15
    MoreBill = 0 ' To start loop variable
    DO WHILE MoreBill = 0 ' Loop to start the Bill Paying Process
    StartBill:
         ' Displays screen to user
    CLS
    COLOR 15
    PRINT "PAY A BILL"
    PRINT STRING$(80, CHR$(196))
    INPUT "Customer Name: ", CustName ' user enters customer name
    Flag = 0
    FOR Q = 0 TO 4 ' Loops to search for customer name in array
    IF UCASE$(RTRIM$(p(Q).CustName)) = UCASE$(RTRIM$(CustName)) THEN
    Flag = 1
    PRINT p(Q).CustName; p(Q).Bill
    EXIT FOR
    END IF
    NEXT Q
    '' If customer name invalid error message displayed
    IF Flag = 0 THEN
    PRINT "Invalid name. Press a key to try again."
    DO WHILE INKEY$ <> "": LOOP
    GOTO StartBill
    END IF
    MethodInput:
    DO
    LOCATE 4, 1     ' Display Payment methods and wait for user to pick one
    COLOR 11
    PRINT "We only use Visa or American Express. How do you wish to pay?"
    PRINT "1 - Visa"
    PRINT "2 - American Express"
    PRINT "3 - Check"
    PRINT "4 - Cash"
    INPUT "Select 1, 2, 3, or 4: ", howtopay$ ' User enters way to pay
    IF howtopay$ = "1" OR howtopay$ = "2" THEN ' CArd number asked for If american or visa
    INPUT "Enter account number: ", cardnum$
    ELSEIF howtopay$ <> "3" AND howtopay$ <> "4" THEN
    PRINT "You must select method of payment."
    END IF
    LOOP WHILE howtopay$ < "1" OR howtopay$ > "4"
    PaymentInput:
    '' users enters payment amount
    INPUT "Payment Amount (0 to cancel the transaction): ", PayAmount
    IF PayAmount <> 0 THEN
    IF PayAmount > p(Q).Bill THEN
    '' If payment bigger than amount owed message displayed
    PRINT "Payment is bigger than amount due. Press key to enter payment."
    DO WHILE INKEY$ = "": LOOP
    GOTO PaymentInput
    ELSE
    ' If amount valid , payment subtracted from amount owed
    p(Q).Bill = p(Q).Bill - PayAmount
    PRINT "New balance is "; USING "$#####.##"; p(Q).Bill
    END IF
    END IF
         '' Loop ask if user wishes to pay another bill
    DO WHILE UCASE$(RTRIM$(Answer)) <> "Y" AND UCASE$(RTRIM$(Answer)) <> "N"
    COLOR 15
    LOCATE 48, 1
    PRINT "Pay Another Bill (Y/N) ";
    INPUT Answer
    LOOP
    IF UCASE$(RTRIM$(Answer)) = "N" THEN ' If answer is "N" then loop exited
    MoreBill = 1
    END IF
    LOOP
    END SUB
    SUB ReadCarData
    ' This sub reads all data from the DATA statements
    ' And puts them in the Cars array
    DIM Counter AS INTEGER
    FOR Counter = 1 TO 26
    Cars(Counter).CarNumber = Counter
    READ Cars(Counter).License
    READ Cars(Counter).Year
    READ Cars(Counter).CarMaker
    READ Cars(Counter).CarName
    READ Cars(Counter).Description
    READ Cars(Counter).ColorOfCar
    READ Cars(Counter).NumberOfDoors
    READ Cars(Counter).Price
    NEXT Counter
    END SUB
    SUB RentCar
    ' This sub does the renting of a car
    ' to a customer. This ask several questions
    ' in order to get the right customer and the right
    ' car to rent then it rents it.
    DIM MoreRent AS INTEGER
    DIM TempCustomer AS INTEGER
    DIM TempBill AS DOUBLE
    DIM Answer AS STRING
    DIM TempPrice AS DOUBLE
    DIM TempInsurance AS DOUBLE
    DIM CustName AS STRING
    DIM Number AS STRING
    DIM CarNumber AS INTEGER
    DIM Days AS INTEGER
    DIM Q AS INTEGER
    MoreRent = 0 ' Loop for rental process
    DO WHILE MoreRent = 0
    InputName:
    CLS ' Display screen to user
    COLOR 15
    PRINT "RENT A CAR"
    PRINT STRING$(80, CHR$(196))
    COLOR 11
    LOCATE 3, 1
    INPUT " Full Name: ", CustName ' user enters his name
    IF RTRIM$(CustName) = "" THEN
    PRINT "You Must Enter Your Name. Press a key to retry." ' User is told he must enter a name
    DO WHILE INKEY$ = "": LOOP
    GOTO InputName
    ELSE
    FOR Q = 0 TO 4
    IF UCASE$(RTRIM$(p(Q).CustName)) = UCASE$(RTRIM$(CustName)) THEN
    Flag = 1
    PRINT p(Q).CustName; p(Q).Bill
    TempCustomer = Q
    EXIT FOR
    END IF
    NEXT Q
    END IF
    InputNumber:
    LOCATE 5, 1
    INPUT " Phone Number: ", Number ' User enters phone number
    IF RTRIM$(Number) = "" THEN
    PRINT "You Must a phone number. Press a key to retry." ' User is warned he must enter a number
    DO WHILE INKEY$ = "": LOOP
    GOTO InputNumber
    END IF
    CarInput:
    LOCATE 7, 2
    COLOR 11
    INPUT "Car Number: ", CarNumber     
    ' This awaits a car number from the user.
    IF CarNumber < 1 AND CarNumber > 26 THEN ' If the car number is out of range, we warn and start again
    PRINT "Car Number must be between 1 and 26. Press a key to retry."
    DO WHILE INKEY$ = "": LOOP
    GOTO CarInput
    ELSE
    ' No need to search, we just display the car information
    COLOR 14
    PRINT RTRIM$(Cars(CarNumber).License) + " - ";
    PRINT Cars(CarNumber).Year;
    PRINT RTRIM$(Cars(CarNumber).CarMaker) + " " + RTRIM$(Cars(CarNumber).CarName) + " ";
    PRINT RTRIM$(Cars(CarNumber).ColorOfCar)
    PRINT "PRICE: "; USING "$####.##"; Cars(CarNumber).Price
    END IF
    DaysInput:
    LOCATE 10, 1
    COLOR 11
    INPUT " Number of Days to rent: ", Days
    ' This awaits for a number of days to rent the car for.
    IF Days < 1 AND Days > 31 THEN
    PRINT "Days are 1 to 31. Press a key to retry."
    ' Can't have less than 1 day or more than a month or we warn.
    DO WHILE INKEY$ = "": LOOP
    GOTO DaysInput
    END IF
    TempPrice = Days * Cars(CarNumber).Price
    ' Calculate the Price of the rental
    InsuranceInput:
    LOCATE 13, 1
    COLOR 11
    DO WHILE UCASE$(RTRIM$(Answer)) <> "Y" AND UCASE$(RTRIM$(Answer)) <> "N"
    COLOR 11
    LOCATE 13, 1
    PRINT "Add Insurance (Y/N)";
    ' the customer has the option to purchase insurance here.
    INPUT Answer
    LOOP
    IF UCASE$(Answer) = "Y" THEN
    COLOR 11
    DO WHILE UCASE$(RTRIM$(Answer)) <> "F" AND UCASE$(RTRIM$(Answer)) <> "D"
    'we loop until the users enters y or n
    COLOR 11
    LOCATE 14, 1
    PRINT "(F)ixed Or (D)aily Amount";
    ' If the user selected yes, we ask for fixed or daily insurance amount.
    INPUT Answer
    LOOP
    ' if Fixed amount was picked we ask for that amount
    IF UCASE$(RTRIM$(Answer)) = "F" THEN
    INPUT "Fixed Insurance: ", TempInsurance
    ELSE
    TempInsurance = 15 * Days ' If Daily was picked we multiply 15 by the number of days rented
    END IF
    END IF
    DO     ' this loop asks for a payment method.
    LOCATE 17, 1
    PRINT "We only use Visa or American Express. How do you wish to pay?"
    PRINT "1 - Visa"
    PRINT "2 - American Express"
    PRINT "3 - Check"
    PRINT "4 - Cash"
    INPUT "Select 1, 2, 3, or 4: ", howtopay$
    IF howtopay$ = "1" OR howtopay$ = "2" THEN
    INPUT "Enter account number: ", cardnum$
    ELSEIF howtopay$ <> "3" AND howtopay$ <> "4" THEN
    PRINT "You must select method of payment."
    END IF
    LOOP WHILE howtopay$ < "1" OR howtopay$ > "4"
    COLOR 14
    PRINT     
    ' This part displays some totals to the user.
    PRINT "Rental Price = "; USING "$##,###.##"; TempPrice
    PRINT "Insurance Amount = "; USING "$##,###.##"; TempInsurance
    PRINT "Total Price = "; USING "$##,###.##"; TempPrice + TempInsurance
    PRINT " ----------"
    TempBill = p(TempCustomer).Bill
    TempBill = TempBill + (TempPrice + TempInsurance)
    p(TempCustomer).Bill = TempBill
    PRINT "New Balance = "; USING "$##,###.##"; TempBill
    PRINT " =========="
    Answer = ""
    ' This loop asks if the user wants to rent another car.
    DO WHILE UCASE$(RTRIM$(Answer)) <> "Y" AND UCASE$(RTRIM$(Answer)) <> "N"
    COLOR 15
    LOCATE 48, 1
    PRINT "Rent Another Car (Y/N) ";
    INPUT Answer
    LOOP
    IF UCASE$(RTRIM$(Answer)) = "N" THEN
    ' If user selected N, we assign value to exit the loop
    MoreRent = 1
    END IF
    LOOP
    END SUB
    Im really good at programming but really suck at algorithms can someone please please write in a algorithm form for me , i need it by friday i would greatly be thankful for u

    Im really good at programming but really suck at algorithms
    >If your are 'really good' at programming, you will be able to solve this problem. Because, it has nothing to do with algorithm.
    >>can someone please please write in a algorithm form for me , i need it by friday i would greatly be thankful for u
    >Wrong person, in the wrong place.

  • Can anyone help me to edit this picture?

    Like the writing in the background. How can I warp the text like that? Nor curved, just straight like in the picture.
    http://media2.firstshowing.net/firstshowing/img6/OscarsBigFigurePosterTeleFull5803sv.jpg

    You might be able to do that with the new perspective warp in PS CC.  If you don't have that, this is a way I used to create that type of effect:
    Make your text layer and size it so that the center section fills tha area you want in the final image.
    Create a guide where you want to "bend" or break the type, according to your shape you're trying to fill.
    make a vector mask that goes cuts your text layer at the guide you just created.  Duplicate that layer and transform the mask so that the far left edge is no over the far right edge of your text - don't move the edge along the guide.  Put both layers in their own smart object.  Then use transform>distort to move the corners of each of the smart object text layers to fill your shape.  Don't move the points along the guide.
    This was the image that I devised this approach.  Every board went through this process to make it look lik the grain wrapped around the board.  After I finished this, I put in several request for being able to transform a layer long a datum line.  Finally Adobe release perspective warp, which kind of along the lines of what I wanted.  To make the devide at an angle, place both smart object layers in a group then transform the group to the angle you want.  This was also done with each of the boards in the below image.

  • In my dock there was this weird program called "tutorial". While throwing away this program I had to fill in my password. Afterwards I tried to change my password, but my old password doesn't work anymore. Who can help?

    In my dock there was this weird program called "tutorial". While throwing away this program I had to fill in my password. Afterwards I tried to change my password, but my old password doesn't work anymore. Who can help?

    What was this program for, or did you just assume it's something you shouldn't have and therefore arbitrarily decide to "throw it away"? Exactly how did you supposedly throw it away?
    If you didn't change your administrator password, there's no reason it shouldn't work now, so that suggests you did something else, or changed it and then forgot what it was.
    You can't recover that password; you can only change it. To do that, you would need to boot from your Snow Leopard DVD, choose your language, then choose Reset Password from the Utilities menu in the top menu bar.

  • Help me to debug this function.

    public Frame getParentFrame()
    Container container = null;
    for(container = getParent();!(container instanceof Frame); ){
    container = container.getParent();/*/
    return (Frame)container;
    When I use this function , it will wrong at the line marked "*"(I put this program at the applet),please help me to debug this program.

    Let me translate that into something that the average programmer could understand, instead of that awful for-statement...public Frame getParentFrame() {
      Container container = getParent();
      while (!(container instanceof Frame)) {
         container = container.getParent(); // Error here?
      return (Frame)container;
    }Now, you say it has an error at that line? Okay, to debug it you look at the error message. And then you figure out what's wrong with that line of code that causes that message. Sorry, that's all I can say because you didn't mention what the actual error was.

  • Problem in writing this program

    Please can anyone help me in writing this program, i am a student 
    Write a C++ program that reads a real variable x, integer variable N, and computes its exponential e<sup>x</sup> using the formula:
     Ex =  1 + x +
    x^2/2! + x^3/31 + x^4/4! + x^5/5 +...+ x^N/N!  (for N ≤ 10).
    Your program should define a function that computes factorial, which is called in the main function.
    Thanks

    Hi Kanayo
    The following program does
          total = x*0 +  x*1 + x*2 + x*3 + x*4 ...+x*N
    You may modify it for your formula. Use a recursive function or 'for' loop to compute a factorial.
    Regards
    Chong
    #include "stdafx.h"
    #include <iostream>
    using namespace std;
    int N;
    double x;
    float Fn( int n)
     double total=0.0;
     if (n<N)total= Fn(n+1);
     return(total+=x*n);
    int main()
     //double x;
     //int N;
     cout<<"Enter x: "; cin >>x;
     cout<<"Enter N: "; cin >>N;
     double total=Fn(0);
     cout<<total<<"\n";

  • Help! While editing a photo in CS3 the program shut down and will not reopen my psd file.

    Help! While editing a photo in CS3 the program shut down and will not reopen my psd file. The error message reads "cannot complete your request because of a program error" -- it is a very large file (I have been saving it all along) and I had just "flattened layers" and went to open up a new, blank photo file when it shut down. Is there anyway to get this file to open? Any advice would be greatly appreciated! (p.s. after reading a couple of similar threads, I have a feeling it's hopeless. But I'd also like to know WHY this might have happened!) Thanks in advance!

    Thank you. I appreciate you taking the time to respond and for sharing the article--I did panic. Here are the details of my system:
    Model: HP p7-1247c
    Processor: AMD A8-3820 APU with Radeon HD Graphics
    Installed Memory: 8 GB (7.48 usable)
    System Type: 64-bit
    Windows 7 Home Premium
    I am using Photoshop CS3. It seems that I can work on photos and save them. But I am unable to open them back up. I have tried saving the files as psd and tiff with the same result. The error message is:  "cannot complete your request because of a program error"
    The interesting thing is that I can open up InDesign and "place" the psd file within InDesign (then export and save as a jpeg). So I don't think the files are necessarily corrupted. I uninstalled Photoshop and reinstalled it last night, but there's no change.
    If you have any ideas, I'd appreciate it. Or, should I repost my question with this more complete info? Thank you!

  • Really need help on how to write this program some 1 plz help me out here.

    i am new to java and i confused on how to be writing this program.
    i have completed the Part 1 but i am stuck on Part 2 & 3 so it would would be really great if any 1 could help me out on how to write the program.
    Part I
    An algorithm describes how a problem is solved in terms of the actions to be executed, and it specifies the order in which the actions should be executed. An algorithm must be detailed enough so that you can "walk" through the algorithm with test data. This means the algorithm must include all the necessary calculations.
    Here is an algorithm that calculates the cost of a rectangular window. The
    total cost of a window is based on two prices; the cost of the glass plus the cost of the metal frame around the glass. The glass is 50 cents per
    square inch (area) and the metal frame is 75 cents per inch (perimeter).
    The length and width of the window will be entered by the user. The
    output of the program should be the length and width (entered by the user)
    and the total cost of the window.
    FORMULAS:
    area = length times width perimeter = 2 times (length plus width)
    Here is the corresponding algorithm:
    read in the length of the window in inches
    read in the width of the window in inches
    compute the area
    compute the cost of the glass (area times 50 cents)
    compute the perimeter
    compute the cost of the frame (perimeter times 75 cents)
    compute the total cost of the window (cost of glass plus cost of frame)
    display the length, width and total cost
    The next step would be to "desk check" the algorithm. First you would need to make up the "test data". For this algorithm, the test data would involve making up a length and a width, and then calculating the cost of the window based on those values. The results are computing by hand or using a calculator. The results of your test data are always calculated before translating your algorithm into a programming language. Here is an example of the test data for the problem given:
    length = 10
    width = 20
    area = 200, glass cost= 100.00 (area times 50 cents)
    perimeter = 60, frame cost = 45.00 (perimeter times 75 cents)
    total cost =145.00
    Once the test data is chosen, you should "walk" through the algorithm using the test data to see if the algorithm produces the same answers that you obtained from your calculations.
    If the results are the same, then you would begin translating your algorithm into a programming language. If the results are not the same, then you would attempt to find out what part of the algorithm is incorrect and correct it. It is also
    necessary to re-check your hand calculations.
    Each time you revise your algorithm, you should walk through it with your test data again. You keep revising your algorithm until it produces the same answers as your test data.
    ?Now write and submit a Java program that will calculate the cost of a rectangular window according to the algorithm explained. Be sure to prompt for input and label your output.?
    Part II
    Write, compile and execute a Java program that displays the following prompts:
    Enter an integer.
    Enter a second integer
    Enter a third integer.
    Enter a fourth integer.
    After each prompt is displayed, your program should use the nextint method of the Scanner class to accept a number from the keyboard for the displayed
    prompt. After the fourth integer has been entered, your program should calculate and display the average of the four integers and the value of the first integer entered raised to the power of the second integer entered. The average and result of raising to a power should be included in an appropriate messages
    (labels).
    Sample Test Data:
    Set 1: 100 100 100 100
    Set 2: 100 0 100 0
    Be sure to write an algorithm first before attempting to write the Java code. Walk through your algorithm with test data to be sure it works as anticipated.
    Part III
    Repeat Part lI but only calculate the average, not the power. This time, make sure to use the same variable name, number, for each of the four numbers input. Also use the variable sum for the sum of the numbers. (Hint: To do this, you may use the statement sum = sum + number after each number is read.)
    For Part 1 this is what i got
    import java.util.Scanner;
    public class Window
         public static void main(String[] args)
              double length, width, glass_cost, perimeter, frame_cost, area, total;
              Scanner keyboard = new Scanner (System.in);
              System.out.println("Enter the length of the window in inches");
              length = keyboard.nextInt();
              System.out.println("Enter the width of the window in inches");
              width = keyboard.nextInt();
              area = length * width;
              glass_cost = area * .5;
              perimeter = 2 * (length + width);
              frame_cost = perimeter * .75;
              total = glass_cost + frame_cost;
                   System.out.println("The Length of the window is " + length + "inches");
                   System.out.println("The Width of the window is " + length + "inches");
                   System.out.println("The total cost of the window is $ " + total);
         Enter the length of the window in inches
         5
         Enter the width of the window in inches
         8
         The Length of the window is 5.0inches
         The Width of the window is 5.0inches
         The total cost of the window is $ 39.5
    Press any key to continue . . .
    Edited by: Adhi on Feb 24, 2008 10:33 AM

    Adhi wrote:
    i am new to java and i confused on how to be writing this program.
    i have completed the Part 1 but i am stuck on Part 2 & 3 so it would would be really great if any 1 could help me out on how to write the program.Looks like homework to me.
    What have you written so far? Post it.
    Part I
    An algorithm describes how a problem is solved in terms of the actions to be executed, and it specifies the order in which the actions should be executed. An algorithm must be detailed enough so that you can "walk" through the algorithm with test data. This means the algorithm must include all the necessary calculations.
    Here is an algorithm that calculates the cost of a rectangular window. The
    total cost of a window is based on two prices; the cost of the glass plus the cost of the metal frame around the glass. The glass is 50 cents per
    square inch (area) and the metal frame is 75 cents per inch (perimeter).
    The length and width of the window will be entered by the user. The
    output of the program should be the length and width (entered by the user)
    and the total cost of the window.
    FORMULAS:
    area = length times width perimeter = 2 times (length plus width)
    Here is the corresponding algorithm:
    read in the length of the window in inches
    read in the width of the window in inches
    compute the area
    compute the cost of the glass (area times 50 cents)
    compute the perimeter
    compute the cost of the frame (perimeter times 75 cents)
    compute the total cost of the window (cost of glass plus cost of frame)
    display the length, width and total cost
    The next step would be to "desk check" the algorithm. First you would need to make up the "test data". For this algorithm, the test data would involve making up a length and a width, and then calculating the cost of the window based on those values. The results are computing by hand or using a calculator. The results of your test data are always calculated before translating your algorithm into a programming language. Here is an example of the test data for the problem given:
    length = 10
    width = 20
    area = 200, glass cost= 100.00 (area times 50 cents)
    perimeter = 60, frame cost = 45.00 (perimeter times 75 cents)
    total cost =145.00
    Once the test data is chosen, you should "walk" through the algorithm using the test data to see if the algorithm produces the same answers that you obtained from your calculations.
    If the results are the same, then you would begin translating your algorithm into a programming language. If the results are not the same, then you would attempt to find out what part of the algorithm is incorrect and correct it. It is also
    necessary to re-check your hand calculations.
    Each time you revise your algorithm, you should walk through it with your test data again. You keep revising your algorithm until it produces the same answers as your test data.
    &#147;Now write and submit a Java program that will calculate the cost of a rectangular window according to the algorithm explained. Be sure to prompt for input and label your output.&#148;
    Part II
    Write, compile and execute a Java program that displays the following prompts:
    Enter an integer.
    Enter a second integer
    Enter a third integer.
    Enter a fourth integer.
    After each prompt is displayed, your program should use the nextint method of the Scanner class to accept a number from the keyboard for the displayed
    prompt. After the fourth integer has been entered, your program should calculate and display the average of the four integers and the value of the first integer entered raised to the power of the second integer entered. The average and result of raising to a power should be included in an appropriate messages
    (labels).
    Sample Test Data:
    Set 1: 100 100 100 100
    Set 2: 100 0 100 0
    Be sure to write an algorithm first before attempting to write the Java code. Walk through your algorithm with test data to be sure it works as anticipated.So this is where you actually have to do something. My guess is that you've done nothing so far.
    Part III
    Repeat Part lI but only calculate the average, not the power. This time, make sure to use the same variable name, number, for each of the four numbers input. Also use the variable sum for the sum of the numbers. (Hint: To do this, you may use the statement sum = sum + number after each number is read.)Man, this specification writes itself. Sit down and start coding.
    One bit of advice: Nobody here takes kindly to lazy, stupid students who are just trying to con somebody into doing their homework for them. If that's you, better have your asbestos underpants on.
    %

  • I Need Help With Making This Program Work

    The directions for this program:
    Enhance the Student class to contain an Advisor. The advisor has a name (type Name), phone number (type String). Place edits in the Name class to validate that the length of the first name is between 1 and 15, middle inital <= 1, and lastName is between 1 and 15. Throw an IllegalArgumentException if the edits are not met. The advisor attribute in the Student class should replace the advisorName. Document the Name, Advisor, and Student classes including the preconditions and postconditions where necessary. Create a test class that will instantiate a Student, fully populate all of its fields and print it out. Do not document the test class. Submit for grade Student.java, Advisor.java, and Name.java.
    public class Student
         private Advisor advisorName;
         private Advisor phoneNumber;
         public void setAdvisorName(Advisor anAdvisorName)
             advisorName = anAdvisorName;
         public Advisor getAdvisorName()
             return advisorName;
         public void setPhoneNumber(Advisor aPhoneNumber)
             phoneNumber = aPhoneNumber;
         public Advisor getPhoneNumber()
             return phoneNumber;
    public class Name
         private String firstName;
         private String midInit;
         private String lastName;
         public String getFullName()
             return firstName + " " + midInit + " " + lastName;
         public String getFirstName()
             return firstName;
         public String getMidInit()
             return midInit;
         public String getLastName()
             return lastName;
            Calculates length of the first name.
            (Postcondition: getFirstName() >= 0)
            @param s the length of the first name to calculate
            (Precondition: length of aFirstName > 0 and <= 15)
         public void setFirstName(String aFirstName)
             if(aFirstName.length() < 1)
               throw new IllegalArgumentException();
             if(aFirstName.length() > 15)
               throw new IllegalArgumentException();
               firstName = aFirstName;
            Calculates length of the middle initial.
            (Postcondition: getMidInit() >= 0)
            @param s the length of the middle initial to calculate
            (Precondition: length of s > 0 and <= 1)
         public void setMidInit(String aMidInit)
             if(aMidInit.length() == 1)
               throw new IllegalArgumentException();
               midInit = aMidInit;
            Calculates length of the last name.
            (Postcondition: getLastName() >= 0)
            @param s the length of the last name to calculate
            (Precondition: length of aLastName > 0 and <= 15)
         public void setLastName(String aLastName)
             if(aLastName.length() < 1)
               throw new IllegalArgumentException();
             if(aLastName.length() > 15)
               throw new IllegalArgumentException();    
               lastName = aLastName;
    public class Advisor
         private Name advisorName;
         private String phoneNumber;
         public String getFullName()
            return advisorName + " " + phoneNumber + " ";
         public Name getAdvisorName()
             return advisorName;
         public String getPhoneNumber()
             return phoneNumber;
         public void setAdvisorName(Name anAdvisorName)
             advisorName = anAdvisorName;
         public void setPhoneNumber(String aPhoneNumber)
             phoneNumber = aPhoneNumber;
    public class Test
         public static void main(String[] args)
            Name name1 = new Name();
            name1.setFirstName("Timothy");
            name1.setLastName("O'Neal");
            name1.setMidInit("J.");
            System.out.println("name1 = " +
                name1.getFirstName() + " " +
                name1.getMidInit() + " " +
                name1.getLastName());
            Student st = new Student();
            st.setAdvisorName(name1);
            Name name2 = st.getAdvisorName();
            System.out.println("name2 = " +
                name2.getFirstName() + " " +
                name2.getMidInit() + " " +
                name2.getLastName());   
            name2.setFirstName("Timothy");
            System.out.println("name2 = " +
                name2.getFirstName() + " " +
                name2.getMidInit() + " " +
                name2.getLastName());       
            System.out.println("name1 = " +
                name1.getFirstName() + " " +
                name1.getMidInit() + " " +
                name1.getLastName());
            System.out.println("name1 = " + name1.getFullName());   
            System.out.println("name2 = " + name2.getFullName());
    }I can't get the test class to compile and i'm not sure if this is what i'm suppose to do

    public class Test
    public static void main(String[] args)
    Student st = new Student();
    Advisor advisor = new Advisor();
    st.setAdvisor(advisor);
    Name name1 = new Name();
    name1.setFirstName("Jake");
    name1.setLastName("Schmidt");
    name1.setMidInit("K.");You have the general idea, I think. You are just doing it backwards.
    You create and advisor and assign it to a student. But you don't give
    the advisor a name until after you assign it to the student.
    You should create an advisor, give the advisor a name and then add it to the student.
    //create the name
    Name name1 = new Name();
    name1.setFirstName("John");
    name1.setLastName("Smith");
    name1.setMidInit("K.");
    //create the advisor
    Advisor advisor = new Advisor();
    advisor.setAdvisorName(name1);
    //create the student
    Student student = new Student();
    //assign the advisor to the student
    student.setAdvisor(advisor);
    //now the student has an advisor named John K. Smith
    //What is the name of the advisor?
    String name = st.advisor.getAdvisorName().getFullName();
    //I know that line looks complicated...but that's how you have created your class structure.
    Instead you could have done:
    Class Student{
    private Advisor advisor;
    public String getAdvisorName(){
    return advisor.getFullName();
    class Advisor{
    private Name advisorName;
    public getFullName(){
    return advisorName.getFullName();
    This way, if you wanted to know the advisor's name you would go:
    String name = st.getAdvisorName();
    which is much easier.
    I think it would be much easier to help you if we were both in the same room, on the same computer :)

  • Need help fixing a bug with this program...

    I've been working for hours trying to fix the bug I have with this program...
    http://ss.majinnet.com/AccountManager.java - This is the source code of my program
    http://ss.majinnet.com/Dalzhim.jpg - This is an image used inside the program
    http://ss.majinnet.com/sphereaccu.scp - This is a text file you need to use the program
    First of all, to know what bug I am talking about.. You will need to download those 3 files.. Then you can compile AccountManager.java and run it.. When the program has opened, go into: File -> Open Account File
    and browse until you can open up the text file sphereaccu.scp ... Then there should be a list of names appearing on the left, and when you select any, there will be variables appearing in the TextFields on the right. When that's done, all you have to do to see where the bugs are is to use the options: Edit -> Create New Account as well as Edit -> Remove Account ... When you use the Create New Account option for the first time, it works fine.. But when you use it a second time, errors are appearing on the console (can't find what generates those errors...). And the biggest problem is that when you use the Remove Account option, it doesn't remove the selected account, and over that it generates errors in the console as well...
    If anyone can help me fix those errors, I'd be very grateful !

    won't pretend to understand everything or why you do somethings, but FWIW,
    //package Dalzhim.AccountManager;
    import java.io.*;
    import java.awt.*;
    import java.util.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    public class AccountManager
          JFrame window;
          Container mainPane;
          JSplitPane splitPane;
          JPanel leftPane,rightPane;
          JList accountList;
          JTextField accountName,plevel,priv,password,totaltime,lasttime,lastchar,firstconnect;
          JTextField firstIP,lastconnect,lastIP,lang;
          JLabel label1,label2,label3,label4,label5,label6,label7,label8,label9,label10,label11,label12;
          JMenuBar menuBar;
          JMenu file,edit,end;
          JMenuItem open,save,quit,create,remove,search,ab;
          JFileChooser jfc,jfcs;
          JButton searchButton,createButton;
          JTextField searchString,newName,newPassword,newPLevel;
          JDialog searchWindow,createWindow;
          File accountFile = null;
          File savingFile = null;
          FileInputStream fis;
          StringTokenizer st;
          String content;
          String lastSearch = "";
          String[] strings,lines;
          String[] parameters,arguments;
          Vector accountNames;
          Hashtable plevels,privs,passwords,totaltimes,lasttimes,lastchars,firstconnects;
          Hashtable firstIPs,lastconnects,lastIPs,langs;
          String newline = "";
          int[] activated;
          int lastSelection = -1;
          AL al;
          LL ll;
          public static void main(String args[])
          AccountManager am = new AccountManager();
          public AccountManager()
          al = new AL();
          ll = new LL();
          window = new JFrame("Account Manager");
          mainPane = window.getContentPane();
          leftPane = new JPanel();
          rightPane = new JPanel();
          leftPane.setLayout(new GridLayout(1,1,5,5));
          rightPane.setLayout(null);
          splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,leftPane,rightPane);
          mainPane.setLayout(new GridLayout(1,1,5,5));
          mainPane.add(splitPane);
          menuBar = new JMenuBar();
          file = new JMenu("File");
          edit = new JMenu("Edit");
          end = new JMenu("?");
          menuBar.add(file);
          menuBar.add(edit);
          menuBar.add(end);
          open = new JMenuItem("Open Account File");
          open.addActionListener(al);
          file.add(open);
          save = new JMenuItem("Save Account File");
          save.addActionListener(al);
          file.add(save);
          quit = new JMenuItem("Quit");
          quit.addActionListener(al);
          file.add(quit);
          create = new JMenuItem("Create New Account");
          create.addActionListener(al);
          edit.add(create);
          remove = new JMenuItem("Remove Selected Account");
          remove.addActionListener(al);
          edit.add(remove);
          search = new JMenuItem("Search");
          search.addActionListener(al);
          edit.add(search);
          ab = new JMenuItem("About");
          ab.addActionListener(al);
          end.add(ab);
          window.setJMenuBar(menuBar);
          accountList = new JList();
          accountList.addListSelectionListener(ll);
          leftPane.add(new JScrollPane(accountList));
          accountName = new JTextField(50);
          plevel = new JTextField(50);
          priv = new JTextField(50);
          password = new JTextField(50);
          totaltime = new JTextField(50);
          lasttime = new JTextField(50);
          lastchar = new JTextField(50);
          firstconnect = new JTextField(50);
          firstIP = new JTextField(50);
          lastconnect = new JTextField(50);
          lastIP = new JTextField(50);
          lang = new JTextField(50);
          label1 = new JLabel("Account Name:");
          label2 = new JLabel("Player Level:");
          label3 = new JLabel("Priv Level:");
          label4 = new JLabel("Password:");
          label5 = new JLabel("Total Connected Time:");
          label6 = new JLabel("Last Connected Time:");
          label7 = new JLabel("Last Character Used:");
          label8 = new JLabel("First Connect Data:");
          label9 = new JLabel("First Connected IP:");
          label10 = new JLabel("Last Connected Date:");
          label11 = new JLabel("Last Connected IP:");
          label12 = new JLabel("Language:");
          rightPane.add(accountName);
          rightPane.add(plevel);
          rightPane.add(priv);
          rightPane.add(password);
          rightPane.add(totaltime);
          rightPane.add(lasttime);
          rightPane.add(lastchar);
          rightPane.add(firstconnect);
          rightPane.add(firstIP);
          rightPane.add(lastconnect);
          rightPane.add(lastIP);
          rightPane.add(lang);
          rightPane.add(label1);
          rightPane.add(label2);
          rightPane.add(label3);
          rightPane.add(label4);
          rightPane.add(label5);
          rightPane.add(label6);
          rightPane.add(label7);
          rightPane.add(label8);
          rightPane.add(label9);
          rightPane.add(label10);
          rightPane.add(label11);
          rightPane.add(label12);
          label1.setBounds(10,10,150,25);
          accountName.setBounds(175,10,200,25);
          label2.setBounds(10,40,150,25);
          plevel.setBounds(175,40,200,25);
          label3.setBounds(10,70,150,25);
          priv.setBounds(175,70,200,25);
          label4.setBounds(10,100,150,25);
          password.setBounds(175,100,200,25);
          label5.setBounds(10,130,150,25);
          totaltime.setBounds(175,130,200,25);
          label6.setBounds(10,160,150,25);
          lasttime.setBounds(175,160,200,25);
          label7.setBounds(10,190,150,25);
          lastchar.setBounds(175,190,200,25);
          label8.setBounds(10,220,150,25);
          firstconnect.setBounds(175,220,200,25);
          label9.setBounds(10,250,150,25);
          firstIP.setBounds(175,250,200,25);
          label10.setBounds(10,280,150,25);
          lastconnect.setBounds(175,280,200,25);
          label11.setBounds(10,310,150,25);
          lastIP.setBounds(175,310,200,25);
          label12.setBounds(10,340,150,25);
          lang.setBounds(175,340,200,25);
          Dimension rightdim = new Dimension(380,425);
          rightPane.setMinimumSize(rightdim);
          window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          window.pack();
          window.setSize(550,425);
          window.setResizable(false);
          window.setVisible(true);
          public void openAccountFile()
          byte[] b = null;
          try
             fis = new FileInputStream(accountFile);
             b = new byte[fis.available()];
             fis.read(b,0,fis.available());
          catch(FileNotFoundException e)
          catch(IOException e)
          content = new String(b);
          newline = String.valueOf(content.charAt(content.indexOf("\n")));
          parseAccountFile();
          public void parseAccountFile()
          StringTokenizer st = new StringTokenizer(content, "[");
          strings = new String[st.countTokens()];
          createArrays();
          for (int i=0;i<strings.length;i++)
             strings[i] = st.nextToken();
          for(int i=0;i<strings.length;i++)
             parseAccountParameters(i);
          sort();
          public void parseAccountParameters(int which)
          StringTokenizer st = new StringTokenizer(strings[which],"\n");
          lines = new String[st.countTokens()];
          for(int i=0;i<lines.length;i++)
             lines[i] = st.nextToken();
          parameters = new String[lines.length];
          arguments = new String[lines.length];
          accountNames.add(getAccountName(lines[0]));
          for(int i=1;i<lines.length;i++)
             parseAccountParameter(i,which);
          public void parseAccountParameter(int which,int strings)
          StringTokenizer st = new StringTokenizer(lines[which],"=");
          parameters[which] = st.nextToken();
          if(st.hasMoreTokens())
             arguments[which] = st.nextToken();
          stockValues(strings);
          public void stockValues(int a)
          for(int i=0;i<parameters.length;i++)
             if(arguments!=null)
         if(parameters[i].equals("PLEVEL"))
              plevels.put(accountNames.get(a),arguments[i]);
         else if(parameters[i].equals("PRIV"))
              privs.put(accountNames.get(a),arguments[i]);
         else if(parameters[i].equals("PASSWORD"))
              passwords.put(accountNames.get(a),arguments[i]);
         else if(parameters[i].equals("TOTALCONNECTTIME"))
              totaltimes.put(accountNames.get(a),arguments[i]);
         else if(parameters[i].equals("LASTCONNECTTIME"))
              lasttimes.put(accountNames.get(a),arguments[i]);
         else if(parameters[i].equals("LASTCHARUID"))
              lastchars.put(accountNames.get(a),arguments[i]);
         else if(parameters[i].equals("FIRSTCONNECTDATE"))
              firstconnects.put(accountNames.get(a),arguments[i]);
         else if(parameters[i].equals("FIRSTIP"))
              firstIPs.put(accountNames.get(a),arguments[i]);
         else if(parameters[i].equals("LASTCONNECTDATE"))
              lastconnects.put(accountNames.get(a),arguments[i]);
         else if(parameters[i].equals("LASTIP"))
              lastIPs.put(accountNames.get(a),arguments[i]);
         else if(parameters[i].equals("LANG"))
              langs.put(accountNames.get(a),arguments[i]);
    public String getAccountName(String line)
         String name = "";
         for(int i=0;i<line.indexOf("]");i++)
         name = name + (String.valueOf(line.charAt(i)));
         return name;
    public void createArrays()
         accountNames = new Vector();
         plevels = new Hashtable();
         privs = new Hashtable();
         passwords = new Hashtable();
         totaltimes = new Hashtable();
         lasttimes = new Hashtable();
         lastchars = new Hashtable();
         firstconnects = new Hashtable();
         firstIPs = new Hashtable();
         lastconnects = new Hashtable();
         lastIPs = new Hashtable();
         langs = new Hashtable();
    public void showValues()
         if(lastSelection!=-1)
         //keepValues();
         int i = -1 == accountList.getSelectedIndex() ?
         lastSelection :
         accountList.getSelectedIndex();
         accountName.setText((String)accountNames.get( i ));
         plevel.setText((String)plevels.get(accountNames.get( i )));
         priv.setText((String)privs.get(accountNames.get( i )));
         password.setText((String)passwords.get(accountNames.get( i )));
         totaltime.setText((String)totaltimes.get(accountNames.get( i )));
         lasttime.setText((String)lasttimes.get(accountNames.get( i )));
         lastchar.setText((String)lastchars.get(accountNames.get( i )));
         firstconnect.setText((String)firstconnects.get(accountNames.get( i )));
         firstIP.setText((String)firstIPs.get(accountNames.get( i )));
         lastconnect.setText((String)lastconnects.get(accountNames.get( i )));
         lastIP.setText((String)lastIPs.get(accountNames.get( i )));
         lang.setText((String)langs.get(accountNames.get( i )));
         lastSelection = i ;
    public void keepValues()
         accountNames.setElementAt(accountName.getText(),lastSelection);
         plevels.put(accountNames.get(lastSelection),plevel.getText());
         privs.put(accountNames.get(lastSelection),priv.getText());
         passwords.put(accountNames.get(lastSelection),password.getText());
         totaltimes.put(accountNames.get(lastSelection),totaltime.getText());
         lasttimes.put(accountNames.get(lastSelection),lasttime.getText());
         lastchars.put(accountNames.get(lastSelection),lastchar.getText());
         firstconnects.put(accountNames.get(lastSelection),firstconnect.getText());
         firstIPs.put(accountNames.get(lastSelection),firstIP.getText());
         lastconnects.put(accountNames.get(lastSelection),lastconnect.getText());
         lastIPs.put(accountNames.get(lastSelection),lastIP.getText());
         langs.put(accountNames.get(lastSelection),lang.getText());
    public void saveAccountFile()
         keepValues();
         String saving = "";
         for(int i=0;i<strings.length;i++)
         saving = saving + ("["+(String)accountNames.get(i)+"]"+newline);
         if(plevels.get((String)accountNames.get(i))!=null && !(plevels.get((String)accountNames.get(i)).equals("")))
         saving = saving + ("PLEVEL="+plevels.get((String)accountNames.get(i))+newline);
         if(privs.get((String)accountNames.get(i))!=null && !(privs.get((String)accountNames.get(i)).equals("")))
         saving = saving + ("PRIV="+privs.get((String)accountNames.get(i))+newline);
         if(passwords.get((String)accountNames.get(i))!=null && !(passwords.get((String)accountNames.get(i)).equals("")))
         saving = saving + ("PASSWORD="+passwords.get((String)accountNames.get(i))+newline);
         if(totaltimes.get((String)accountNames.get(i))!=null && !(totaltimes.get((String)accountNames.get(i)).equals("")))
         saving = saving + ("TOTALCONNECTTIME="+totaltimes.get((String)accountNames.get(i))+newline);
         if(lasttimes.get((String)accountNames.get(i))!=null && !(lasttimes.get((String)accountNames.get(i)).equals("")))
         saving = saving + ("LASTCONNECTTIME="+lasttimes.get((String)accountNames.get(i))+newline);
         if(lastchars.get((String)accountNames.get(i))!=null && !(lastchars.get((String)accountNames.get(i)).equals("")))
         saving = saving + ("LASTCHARUID="+lastchars.get((String)accountNames.get(i))+newline);
         if(firstconnects.get((String)accountNames.get(i))!=null && !(firstconnects.get((String)accountNames.get(i)).equals("")))
         saving = saving + ("FIRSTCONNECTDATE="+firstconnects.get((String)accountNames.get(i))+newline);
         if(firstIPs.get((String)accountNames.get(i))!=null && !(firstIPs.get((String)accountNames.get(i)).equals("")))
         saving = saving + ("FIRSTIP="+firstIPs.get((String)accountNames.get(i))+newline);
         if(lastconnects.get((String)accountNames.get(i))!=null && !(lastconnects.get((String)accountNames.get(i)).equals("")))
         saving = saving + ("LASTCONNECTDATE="+lastconnects.get((String)accountNames.get(i))+newline);
         if(lastIPs.get((String)accountNames.get(i))!=null && !(lastIPs.get((String)accountNames.get(i)).equals("")))
         saving = saving + ("LASTIP="+lastIPs.get((String)accountNames.get(i))+newline);
         if(langs.get((String)accountNames.get(i))!=null && !(langs.get((String)accountNames.get(i)).equals("")))
         saving = saving + ("LANG="+langs.get((String)accountNames.get(i))+newline);
         saving = saving + newline;
         try
         FileOutputStream fos = new FileOutputStream(savingFile);
         fos.write(saving.getBytes());
         catch(FileNotFoundException e)
         catch(IOException e)
    public void about()
         final JDialog info = new JDialog(window,"About",true);
         Container aboutPane = info.getContentPane();
         aboutPane.setLayout(null);
         Image image = Toolkit.getDefaultToolkit().getImage(getClass().getResource("Dalzhim.jpg"));
         ImageIcon sig = new ImageIcon(image);
         JLabel sign = new JLabel(sig);
         JLabel text1 = new JLabel("AccountManager v0.2Beta");
         JEditorPane text2 = new JEditorPane();
         JEditorPane text3 = new JEditorPane();
         JEditorPane text4 = new JEditorPane();
         JButton close = new JButton("Okay");
         JEditorPane jep = new JEditorPane();
         sign.setBounds(10,0,374,292);
         text1.setBounds(125,300,250,20);
         text2.setBounds(10,350,400,20);
         text3.setBounds(10,400,400,20);
         text4.setBounds(10,450,400,20);
         close.setBounds(150,500,100,20);
         close.addActionListener(new ActionListener()
              public void actionPerformed(ActionEvent e)
              info.setVisible(false);
         text2.setText("Created by �alzhim");
         text3.setText("Dalzhim, also known as, Amlaruil");
         text4.setText("[email protected] - [email protected]");
         text2.setEditable(false);
         text3.setEditable(false);
         text4.setEditable(false);
         text2.setBackground(new Color(207,207,207));
         text3.setBackground(new Color(207,207,207));
         text4.setBackground(new Color(207,207,207));
         aboutPane.add(sign);
         aboutPane.add(text1);
         aboutPane.add(text2);
         aboutPane.add(text3);
         aboutPane.add(text4);
         aboutPane.add(close);
         jep.setBackground(new Color(207,207,207));
         jep.setEditable(false);
         jep.setText("TEST");
         info.pack();
         info.setSize(400,550);
         info.setResizable(false);
         info.setVisible(true);
    public void search()
         searchWindow = new JDialog(window,"Search");
         Container searchPane = searchWindow.getContentPane();
         searchPane.setLayout(null);
         searchString = new JTextField(lastSearch);
         searchButton = new JButton("Search");
         searchString.addActionListener(al);
         searchButton.addActionListener(al);
         searchPane.add(searchString);
         searchPane.add(searchButton);
         searchString.setBounds(10,10,175,25);
         searchButton.setBounds(200,10,100,25);
         searchString.selectAll();
         searchWindow.pack();
         searchWindow.setSize(320,65);
         searchWindow.setResizable(false);
         searchWindow.setVisible(true);
    public void search(String what)
         accountList.setSelectedValue(what,true);
    public void createAccount()
         createWindow = new JDialog(window,"Create New Account");
         Container createPane = createWindow.getContentPane();
         createPane.setLayout(null);
         newName = new JTextField();
         newPassword = new JTextField();
         newPLevel = new JTextField();
         createButton = new JButton("Create Account");
         JLabel createlabel1 = new JLabel("Account Name:");
         JLabel createlabel2 = new JLabel("Account Password:");
         JLabel createlabel3 = new JLabel("Account PLevel:");
         createPane.add(newName);
         createPane.add(newPassword);
         createPane.add(newPLevel);
         createPane.add(createButton);
         createPane.add(createlabel1);
         createPane.add(createlabel2);
         createPane.add(createlabel3);
         newName.addActionListener(al);
         newPassword.addActionListener(al);
         newPLevel.addActionListener(al);
         createButton.addActionListener(al);
         newName.setBounds(160,10,200,25);
         newPassword.setBounds(160,45,200,25);
         newPLevel.setBounds(160,80,200,25);
         createButton.setBounds(160,115,200,25);
         createlabel1.setBounds(10,10,150,25);
         createlabel2.setBounds(10,45,150,25);
         createlabel3.setBounds(10,80,150,25);
         createWindow.pack();
         createWindow.setSize(375,175);
         createWindow.setResizable(false);
         createWindow.setVisible(true);
    public void createProcess()
         String tempname = newName.getText();
         String temppass = newPassword.getText();
         String templeve = newPLevel.getText();
         createWindow.dispose();
         if(!(accountNames.contains(tempname)))
         accountNames.add(tempname);
         sort();
         passwords.put(tempname,temppass);
         plevels.put(tempname,templeve);
         search(newName.getText());
    public void sort()
         Object[] sorting = new Object[accountNames.size()];
         accountNames.toArray(sorting);
         String[] sorting2 = new String[sorting.length];
         for(int i=0;i<sorting.length;i++)
         sorting2[i] = (String)sorting[i];
         Arrays.sort(sorting2,String.CASE_INSENSITIVE_ORDER);
         accountNames.clear();
         for(int i=0;i<sorting2.length;i++)
         accountNames.add(sorting2[i]);
         accountList.setListData(accountNames);
    public void removeAccount()
         if(accountList.getSelectedIndex()==-1)
         JOptionPane.showMessageDialog(window,"You must select an account from the list to use the Remove option");
         else
         int i = accountList.getSelectedIndex();
         System.out.println( "ra: " + i + " an: " + accountNames.elementAt( i ) );
         System.out.println(accountNames.elementAt( i ));
         plevels.remove(accountNames.elementAt( i ));
         privs.remove(accountNames.elementAt( i ));
         passwords.remove(accountNames.elementAt( i ));
         totaltimes.remove(accountNames.elementAt( i ));
         lasttimes.remove(accountNames.elementAt( i ));
         lastchars.remove(accountNames.elementAt( i ));
         firstconnects.remove(accountNames.elementAt( i ));
         firstIPs.remove(accountNames.elementAt( i ));
         lastconnects.remove(accountNames.elementAt( i ));
         lastIPs.remove(accountNames.elementAt( i ));
         langs.remove(accountNames.elementAt( i ));
         accountNames.removeElementAt( i );
         accountList.setListData( accountNames );
         //sort();
         showValues();
    class AL implements ActionListener
         public void actionPerformed(ActionEvent e)
         if(e.getSource()==open)
              jfc = new JFileChooser(accountFile);
              jfc.setDialogTitle("Select your account file");
              jfc.setMultiSelectionEnabled(false);
              jfc.addActionListener(al);
              jfc.showOpenDialog(window);
         else if(e.getSource()==jfc)
              accountFile = jfc.getSelectedFile();
              openAccountFile();
         else if(e.getSource()==save)
              jfcs = new JFileChooser(savingFile);
              jfcs.setDialogTitle("Where do you wish to save?");
              jfcs.setMultiSelectionEnabled(false);
              jfcs.addActionListener(al);
              jfcs.showSaveDialog(window);
         else if(e.getSource()==ab)
              about();
         else if(e.getSource()==jfcs)
              savingFile = jfcs.getSelectedFile();
              saveAccountFile();
         else if(e.getSource()==quit)
              System.exit(-1);
         else if(e.getSource()==search)
              search();
         else if(e.getSource()==searchString)
              searchButton.doClick();
         else if(e.getSource()==searchButton)
              accountList.setSelectedValue(searchString.getText(),true);
              lastSearch = searchString.getText();
              searchWindow.dispose();
         else if(e.getSource()==create)
              createAccount();
         else if(e.getSource()==newName)
              newPassword.requestFocus();
              newPassword.selectAll();
         else if(e.getSource()==newPassword)
              newPLevel.requestFocus();
              newPLevel.selectAll();
         else if(e.getSource()==newPLevel)
              createButton.doClick();
         else if(e.getSource()==createButton)
              if(newName.getText().equals("") || newPassword.getText().equals("") || newPLevel.getText().equals(""))
              createWindow.dispose();
              JOptionPane.showMessageDialog(window,"You have to enter an account name, a password and a plevel");
              else
              createProcess();
         else if(e.getSource()==remove)
              removeAccount();
    class LL implements ListSelectionListener
         public void valueChanged(ListSelectionEvent e)
         showValues();

Maybe you are looking for

  • Facing problem while creating a report on the value of a UDM in oem gc

    Hi, I have created a report in OEM grid control. I have selected a host for this. And I have selected an UDM from the metric list. The report works fine shows the correct graph in the report. The problem is that along with the value from the respecti

  • IPod Photo won't display album artwork for purchased songs

    I bought some songs on the ITunes Music Store, and I can see the album artwork on the ITunes, I can also see in my IPod the artwork for most of the songs that I've downloaded, but I CAN'T see the artwork for those recently purchased. I also noticed t

  • I-photo wont close

    It locks up. Force quit wont open unless I open another program, then force quit will open and allow me to force quit I-Photo. Thanks in advance, Bill

  • How to display and type in Chinese on BB bold 9000?

    Hey, I'm a new user of BB bold 9000. Just bought the phone from the states, which was distributed by AT&T and it is unlocked. I have tried couple times by following this post: http://supportforums.blackberry.com/t5/BlackBerry-Curve-BlackBerry-8300/Ch

  • 9 years of photos gone!  Please help!

    I have always uploaded ALL of my photos onto my work computer.... 9 years going on 10.  Our tech guy realized my machine was never being backed up.  The only connection I can make is they disappeared when he started backing up via Time Machine.  I ha