Homewordk Help PLZZZZZZZZZZ

I have been at this for about 5 hours now and I do not know what to do anymore. This homework is due in about 2 hours so I hope someone can help me figure this out. I am not looking for answer. I sincerely want to learn this language but I do need so help. Here is the homework question:
The value ex can be approximated by the sum:
1 + x + x2/2! + x3/3! + ... + xn/n!
Write a program that takes a value x as input and outputs this sum for n taken to be each of the values 1 to 10, 50, and 100. Your program should repeat the calculation for new values of x until the user says she or he is through. The expression n! is called the factorial of n and is defined as
n! = 1 * 2 * 3 * ... * n
Use variables of type double to store the factorials or you are likely to produce integer overflow, that is integers larger than Java allows, (or arrange your calculation to avoid any direct calculation of factorials).
The output is suppose to look something like this:
Enter a value for x (or a blank line to quit):
6
n = 1: e^x = 7
n = 2: e^x = 25
n = 3: e^x = 61
n = 4: e^x = 115
n = 5: e^x = 179.8
n = 6: e^x = 244.6
n = 7: e^x = 300.143
n = 8: e^x = 341.8
n = 9: e^x = 369.571
n = 10: e^x = 386.234
n = 50: e^x = 403.429
n = 100: e^x = 403.429
Enter a value for x (or a blank line to quit):
and this is what I have so far:
import java.util.Scanner;
import java.text.DecimalFormat; // It's okay if you don't use this.
import java.lang.Math;
  Iteratively computes e^x for a given value x, outputing values at iteration
  1 to 10, 50, and 100
public class Ex {
    public static void main(String[] args)  {
        // Make a Scanner to read data from the console
        Scanner console = new Scanner(System.in);
        // Make a NumberFormat object that we'll use when printing values
        // of n in the loop below (use of this format is optional)
        DecimalFormat nFormat = new DecimalFormat("000");
        // Read in a number for x
        System.out.println("Enter a value for x (or a blank line to quit):");
        String xString = console.nextLine();
        while ((xString != null) && (xString.length() > 0)) {
            double x = Double.parseDouble(xString);
            double fact = 1;
          for(int i = 2; i <= x; i++)     // loop
                         fact = fact * i;     // shorthand for: fact = fact * i;
                         System.out.println(fact);
            // Start over again
            System.out.println(
                "Enter a value for x (or a blank line to quit):");
            xString = console.nextLine();
}where do I go from here to sovle this problem?

Have a look at the Math.pow() method. And for what it's worth, many of the most helpful folks around here deliberately overlook threads with subject lines like the one you used. You can get better, faster help by using a descriptive subject line and refraining from slang and abbreviations. Of course, you're free to ignore that advice as well, but it's in your best interest to make your questions interesting to answer and present them in a format that encourages rather than discourages help.
~

Similar Messages

  • Plz help I changed my gmail on my Apple ID but I can't download on the App Store the old gmail keeps coming up can enemy one help plzzzzzzzzzz.

    Plz help I changed my gmail on my Apple ID but the old one keeps commingled up what will I do plzzzzzzzz help

    First, are you sure you changed your email address associated with your Apple ID and did not creat a new Apple ID?
    Try signing out of your Apple ID on your iPad then sign back in. Use the Settings app.
    Settings > iTunes and App Store > tap on your Apple ID > sign out
    Then sign in to your Apple ID. What happens?

  • Help plzzzzzzzzzz : How to stretch the list of FM : 'DD_POPUP_WITH_LIST'

    Hi everyone,
    Does anyone can help me to stretch the list for this POPUP 'DD_POPUP_WITH_LIST', I used the following parameters:
                start_column = 50
                start_row       = 10
                end_column   = 90
                end_row         = 30
    But the breadth of the list is still small compared to the list of the fields that I want displayed.
    thanks in advance.
    Mustapha
    Edited by: Mustapha ABAPER on Apr 21, 2008 10:39 AM
    Edited by: Mustapha ABAPER on Apr 21, 2008 10:46 AM

    thanks Venkat,
    But if i use ur parameters, the pop up will be very small
    u can try this parameters in exection of this popup in SE37 to see the difrence
    START_COLUMN = 1
    START_ROW = 1
    END_COLUMN = 00
    END_ROW = 15
    best regards
    Mustapha

  • Help plzzzzzzzzzz

    i am doing calculates and prints the cost of an international phone and i have allready done the first part where i have to put calculates
    but i am stuck with the second part where its says i have to
    Your program will need to enter the country called from the user. In particular:
    Prompt the user to enter a g for Germany or an i for India.
    Use the Scanner object to read in a String from the user and use the charAt method of the String class to obtain the first character of that String.
    If the first character is an 'i', 'I', 'g', or 'G', continue on to the next step. Otherwise, display a message to the user that indicates they have entered an invalid country. In the latter case, the program is now done.
    so i have to creat new Scanner right ?
    this is my calculation
    static BufferedReader keyboard = new
    BufferedReader(new InputStreamReader(System.in));
    //Named constants
    static final double CONNECTION_FEE = 1.99;
    static final double FIRST_THREE_MIN_FEE = 2.00;
    static final double COST_OF_EACH_ADDITIONAL_MIN = 0.45;
    public static void main(String[] args) throws IOException
    //Variable declaration
    int noOfMinCallLasted;
    double amountDue;
    DecimalFormat twoDigits =
    new DecimalFormat("0.00");
    System.out.println("This program computes an international phone call.");
    System.out.print("Enter the number of minutes the call lasted: ");
    noOfMinCallLasted =
    Integer.parseInt(keyboard.readLine());
    System.out.println();
    if (noOfMinCallLasted<= 3)
    amountDue = CONNECTION_FEE +
    FIRST_THREE_MIN_FEE;
    else
    amountDue = CONNECTION_FEE +
    FIRST_THREE_MIN_FEE +
    (noOfMinCallLasted - 3) * COST_OF_EACH_ADDITIONAL_MIN;
    System.out.println("The number of minutes the call lasted was "
    + noOfMinCallLasted);
    System.out.println("Amount due = $"
    + twoDigits.format(amountDue));

    public static void main(String[] args)
                   Scanner letterScanner = new Scanner(System.in);
                   System.out.print("Enter your conutry letter (G - I): ");
                   String gradeText = letterScanner.next();
                   char grade = gradeText.charAt(0);
                   String reply;
                 switch (Country)
                          case 'G':      reply = "Germany!";
                                              break;
                          case 'I':      reply = "India!";
                                          break;
                          default:     reply = "Not a valid Country.";
                 System.out.println(reply);
    }

  • JComboBox Problem !!!!!!!!!!!!!!!! PLzzzzzzzzzz Help me out frnds...

    Hiiiiiii frmdsss...........im n deep trouble and need ur help immediately......im havin this prob with JComboBox....heres d code.....
    public void actionPerformed(ActionEvent ae)
              JButton source=(JButton)ae.getSource();
              //JComboBox source1=(JComboBox)ae.getSource();
              if(b1.equals(source))
                   cb1.setEnabled(true);
                   try
                        cb1.removeActionListener(this);
                        cb1.removeAllItems();
                        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                        con=DriverManager.getConnection("jdbc:odbc:MyDataSource","sa","");
                        stmt=con.createStatement();
                        rs=stmt.executeQuery("select prod_model from product where prod_type LIKE 'Mobile'");
                        while(rs.next())
                             cb1.addItem(String.valueOf(rs.getString(1)));
                        con.close();
                   }catch(ClassNotFoundException c)
                        System.out.println("Error "+c);
                   catch(SQLException e)
                        System.out.println("Exception"+e.toString());
                   cb1.addActionListener(this);
    if(ae.getSource() == cb1)
                   /*try
                   {          //cb1.removeActionListener(this);
                             //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                             /*con=DriverManager.getConnection("jdbc:odbc:MyDataSource","sa","");
                             String selected_id=cb1.getSelectedItem().toString();
                             stmt=con.createStatement();
                             rs=stmt.executeQuery("SELECT * FROM PRODUCT WHERE prod_model LIKE 'S%'");
                             if(rs.next())
                                  JOptionPane.showMessageDialog(fr,"USER NAME IDENTIFIED","CONFIRMATION",JOptionPane.INFORMATION_MESSAGE);
                             con.close();          
                   /*catch(ClassNotFoundException c)
                        System.out.println("Error "+c);
                   catch(SQLException e)
                        System.out.println("EXception"+e.toString());
    It gives me a huge list of errors..........
    java.lang.ClassCastException
    at Order.actionPerformed(Order.java:86)
    at javax.swing.JComboBox.fireActionEvent(Unknown Source)
    at javax.swing.JComboBox.setSelectedItem(Unknown Source)
    at javax.swing.JComboBox.setSelectedIndex(Unknown Source)
    at javax.swing.plaf.basic.BasicComboPopup$ListMouseHandler.mouseReleased
    Source)
    at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.plaf.basic.BasicComboPopup$2.processMouseEvent(Unknown So
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)...
    PLzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz help me frnds.......i hve 2 submit this prjkt on Thursdy

    The forum is fore heping out othersAnd that is exactly what I did. You won't get much help in the future if you don't change your habbits. In fact I'm surprised you got help this time.
    It's your responsibility to make a question easy to read, not to make it difficult to read by (among other things):
    a) holding the repeat key down
    b) not spelling out words
    Heck you can't even post formatted code to make it easy for people to read. Do you write your code with every line left aligned? I doubt it and we don't want to read it either.
    So learn how to use the forum properly.

  • Urgent - (session bean calling Entity bean )Help Need for me - Plzzzzzzzzzz

    Hi
    I am created two beans one is Entity bean another one is session . the two beans deployed using diffrent jar files
    . I call the Entity bean methods using session bean
    But i couldn't locate the entity bean Home object through session bean(
    Sub is created but i couldn't get it that home obj stub)
    i get the following error messgae CorbaBad Operation
    i deployed two bean using same jar means my program is working
    Help meeeeeee

    I Send part of code to u
    public String logic1(rsp.ejbbm.ex.studVO s) {
              rsp.ejbbm.student.studentRemote r=null;
              String id = null;
              try {
    System.out.println("sdfsdfsdfs");
              Object obj = ctx.lookup("ejb/student");
              System.out.println("Lookup Succeded ");
              System.out.println("Object value" +obj.toString());
    /// HERE I GOT THE ERRO I COULDn'T Locate IT
    EJBHome obj1 =(EJBHome)javax.rmi.PortableRemoteObject.narrow(obj,rsp.ejbbm.student.studentHome.class);
              System.out.println("Object value" +obj1.toString());
              rsp.ejbbm.student.studentHome home=(rsp.ejbbm.student.studentHome)obj1;
              //studentHome hom=(studentHome)ctx.lookup("ejb/student");
         System.out.println("Object value" +obj.toString() );
         System.out.println("Lookup Converted ");
              home.create(s.getRollno(),s.getName());
              System.out.println("student Record isInserted in Oracle ");
              r= (rsp.ejbbm.student.studentRemote) home.findByPrimaryKey(s.getRollno());
              System.out.println("Student 5555 Name is "+ r.getName());
              id = r.getName();
              catch(Exception e ){
              System.out.println(e.toString());}
              return id;
    * @see javax.ejb.SessionSynchronization#afterBegin()
    public void afterBegin() {
    * @see javax.ejb.SessionSynchronization#afterCompletion(boolean)
    public void afterCompletion(boolean committed) {
    * @see javax.ejb.SessionSynchronization#beforeCompletion()
    public void beforeCompletion() {
    * See section 7.10.3 of the EJB 2.0 specification
    public void ejbCreate() {
              Properties p = new Properties();
              p.put("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory");
              try{
         ctx = new InitialContext(p);
         catch(Exception e) {System.out.println("Create Exception "+e.toString());}
    }

  • DbTier:RC-50004 Error occurred in ApplyDatabase:help me plzzzzzzzzzz

    HI,
    Am on 11.5.10.2
    DB 10gR2
    OS Red Hat Enterprise Linux AS release 4 (Nahant Update 6)
    When am trying to clone dbtier am facing this error :
    Beginning database tier Apply - Wed Jun 22 14:00:53 2011
    Log file located at /stageDB/proddb/10.2.0/appsutil/log/PROD_rofdbs5/ApplyDBTier_06221400.log
    RC-50004: Fatal: Error occurred in ApplyDatabase:
    Control file creation failed
    Before taking the source backup :
    i did the following
    1. Autoconfig - completed successfully.
    2.preclone
    3.Shutdown database (normal, innmediate) & stop listener
    4.Copy the soutce to target using scp -r root@hostname:/stageDB
    log file
    vi /stageDB/proddb/10.2.0/appsutil/log/PROD_rofdbs5/ApplyDBTier_06221400.logLoading ORACLE_HOME environment from /stageDB/proddb/10.2.0
    Logfile: /stageDB/proddb/10.2.0/appsutil/log/PROD_rofdbs5/06221400/NetServiceHandler.log
    Error generating tnsnames.ora from the database, temperory tnsnames.ora will be generated using templates
    Instantiating templates
    tnsnames.ora instantiated
    listener.ora instantiated
    adgentns.pl exiting with status 25600
    ERRORCODE = 25600 ERRORCODE_END
    log file
    /stageDB/proddb/10.2.0/appsutil/log/PROD_rofdbs5/06221400/NetServiceHandler.logClasspath : /stageDB/proddb/10.2.0/jdk/jre/lib/rt.jar:/stageDB/proddb/10.2.0/jdk/lib/dt.jar:/stageDB/proddb/10.2.0/jdk/lib/tools.jar:/stageDB/proddb/10.2.0/jdbc/lib/ojdbc14.jar:/stageDB/proddb/10.2.0/appsutil/java/xmlparserv2.zip:/stageDB/proddb/10.2.0/appsutil/java:/stageDB/proddb/10.2.0/jlib/netcfg.jar:/stageDB/proddb/10.2.0/jlib/ldapjclnt10.jar
    ===============================================================================
    NetServiceHandler 115.54 started for rofdbs5 at Wed Jun 22 14:00:59 GST 2011
    ===============================================================================
    [ Context Information ]
    Host : rofdbs5
    Domain : reyamidbs.com
    Out Dir : /stageDB/proddb/10.2.0/appsutil/out/PROD_rofdbs5/06221400
    Tier Type : DATABASE TIER
    Getting connection...
    ADX Database Utility
    getConnectionUsingAppsJDBCConnector() -->
    APPS_JDBC_URL='null'
    Trying to get connection using SID based connect descriptor
    getConnection() -->
    sDbHost : rofdbs5
    sDbDomain : reyamidbs.com
    sDbPort : 1521
    sDbSid : PROD
    sDbUser : apps
    Trying to connect using SID...
    getConnectionUsingSID() -->
    JDBC URL: jdbc:oracle:thin:@rofdbs5.reyamidbs.com:1521:PROD
    Exception occurred: java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
    Trying to connect using SID as ServiceName
    getConnectionUsingServiceName() -->
    JDBC URL: jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rofdbs5.reyamidbs.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=PROD)))
    Exception occurred: java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
    Trying to connect using SID as ServiceName.DomainName
    getConnectionUsingServiceName() -->
    JDBC URL: jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rofdbs5.reyamidbs.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=PROD.reyamidbs.com)))
    Exception occurred: java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
    Connection could not be obtained; returning null
    -------------------ADX Database Utility Finished---------------
    Could not get connection to the database.
    Exiting with status 100 to instantiate the tnsnames.ora template
    Creation of Directory - /stageDB/proddb/10.2.0/network/admin/PROD_rofdbs5 Succeeded.
    instantiate file:
    source : /stageDB/proddb/10.2.0/appsutil/template/ad8itns.ora
    dest : /stageDB/proddb/10.2.0/network/admin/PROD_rofdbs5/tnsnames.ora
    AutoConfig is exiting with status 0
    instantiate file:
    source : /stageDB/proddb/10.2.0/appsutil/template/ad8ilsnr.ora
    dest : /stageDB/proddb/10.2.0/network/admin/PROD_rofdbs5/listener.ora
    AutoConfig is exiting with status 0
    adgentns.pl exiting with status 25600
    ERRORCODE = 25600 ERRORCODE_END
    Thanks
    Edited by: 843272 on Jun 22, 2011 3:21 AM
    Edited by: 843272 on Jun 22, 2011 5:55 AM

    Log file located at /stageDB/proddb/10.2.0/appsutil/log/PROD_rofdbs5/ApplyDBTier_06221400.log
    RC-50004: Fatal: Error occurred in ApplyDatabase:
    Control file creation failedThis error indicates that the database was not created successfully.
    Rapid Clone Failed While Running "Adcfgclone.pl dbTier": ORA-01194 and RC-00118 [ID 375389.1]
    Adcfgclone.pl DBTier is failing with error for dbms_backup_restore.zeroDbid(0) [ID 361157.1]
    Thanks,
    Hussein

  • Plzzzzzzzzzz help

    i moved the form into application server , complies it there ,, now i want to access it from client machine through URL .
    when i write a URL in address bar in internet explorer window then press go button to call that module from application server .
    internet explorer show this message :
    [ internet explorer has encountered a problem and needs to close .we are sorry for the inconvenience and there is three buttons , debug , send error report , dont send ]
    and whatever button you pressed the window will be closed automatically and disappeared without any result returned

    try any other browser and see if you can access your application, also send what URL you type in your browser window with port no.
    try firefox or opera browsers.

  • "DSN not found error" plz help me.

    am doing my project in jsp. using tomcat.
    am connecting the database using access.
    it cause the error like " DSN not found error"
    am verified so many times the data source name as well as data base connection.
    but not to be clear the error.
    am also tried it in weblogic, it worked perfectly.
    then am reinstall the tomcat and used other platform but not worth.
    plzzzzzzzzzz some one help me to clear the error.
    thanx in advance.
    with regards,
    senthil

    I think you can see again file faces-config.xml.
    You check the tag <faces-config>, it must be
    <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
    version="1.2">
    //body tag
    </faces-config>

  • DSN not found error and no default driver specified....plz help me

    am doing my project in jsp. using tomcat.
    am connecting the database using access.
    it cause the error like " DSN not found error"
    am verified so many times the data source name as well as data base connection.
    but not to be clear the error.
    am also tried it in weblogic, it worked perfectly.
    then am reinstall the tomcat and used other platform but not worth.
    plzzzzzzzzzz some one help me to clear the error.
    thanx in advance.
    with regards,
    senthil

    Yes, it has a DSN. It is:
    DSN Test Homer
    User Name ******
    Server homer.cs.odu.edu
    The connection string is:
    Provider=MSDASQL.1;Password=*******;Persist Security Info=True;User ID=******;Extended Properties="DSN=Test Homer;UID=******;PWD=******;SERVER=homer.cs.odu.edu;"
    with the appropriate user name and password filled in.

  • Help with xml  menu

    hai to all,
    i am struck with a problem. plzzzzzzzzzz help
    i have 6 menus where the text is displayed from a html file.i
    kept the text box in a movieclip.its fine working.
    now the problem arises.
    when the mouse is over the menu the respective xml will be
    loaded into the flash.
    this is for menu1_mc
    on (press, rollOver) {
    _root.main("menu1.xml");
    this is for menu2_mc
    on (press, rollOver) {
    _root.main("menu2.xml");
    the xml will be loaded depending upon the nodes one mc here
    "menuItem" will be duplicated and displayed.
    menu1 it is displaying fine.but
    for the menu2_mc it is displaying the contents of the menu2 +
    menu1 contents
    means for menu1 there r 10 menus. ok displaying, if for menu2
    there r 6 menus it is displaying the 6 menus with menu1's bottom 4
    menus.
    means the menu1 contents r not erasing or they should not
    displayed. any help plzzzzzzzzzzzzz
    here is the code:-
    function main(path) {
    var menu:XML = new XML();
    menu.ignoreWhite = true;
    menu.load(path);
    menu.onLoad = function() {
    items = this.firstChild.childNodes;
    for (a=0; a<=items.length-1; a++)
    _root.attachMovie("menuItem", "item"+a, a);
    _root["item"+a].nametxt.text = items[a].attributes.id;
    _root["item"+0]._y = 18;
    _root["item"+1]._y = 38;
    _root["item"+2]._y = 58;
    _root["item"+3]._y = 78;
    _root["item"+4]._y = 98;
    _root["item"+5]._y = 118;
    _root["item"+6]._y = 138;
    _root["item"+7]._y = 158;
    _root["item"+8]._y = 178;
    _root["item"+9]._y = 198;
    _root["item"+10]._y = 218;
    _root["item"+a]._x = 180;
    _root["item"+a].itemUrl = items[a].attributes.theurl;
    _root["item"+a].method = items[a].attributes.method;
    _root["item"+a].onRollOver = function() {
    this._x+=10;
    _root["item"+a].onRollOut = function() {
    this._x-=10;
    _root["item"+a].onRelease = function() {
    getURL(this.itemUrl, this.method);

    sir,here i am attaching fla and xml file which are in zip
    format. i am using flash mx 2004 version. but sir how to upload the
    zip file i can get. can u suggest me plz

  • Blackberry 8700 going restarts....plz help me

    I download a software from internet and during the installation on blackberry 8700 a problem occured and my blackberry going restarts agains and again.......if anyone can solve this problem then plzzzzzzzzzz tell me......thanx

    Oh dear oh dear...see this article:
    http://crackberry.com/blackberry-101-lecture-12-how-reload-operating-system-nuked-blackberry
    Hopefully you already have a recent backup from which to restore...
    Good luck and let us know.
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Need help in my PROJect

    I would like to get the data from JDBC............ like this
    +6. What is the advantage of using import statements?+
    A .To avoid having to declare variables.
    B.To refer to a class without using prefixes.
    C.To avoid calling methods.
    D.To import the images you want to use.
    So i created tables for the each questoin (its an online examination project) i have to enter the questions for SAP,J2ee,.NET like this.........
    *._so creating a table for each question*_ .............means DB size is large and so many tables i have to create ...........
    creating Entire table for each language from where ............is there any method to getData of one particular question RANDOMLY.........(AS shown ABOVE)
    Thx in advance plzzzzzzzzzz help me.......................

    Hi Buddy,
    Again you question is like a pool of things. Please dont do it, make a proper format for your question then post it.
    So that the answer provider will bang right at target.
    You can implement things at Application Level surely. For random question stuff, If you want then assign one more column to your Table & in that assign level's for question(1-Hard, 2-Average,3-Easy ). And inside your random selection make one level based on previous question answered.
    Sachin Kokcha

  • Problem with threads and simulation: please help

    please help me figure this out..
    i have something like this:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DrawShapes extends JApplet{
         private JButton choices[];
         private String names[]={"line", "square", "oval"};
         private JPanel buttonPanel;
         private DrawPanel drawingArea;
         private int width=300, height=200;
         public void init(){
              drawingArea=new DrawPanel(width, height);
              choices=new JButton[names.length];
              buttonPanel=new JPanel();
              buttonPanel.setLayout(new GridLayout(1, choices.length));
              ButtonHandler handler=new ButtonHandler();
              for(int i=0; i<choices.length; i++){
                   choices=new JButton(names[i]);
                   buttonPanel.add(choices[i]);
                   choices[i].addActionListener(handler);
              Container c=getContentPane();
              c.add(buttonPanel, BorderLayout.NORTH);
              c.add(drawingArea, BorderLayout.CENTER);
         }//end init
         public void setWidth(int w){
              width=(w>=0 ? w : 300);
         public void setHeight(int h){
              height=(h>=0 ? h : 200);
         /*public static void main(String args[]){
              int width, height;
              if(args.length!=2){
                   height=200; width=300;
              else{
                        width=Integer.parseInt(args[0]);
                        height=Integer.parseInt(args[1]);
              JFrame appWindow=new JFrame("An applet running as an application");
              appWindow.addWindowListener(
                   new WindowAdapter(){
                        public void windowClosing(WindowEvent e){
                             System.exit(0);
              DrawShapes appObj=new DrawShapes();
              appObj.setWidth(width);
              appObj.setHeight(height);
              appObj.init();          
              appObj.start();
              appWindow.getContentPane().add(appObj);
              appWindow.setSize(width, height);
              appWindow.show();
         }//end main*/
         private class ButtonHandler implements ActionListener{
              public void actionPerformed(ActionEvent e){
                   for(int i=0; i<choices.length; i++){
                        if(e.getSource()==choices[i]){
                             drawingArea.setCurrentChoice(i);
                             break;
    }//end class DrawShapes
    class DrawPanel extends JPanel{
         private int currentChoice=-1;
         private int width=100, height=100;
         public DrawPanel(int w, int h){
              width=(w>=0 ? w : 100);
              height=(h>=0 ? h : 100);
         public void paintComponent(Graphics g){
              super.paintComponent(g);
              switch(currentChoice){
                   case 0:     g.drawLine(randomX(), randomY(), randomX(), randomY());
                             break;
                   case 1: g.drawRect(randomX(), randomY(), randomX(), randomY());
                             break;
                   case 2: g.drawOval(randomX(), randomY(), randomX(), randomY());
                             break;
         public void setCurrentChoice(int c){
              currentChoice=c;
              repaint();          
         private int randomX(){
              return (int) (Math.random()*width);
         private int randomY(){
              return (int) (Math.random()*height);
    }//end class drawPanel
    That one's from a book. I used that code to start with my applet. Mine calls different merthod from the switch cases. Say I have:
    case 0: drawStart(g); break;
    public void drawStart(Graphics g){
      /* something here */
    drawMain(g);
    public void drawMain(graphics g){
    g.drawString("test", x, y);
    //here's where i'm trying to pause
    //i've tried placing Thread.sleep between these lines
    g.drawLine(x, y, a, b);
    //Thread.sleep here
    g.drawRect(x, y, 50, 70);
    }I also need to put delays between method calls but I need to synchronize them. Am I doing it all wrong? The application pauses or sleeps but afterwards, it still drew everything all at once. Thanks a lot!

    It is. Sorry about that. Just answer any if you want to. I'd appreciate your help. Sorry again if it caused you anything or whatever. .n_n.

  • Query Help

    Table1:
    ou store point
    LS LIB1 50
    LS LIB1 200
    LS LIB1 100
    LS LIB1 79
    I have to insert table1 to table2 by splitting into every 143point and assing serial number for every 143 from parameter.
    in aboce example we can split 3 time 143 like below table2 sample.
    Table2
    ou store point serial_number
    LS LIB1 50 101
    LS LIB1 93 101
    LS LIB1 107 102
    LS LIB1 36 102
    LS LIB1 64 103
    LS LIB1 79 103
    i tried below procedure its not working.
    table may have any order like below.
    Table1:
    ou store point
    LS LIB1 200
    LS LIB1 50
    LS LIB1 100
    LS LIB1 79
    then table2
    ou store point serial_number
    LS LIB1 143 101
    LS LIB1 57 102
    LS LIB1 50 102
    LS LIB1 36 102
    LS LIB1 64 103
    LS LIB1 79 103
    create or replace procedure assign_serial(from_num number,to_num number) is
    bal number(10);
    begin
    bal := 0;
    for c1 in(select * from table1)
    loop
    if c1.point <=143 then
    if bal=0 then
    bal=143-used;
    insert int0 table2 values(c1.ou,c1.store,used);
    elsif used > 0 then
    used=used-bal;
    insert int0 table2 values(c1.ou,c1.store,bal);
    bal=0;
    if used > 0 then
    insert int0 table2 values(c1.ou,c1.store,used);
    end if;
    bal:=143-used;
    end if;
    end loop;
    end;
    How to split and assign serial number,please hELP.

    .after giving serial num i have to change points in table1 to 0.The problem for SUm and split for every 143 is ,different OU and store is there.we have to know for which store points we earned serial number.
    i hope this below logic little satisfy except assign cardnum,please........ check and currect the logic
    LS LIB1 50
    LS LIB1 200
    LS LIB1 100
    LS LIB1 79
    --variable used and bal
    for c1 in(select * from table1)
    loop
    used := c1.points;
    if c1.point <=143 then
    if bal=0 then
    bal=143-used;
    insert int0 table2 values(c1.ou,c1.store,used);
    elsif used > 0 then
    used=used-bal;
    insert int0 table2 values(c1.ou,c1.store,bal);
    bal=0;
    if used > 0 then
    insert int0 table2 values(c1.ou,c1.store,used);
    end if;
    bal:=143-used;
    end if;
    end loop;

Maybe you are looking for

  • How to Deploy ECperf on Oracle Application Server

    Hi, I have deployed the ECperf benchmark on Oracle Application Server. I am trying to run the driver.sh script from ECperf/bin directory. I have got the following error while running the driver.sh O1:0: Failure looking up home javax.naming.NoInitialC

  • Inbound Email Attachments with MIME type of application/octet-stream

    I'm hoping someone can help me here. I'm trying to start a BPEL process via email. The email can consist of no attachments or multiple attachments. All the attachments should be text, e.g. XML, CSV, etc. Where I have got to is receiving the email and

  • Replacing Oracle Toplink with TopLink Essentials

    Is it possible to force OC4J to use TopLink Essentials by default instead of Oracle TopLink?

  • Calculate average for some dates

    Hi, I would like to calculate average for some dates. Is there any function module or any process, please provide me. venkat.

  • Create Transfer Order inbound using an Idoc

    Hi all, I need some help on solving the error message-  In our senario we want to send an Idoc (Create Transfer order ) from external system to SAP. Hence i have done mapping for the idoc but everytime i process the idoc- it comes with an error the s