Could error check this code

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.lang.Math.*;
import javax.swing.*;
public class YValue extends JApplet implements ActionListener
    JTextField xminField;
    JTextField xmaxField;
    JTextField iterField;
    JTextArea xyvalArea;
    JLabel xminLabel;
    JLabel xmaxLabel;
    JLabel iterLabel;
    JLabel xyvalLabel;
    JButton calcButton;
    public void init()
        setBounds(500, 500, 500, 500);
        Container pane = getContentPane();
        pane.setLayout(null);
        xminField           = new JTextField();
        xminField.setBounds(70, 10, 60, 25);
        xmaxField           = new JTextField();
        xmaxField.setBounds(70, 40, 60, 25);
        iterField          = new JTextField();
        iterField.setBounds(70, 70, 60, 25);
        xyvalArea          = new JTextArea();
        xyvalArea.setEditable(true);
        xyvalArea.setBounds(10, 130, 200, 200);
        JScrollPane scrollPane = new JScrollPane(xyvalArea);
        scrollPane.setBounds(10, 130, 200, 200);
        pane.add(scrollPane);
        xminLabel           = new JLabel("X - Min:");
        xminLabel.setBounds(10, 10, 60, 25);
        xmaxLabel           = new JLabel("X - Max:");
        xmaxLabel.setBounds(10, 40, 60, 25);
        iterLabel          = new JLabel("Iteration:");
        iterLabel.setBounds(10, 70, 60, 25);
        xyvalLabel          = new JLabel("X, Y - Values:");
        xyvalLabel.setBounds(10, 100, 100, 25);
        calcButton          = new JButton("Calculate:");
        calcButton.addActionListener(this);
        calcButton.setBounds(150, 40, 90, 20);
        pane.add(xminLabel);
        pane.add(xminField);
        pane.add(xmaxLabel);
        pane.add(xmaxField);
        pane.add(iterLabel);
        pane.add(iterField);
        pane.add(xyvalLabel);
        pane.add(xyvalArea);
        pane.add(calcButton);
        setContentPane(pane);
          setVisible( true );
    public void actionPerformed(ActionEvent e)
          xyvalArea.setText("");
          // get values from fields and convert to float
          String xminStr      = xminField.getText();                         // get input as string
          int xmin           = Integer.parseInt(xminStr);               // convert to integer
          float xminFl      = Float.valueOf(xminStr).floatValue();     // convert to float
          String xmaxStr      = xmaxField.getText();                         // get input as string
          int xmax           = Integer.parseInt(xmaxStr);               // convert to integer
          String iterStr      = iterField.getText();                         // get input as string
          int iter           = Integer.parseInt(iterStr);               // convert to integer
          float iterFl      = Float.valueOf(iterStr).floatValue();     // convert to float
          // create variables for purposes of calculating distance between two X values
          int neg      = -1;                                                  // create variable with value minus one
          neg           = (xmin * neg);                                        // multiply minimum X value by -1 to get positive value
          int length      = (neg + xmax);                                        // add minimum and maximum X values to get distance between them
          float xmin2Fl = (xminFl * xminFl);                              // minimum X value squared reamins constant
          // loop which lasts the distance between two X values
          for(int i = 0; i<=length; i = i + iter)
               float xmin2tmp      = (xminFl * xminFl);                    // current x2
               float xmin3tmp     = (xmin2Fl - xmin2tmp);                    // minimum x2 minus current x2
               double y           = Math.sqrt(xmin3tmp);                    // get square root of x2 - x*x
               String output      = ("(" + xminFl +", "+ y + ")");     // output (x, y)
               xyvalArea.append(output + "\n");                         // append to textArea with a new line
               xminFl = (xminFl + iterFl);                               // move X value to next iterval point
}the scroll bar wont work at all and a white box the size of the text area appears in the top left corner when i run the applet every so often...
any help would be great.
cheers

this is whats happening..
i copied .java file to new location, compiled and ran, still screws up every few times i run it.
what is:
http://img191.imageshack.us/img191/2439/whatis7sb.jpg
what should:
http://img191.imageshack.us/img191/5854/whatshud7md.jpg

Similar Messages

  • Could anyone check this code for errors for me??

    Hi! Could someone please tell me if you see any problems with this code?? a friend wants me to check it for errors, but can't find any. I just wanted to make sure, because there are probably a lot of better scripters than me reading this. Please answer soon!!
    heres the code:
    stop();
    addEventListener(Event.ENTER_FRAME, preLoad);
    function  preLoad(e:Event):void{
    var bytestoLoad):Number = loaderInfo.bytesTotal; 
    var numberLoaded:Number = loaderInfo.bytesLoaded;
    if (bytestoLoad ==  numberLoaded) {
    removeEventListener)Event.ENTER_FRAME, preLoad) 
    gotoAndStop(2);
    }else {
    preLoader.preLoaderFill.scaleX =  numberLoaded/bytestoLoad;
    preLoader.bytePercent.text = Math.floor  (numberLoaded/bytestoLoad*100) + "%";
    Thanks!!
    -Sammy

    I ran it on debug mode and changed it to this? see any problems now? or are they fixed? It looks to me like it took some actions out, I hope that doesn't
    effect it....
    stop();
    addEventListener(Event.ENTER_FRAME, preLoad);
    function preLoad(e:Event):void{
    var bytestoLoad):Number = loaderInfo.bytesTotal;
    var numberLoaded:Number = loaderInfo.bytesLoaded;
    if (bytestoLoad == numberLoaded) {
    removeEventListener)Event.ENTER_FRAME, preLoad)
    gotoAndStop(2);
    i'm kinda new to flash ((I started as a lua scripter (on Roblox)) so I'm a little confused about this. Thanks for the help!!

  • Could you check this code ??

    Hi Guyz,
      Here is my piece of code.
    FORM get_infotype_data TABLES pi_it0001_tbl      TYPE  t_it0001_tbl
                                  pi_emp_info_tbl    TYPE  t_emp_info_tbl
                                  pi_event_dates_tbl TYPE  t_event_dates_tbl
                                  po_emp_tab_tbl     TYPE  t_emp_tab_tbl.
      DATA: l_it0001_tbl   TYPE t_it0001_tbl,
            l_it0001_str   TYPE t_it0001_str,
            l_emp_info_tbl TYPE t_emp_info_tbl,
            l_emp_info_str TYPE t_emp_info_str,
            l_event_dates_str TYPE t_event_dates_str,
            l_emp_tab_tbl  TYPE t_emp_tab_tbl,
            l_emp_tab_str  TYPE t_emp_tab_str.
      SORT: pi_it0001_tbl      BY  pernr,
            pi_emp_info_tbl    BY  pernr,
            pi_event_dates_tbl BY  pernr.
      LOOP AT pi_it0001_tbl INTO l_it0001_str.
        READ TABLE pi_emp_info_tbl
        WITH KEY pernr = l_it0001_str-pernr BINARY SEARCH.
        IF sy-subrc = 0 .
        clear l_emp_info_str.
          MOVE: l_emp_info_str-perid TO l_emp_tab_str-perid,
                l_emp_info_str-gbdat TO l_emp_tab_str-gbdat.
          CASE l_emp_info_str-gesch.
            WHEN '1'.
              MOVE 'M' TO l_emp_tab_str-gesch.
            WHEN '2'.
              MOVE 'F' TO l_emp_tab_str-gesch.
          ENDCASE.
        ENDIF.
        READ TABLE pi_event_dates_tbl WITH KEY pernr = l_it0001_str-pernr
        BINARY SEARCH.
        IF sy-subrc = 0.
          MOVE: l_event_dates_str-betrg TO l_emp_tab_str-betrg.
        ENDIF.
        MOVE l_emp_tab_str TO po_emp_tab_tbl.
      ENDLOOP.
    ENDFORM.                                         " get_infotype_data
    I am not getting any data in to the table po_emp_tab_tbl.
    After rwading the table,  Getting sy-subrc = 0.
    Please help me.

    1. structure for both l_emp_tab_str and  po_emp_tab_tbl are different.
    2. move one by one field to dest. structure.
    3. check whether data is populating in the l_emp_tab_str .
    4. as well as in int. table pi_it0001_tbl.
    5. u defined the stru. for po_emp_tab_tbl as a work area.
    wheterh it should be work area or table?
    if its table, define table type

  • RUN TIME ERROR IN THIS CODE

    HELLO EVERY ONE ...
    I AM GETTING run time error in this code.....can u send me the corrected code....
    START-OF-SELECTION.
    SELECT T1~MATNR
           T1~MEINS
           T1~ERSDA
           T1~ERNAM
           T1~SPART
           T2~MAKTX
           T3~LVORM
           T3~EKGRP
           T3~WERKS
           T4~LABST
           T4~SPEME
           T4~LGORT
           INTO CORRESPONDING FIELDS OF TABLE ITAB
           FROM MARA AS T1
           INNER JOIN MAKT AS T2
           ON T1MATNR = T2MATNR
           INNER JOIN MARC AS T3
           ON T2MATNR = T3NFMAT
           INNER JOIN MARD AS T4
           ON T3MATNR = T4MATNR
           WHERE T1~MATNR IN SMATNR.
    Thanx & Regards,
    PHANINDER

    ok i am sending u the full code.....
    REPORT  Z_SB_RP_MATERIAL.
    TABLES: MARA,
            MARD,
            MAKT,
            MARC,
            EINA,
            EINE.
    DATA: BEGIN OF ITAB OCCURS 15,
          MATNR LIKE MARA-MATNR,
          MEINS LIKE MARA-MEINS,
          ERSDA LIKE MARA-ERSDA,
          ERNAM LIKE MARA-ERNAM,
          SPART LIKE MARA-SPART,
          MAKTX LIKE MAKT-MAKTX,
          LVORM LIKE MARC-LVORM,
          EKGRP LIKE MARC-EKGRP,
          WERKS LIKE MARC-WERKS,
          LABST LIKE MARD-LABST,
          SPEME LIKE MARD-SPEME,
          LGORT LIKE MARD-SPEME,
          END OF ITAB.
    SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-T01.
    SELECT-OPTIONS: SMATNR FOR MARA-MATNR,
                    SERSDA FOR MARA-ERSDA,
                    SWERKS FOR MARC-WERKS,
                    SLGORT FOR MARD-LGORT.
    SELECTION-SCREEN END OF BLOCK BLK.
    TOP-OF-PAGE.
    WRITE:/ SY-VLINE,
          02 'S.NO',
          06 SY-VLINE,
          08 'MATNR',
          20 SY-VLINE,
          22 'MEINS',
          32 SY-VLINE,
          34 'ERSDA',
          44 SY-VLINE,
          46 'ERNAM',
          56 SY-VLINE,
          58 'SPART',
          68 SY-VLINE,
          70 'MAKTX',
          80 SY-VLINE,
          82 'LVORM',
          92 SY-VLINE,
          94 'EKGRP',
         104 SY-VLINE,
         106 'WERKS',
         116 SY-VLINE,
         118 'LABST',
         128 SY-VLINE,
         130 'SPEME',
         140 SY-VLINE,
         142 'LGORT',
         152 SY-VLINE.
    START-OF-SELECTION.
    SELECT T1~MATNR
           T1~MEINS
           T1~ERSDA
           T1~ERNAM
           T1~SPART
           T2~MAKTX
           T3~LVORM
           T3~EKGRP
           T3~WERKS
           T4~LABST
           T4~SPEME
           T4~LGORT
           INTO CORRESPONDING FIELDS OF TABLE ITAB
           FROM MARA AS T1
           INNER JOIN MAKT AS T2
           ON T1MATNR = T2MATNR
           INNER JOIN MARC AS T3
           ON T2MATNR = T3NFMAT
           INNER JOIN MARD AS T4
           ON T3MATNR = T4MATNR
           WHERE T1~MATNR IN SMATNR.
    END-OF-SELECTION.
    DATA: COUNT(4) TYPE N.
    LOOP AT ITAB.
    COUNT = COUNT + 1.
      WRITE:/ SY-VLINE,
          02 COUNT,
          06 SY-VLINE,
          08 ITAB-MATNR,
          20 SY-VLINE,
          22 ITAB-MEINS,
          32 SY-VLINE,
          34 ITAB-ERSDA,
          44 SY-VLINE,
          46 ITAB-ERNAM,
          56 SY-VLINE,
          58 ITAB-SPART,
          68 SY-VLINE,
          70 ITAB-MAKTX,
          80 SY-VLINE,
          82 ITAB-LVORM,
          92 SY-VLINE,
          94 ITAB-EKGRP,
         104 SY-VLINE,
         106 ITAB-WERKS,
         116 SY-VLINE,
         118 ITAB-LABST,
         128 SY-VLINE,
         130 ITAB-SPEME,
         140 SY-VLINE,
         142 ITAB-LGORT,
         152 SY-VLINE.
    ENDLOOP.
    THANX & REGARDS,
    PHANINDER

  • Could you please check this code

    Hi There,
    The scenario here is :
    I have written this piece of code but its not showing desired result .I think the problem is in the AVGRANGE.
    Please look into this and let me know if I am doing anything wrong.
    I need to accomplish this task ,if employee E1 & E2 are in Entity1 in Grade S in forecast1 and now in forecast 2 a new employee namely E3 has come in this new forecast and whether he belongs to same entity can be identified by a new account say "F",If "F" is present for that Employee in that particular entity means he belongs to that Entity .Then I need to calculate.
    "P" value for E3 for a month=Avg of "P" value for E1 & E2 in Entity1 in Grade S for that month.
    I think this code is calculating for invalid combination also.
    FIX (&CurrFctScenario,&CurrFctVersion,&CurrYear)
    FIX (&SeedCurrency)
    FIX(@descendatns("Entity"),@descendatns(GRADE),@Descendants(Employee)
    FIX (&CurrMonth:"MAY"
    , &SeedHSP
    "P"(
    IF ( "F"!=#Missing AND "P"==#Missing)
    @AVGRANGE(SKIPNONE,"P",@children(Employee)->@currmbr(Grade)->@currmbr(entity));
    ENDIF;
    ENDFIX
    ENDFIX
    One more thing as I am testing this code for say two three employees then its working fine but as I am uisng @children(Employee) then I am getting error message
    Error: 1012704 Dynamic Calc processor cannot lock more than [200] ESM blocks during the calculation, please increase CalcLockBlock setting and then retry(a small data cache setting could also cause this problem, please check the data cache size setting).
    Is there any other way of doing this calculation?
    Edited by: user10760185 on Jun 1, 2011 5:35 AM

    Thanks a lot Alp...
    Please find the logic of the calculation below:
    In forecast1,here E1=employee,S1=Grade,P1=Account member
    E1->S1->Entity1->P1= 100
    E2->S1->Entity1->P1=200
    In forecast2,E3,a new employee has come and if he/she belongs to S1 and Entity1 ,then the value should be
    If (E3->F!->@currmbr(grade)->@currmbr(entity)=#Missing AND P1==#Missing)
    E3->S1->Entity1->P1= (100+200)/2
    I will read the document and will check my cache settings.
    Edited by: user10760185 on Jun 1, 2011 11:36 PM

  • ABAP Syntax error in this code - Could anyone help?

    Hi,
    I have this code which runs fine in our non-unicode SAP system.
    REPORT  ECC5_OFFSETS.
    DATA: W_KONV TYPE KONV.
    DATA: TKOMK LIKE STANDARD TABLE OF KOMK
                     WITH KEY KEY_UC
                     INITIAL SIZE 2
                     WITH HEADER LINE.
    DATA: TKOMK2 type STANDARD TABLE OF KOMK
                     WITH KEY KEY_UC
                     INITIAL SIZE 2.
    * Get some test data
    SELECT SINGLE * INTO W_KONV FROM  KONV
           WHERE  KNUMV  = '0000000061'.
    MOVE-CORRESPONDING W_KONV TO TKOMK.
    APPEND TKOMK.
    tkomk2[] = TKOMK[].
    * Original non-Unicode compliant code
    DATA: LENGTH_KEY_TKOMK(3) TYPE P.
    FIELD-SYMBOLS: <TKOMK_KEY> like TKOMK2.
    DESCRIBE DISTANCE BETWEEN TKOMK-MANDT AND TKOMK-SUPOS
              INTO LENGTH_KEY_TKOMK
    * ( Original Unicode syntax fix! )
              IN BYTE MODE.
    * Copy all the fields between these two into TKOMK_KEY field-symbol.
    * ( In Unicode this assignment fails, causing short dump at read )
    ASSIGN TKOMK2(LENGTH_KEY_TKOMK) TO <TKOMK_KEY>.
    * Read the current record.
    READ TABLE TKOMK2 WITH KEY <TKOMK_KEY>.
    But I get the following error message in our UNICODE complaint SAP system:
    <b>"<TKOMK_KEY>" cannot be a table, a reference, a string, or contain any of these objects.</b>     
    Does anyone know how I could get around this/suggest a solution?
    Thanks in advance!

    Hi,
    Sorry if I'm being unclear.
    My requirements are twofold:
    1)the line of code:
    ASSIGN TKOMK2(LENGTH_KEY_TKOMK) TO <TKOMK_KEY>
    does not assign anything to the fields symbol <TKOMK_KEY>
    2)The read statement does not like the fields symbol <TKOMK_KEY> being used as a key.
    Both these bits of code worked in our 4.6b system but now in the ECC5 environemtn I get syntax errors.
    Let me know if you need anything else!

  • Is there a error with this code

    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    public class ClickMe extends Applet implements MouseListener {
    private Spot spot = null;
    private static final int RADIUS = 7;
    public void init() {
    addMouseListener(this);
    public void paint(Graphics g) {
    //draw a black border and a white background
    g.setColor(Color.white);
    g.fillRect(0, 0, getSize().width - 1, getSize().height - 1);
    g.setColor(Color.black);
    g.drawRect(0, 0, getSize().width - 1, getSize().height - 1);
    //draw the spot
    g.setColor(Color.red);
    if (spot != null) {
    g.fillOval(spot.x - RADIUS, spot.y - RADIUS, RADIUS * 2, RADIUS * 2);
    public void mousePressed(MouseEvent event) {
    if (spot == null) {
    spot = new Spot(RADIUS);
    spot.x = event.getX();
    spot.y = event.getY();
    repaint();
    public void mouseClicked(MouseEvent event) {}
    public void mouseReleased(MouseEvent event) {}
    public void mouseEntered(MouseEvent event) {}
    public void mouseExited(MouseEvent event) {}
    When I compile the the code I get a "cannot resolve symbol"
    private Spot spot = null;
    spot = new Spot(RADIUS);
    I don't know if these are errors in the code

    'cannot resolve symbol' errors usually mean a problem with the declarations and initialisations at the start of your class. This is specifically to do with your line private Spot spot = null;
    i haven`t much time to look at your code, but i would suggest getting rid of the null initialisation here, and do you ever actually change this value? after a quick look it seems that you only query it to see if the variable spot is null. if you never affect this value, then it will always be null and only one if statement will ever be executed.
    but as i said i haven`t any time, so could be off here
    boutye - boss is coming bak argh!

  • URGENT Check this code for me please

    Dear whoeverthisreads, please read and see at the bottom my sourcecode, or whatever I could make of it until (even with help) I failed to see any solution. Please copy, paste and run to see if you can manage to adjust the program to make it work in the way as described. And I think I made it unnecessarily complicated. Whatever you can do for me, I will be very, very grateful.
    Prem Pradeep, email: [email protected]
    (A beginning dutch Java student who is running out of time and hope)
    Catalogue Manager
    Specification:
    a) Develop an object to represent to encapsulate an item in a catalogue. Each CatalogueItem has three pieces of information: an alphanumeric catalogue code, a name, and a price (in dollars and cents), that excludes sales tax. The object should also be able to report the price, inclusive of a 15% sales tax, and the taxed component of the price.
    b) Work out a way to be able to support the inc tax/ex tax price accessors, and the tax component accessor, without needing to store any additional information in the object.
    c) Use an array of 5 CatalogueItem items to store data. (You may assume that no imported goods will be recorded.)
    d) Write a driver program that prompts for three sets of user input (catalogue number, description and price), to be stored in the atalogueItem instance.
    e) The data are to be read for each item in a single line. The data lines will be in the format:
    CatNo:Description:Price
    Use a StringTokenizer object to separate these data lines into their components.
    f) Review the class definition of CatalogueItem, and use modifiers where appropriate to:
    � Ensure that data is properly protected;
    � Ensure that the accessors and mutators are most visible;
    � The accessors and mutators for the catalogue number and description cannot be overridden.
    � The constant for the tax rate is publicly accessible, and does not need an instance of the class
    present in order to be accessible.
    As well as a summary, the program should also calculate and display:
    � All of the cheapest and most expensive item(s) in the catalogue. In the case of more than one
    item being the cheapest (or most expensive), they should all be listed.
    � A total of the pre-tax worth of the goods in the catalogue.
    � The average amount of tax on the items in the catalogue.
    A sample execution of the program may be as follows (output should be tabulated):
    Enter five items of data:
    AA123: Telephone: 52.00
    ZJ282: Pine Table: 98.00
    BA023: Headphones: 23.00
    ZZ338: Wristwatch: 295.00
    JW289: Tape Recorder: 23.00
    LISTING OF ALL GOODS
    Cat      Description      ExTax           Tax           IncTax ~
    ZJ282      pine Table           98.00           14.70           112.70
    AA123 Telephone           52.00           7.80           59.80
    BA023 Headphones      23.00           3.45           26.45
    ZZ338      Wristwatch      295.00      44.25      339.25
    JW289 Tape Recorder      23.00           3.45           26.45
    CHEAPEST GOODS IN CATALOGUE
    Cat      Description      ExTax           Tax           IncTax
    BA023 Headphones           23.00           3.45           26.45
    JW289 Tape Recorder      23.00           3.45           26.45
    MOST EXPENSIVE GOODS IN CATALOGUE
    Cat      Description      ExTax           Tax           IncTax
    ZZ338      Wristwatch      295.00      44.25      339.25
    TOTAL PRE-TAX WORTH OF CATALOGUE ITEMS:      491.00
    AVERAGE AMOUNT OF TAX PAYABLE PER ITEM:      14.73
    The next code is what I could make of it�until I got terribly stuck...
    //CatalogueItem.java
    import java.io.*;
    import java.text.DecimalFormat;
    import java.util.StringTokenizer;
    public class CatalogueItem {
    private static final double TAXABLE_PERCENTAGE = 0.15;
    private String catalogNumber;
    private String description;
    private double price;
    /** Creates a new instance of CatalogueItem */
    public CatalogueItem() {
    catalogNumber = null;
    description = null;
    price = 0;
    public CatalogueItem(String pCatalogNumber, String pDescription, double pPrice) {
    catalogNumber = pCatalogNumber;
    description = pDescription;
    price = pPrice;
    void setCatalogNumber(String pCatalogNumber) {
    catalogNumber = pCatalogNumber;
    String getCatalogNumber() {
    String str = catalogNumber;
    return str;
    void setDescription(String pDescription) {
    description = pDescription;
    String getDescription() {
    String str = description;
    return str;
    void setPrice(String pPrice) {
    price = Double.parseDouble(pPrice);
    double getPrice() {
    double rprice = price;
    return formatDouble(rprice);
    double getTaxAmount(){
    double rTaxAmount = price * TAXABLE_PERCENTAGE;
    return formatDouble(rTaxAmount);
    double getIncTaxAmount() {
    double rTaxAmount = price * (1 + TAXABLE_PERCENTAGE);
    return formatDouble(rTaxAmount);
    double formatDouble(double value) {
    DecimalFormat myFormatter = new DecimalFormat("###.##");
    String str1 = myFormatter.format(value);
    // System.out.println("String is " + str1);
    // System.out.println("The format value : " + value);
    return Double.parseDouble(str1);
    public static void main(String[] args) throws IOException {
    final int MAX_INPUT_SET = 5;
    final String strQ = "Enter five items of data:";
    CatalogueItem[] catalogList = new CatalogueItem[MAX_INPUT_SET];
    String strInput;
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    String header = "Cat\tDescription\tExTax\tTax\tInc Tax";
    String lines = "---\t-----------\t------\t---\t-------";
    // Input of five items with three data each, delimiter ":"
    for (int i = 0; i < MAX_INPUT_SET; i++) {
    catalogList[i] = new CatalogueItem();
    System.out.print(strQ);
    strInput = stdin.readLine();
    StringTokenizer tokenizer = new StringTokenizer(strInput, ":" );
    String inCatNo = tokenizer.nextToken();
    String inDescr = tokenizer.nextToken();
    String inPrice = tokenizer.nextToken();
    catalogList.setCatalogNumnber(inCatNo);
    catalogList[i].setDescription(inDescr);
    catalogList[i].setPrice(inPrice);
    // Listing of all goods
    System.out.println("LISTING OF ALL GOODS");
    System.out.println(header);
    System.out.println(lines);
    for (int i = 0; i < MAX_INPUT_SET; i++) {
    System.out.println(
    catalogList[i].getCatalogNumber() + "\t" +
    catalogList[i].getDescription() + "\t" +
    catalogList[i].getPrice() + "\t" +
    catalogList[i].getTaxAmount() + "\t" +
    catalogList[i].getIncTaxAmount());
    // This should pick the cheapest and most expensive goods in catalogue, but
    // this code is not good:
    // In the case of more than one item being the cheapest (or most expensive),
    // they should all be listed.
    double cheapest = cataloguelist[1].getPrice();
    double mostExpensive = cataloguelist[1].getPrice();
              for(int i=2; i< MAX_INPUT_SET; i++){
                   if (cataloguelist[i].getPrice < cheapest)
              cheapest = i;}
              for(int i=2; i< MAX_INPUT_SET; i++){
                   if (cataloguelist[i].getPrice > mostExpensivet)
              mostExpensive = i;}
    // Lists cheapest goods (not complete enough)
    i = cheapest;
    System.out.println("CHEAPEST GOODS IN CATALOGUE");
    System.out.println(header);
    System.out.println(lines);
    System.out.println(
    catalogList[i].getCatalogNumber() + "\t" +
    catalogList[i].getDescription() + "\t" +
    catalogList[i].getPrice() + "\t" +
    catalogList[i].getTaxAmount() + "\t" +
    catalogList[i].getIncTaxAmount());
    // Lists most expensive goods (not complete enough)
    i = mostExpensive;
    System.out.println("MOST EXPENSIVE GOODS IN CATALOGUE");
    System.out.println(header);
    System.out.println(lines);
    System.out.println(
    catalogList[i].getCatalogNumber() + "\t" +
    catalogList[i].getDescription() + "\t" +
    catalogList[i].getPrice() + "\t" +
    catalogList[i].getTaxAmount() + "\t" +
    catalogList[i].getIncTaxAmount());}}
    // Generates and shows total pre-tax worth of catalogue items (how??)
    // generates and shows amount of tax payable per item (how??)

    How is this:
    import java.io.*;
    import java.text.*;
    import java.util.*;
    public class Cat
         Vector items = new Vector();
    public Cat()
    public void read(String fname)
         FileReader     fr;
        BufferedReader br;
         String         str ="";
        try
             fr = new FileReader(fname);
            br = new BufferedReader(fr);
            while ((str = br.readLine()) != null && items.size() < 30)
                   if (!str.trim().equals(""))
                        StringTokenizer tokenizer = new StringTokenizer(str, ":");
                     String n = tokenizer.nextToken().trim();
                        String d = tokenizer.nextToken().trim();
                        String s = tokenizer.nextToken().trim();
                        double p = Double.parseDouble(s);
                        items.add(new Item(n,d,p));
            fr.close();
        catch (FileNotFoundException e)
            System.out.println("Input file cannot be located, please make sure the file exists!");
            System.exit(0);
        catch (IOException e)
            System.out.println(e.getMessage());
            System.out.println("Application cannot read the data from the file!");
            System.exit(0);
    public void displayAll()
         for (int j=0; j < items.size(); j++)
              Item item = (Item)items.get(j);
              System.out.println(item.toString());
    public void sort()
         Collections.sort(items);     
    public class Item implements Comparable
         String       number, description;
         double       price,pricep;
         final double TAXRATE = 0.15;
    public Item(String number, String description, double price)
         this.number      = number;
         this.description = description;
         this.price       = price;
         this.pricep      = price * TAXRATE;
    public int compareTo(Object o1)
         String o = ((Item)o1).number;
         return(number.compareTo(o));
    public String toString()
         DecimalFormat df = new DecimalFormat("#.00");     
         String        p1 = df.format(TAXRATE*price);
         String        p2 = df.format(TAXRATE*price+price);
         String s = number+"\t "+description+"\t"+price+"\t"+p1+"\t"+p2+"\t" ;
         return(s);
    public static void main (String[] args)
         Cat catalog = new Cat();
         catalog.read("C31.dat");
         String reply = "";
         BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
         while (!reply.equals("e"))
              System.out.println("");
            System.out.println("CATALOGUE MANAGER: MAIN MENU");
            System.out.println("============================");
            System.out.println("a) display all goods        b) display cheapest/dearest goods");
            System.out.println("c) sort the goods list      d) search the good list");
            System.out.println("e) quit");
            System.out.print("Option:");
              try
                   reply = stdin.readLine();
              catch (IOException e)
                System.out.println("ERROR:" + e.getMessage());
                System.out.println("Application exits now");
                System.exit(0);
              if (reply.equals("a")) catalog.displayAll();
              if (reply.equals("c")) catalog.sort();
    Noah

  • How could I fix this code

    Hii 2 all
    How could I change this statement for parameters list,, so the client_name can contain spaces ??
    add_parameter(p_id,'p_client_name',TEXT_PARAMETER, '''' || :cntrl.client_name || '''');
    cause it couldn't print and give syntax error when the :cntrl.client_name contains any spaces !!!!
    please help
    thanks:)

    First I must apologize, I asked you to test something that was not needed... for a moment I thought we were talking about web.show_document, that's why I asked you to test with double-quotes..
    Regarding your problem, Manu is right, there is not need to wrap around the parameter in quotes..
    add_parameter(p_id,'p_client_name',TEXT_PARAMETER, :cntrl.client_name);I have to ask you the same question that Manu asked you before, where are you using this parameter?
    In your Report you must be using in a piece of PL/SQL code, we need you to post that code...
    Edited by: Rodolfo Ferrari on Sep 10, 2009 4:44 PM

  • Error compiling this code

    Could you tell me what i'm doing wrong with this code? I posted earlier for inputting char into a variable, but the post just got too long.
    I've tried below with code, but I can't get it right. Can you help me..?
    import java.io.*;
    public class Goals {
    public static void main (String args[]) {
    System.out.println("Enter time and tide:");
    InputStreamReader reader = new InputStreamReader (System.in);
    char ch = reader.read(char); // trying to read character from keyboard
    System.out.println("the character" +ch);
    This is my error here:
    Goals.java:13: '.class' expec
    char ch = reader.read(char);
    ^
    Goals.java:13: ')' expected
    char ch = reader.read(char);
    ^
    thank you...
    yash

    The read method that you want to use does not accept any argument, so the syntax you want is char ch = reader.read();
    The first error is caused because the compiler is not expecting to see the reserved word "char" at that point. It knows that the only way the code would be valid is that char was followed by .class, so it suggests it. The second error seems to be a ripple effect of the first one and gets fixed when you fix the first one.
    Once you fix that error you get another, warning you about loss of precision. This is because the read() method returns an int and you are trying to assign an int in a char, while it's well known that there are plenty of integer values that don't fit in a char. Why does Reader.read() return an int instead of char? Because it needs a way to signal the end of the stream. In a normal case the read method returns the character that was read, but -1 if the end of the stream has been reached.
    One way to fix this would be casting the int value to char, which erroneously interpretes the end of the stream as a char too:
    char ch = (char) reader.read();

  • Error in this code - javafx

    Sorry for the question but I'm a newbie
    I have this code:
    http://weblogs.java.net/blog/brunogh/archive/2007/09/my_first_fx_blu_1.html
    Button {
                                 text: "Inquiry"
                                 enabled : bind model.inquiryBtnEnabled
                                 action: operation() {
                                    DeviceDiscoverer.getInstance().startInquiry(DiscoveryAgent.GIAC, model.inquiryListener);
                                    model.foundDevices = null;
                                    model.inquiryBtnEnabled = false;
                                    model.cancelBtnEnabled = true;
                                 }what is the error?
    Thanks.
    And sorry for my english, too.

    Hi Gigi_One,
    this code was posted in 2007.. If you're using the Preview version, you must switch "operation" to "function"...
    Are there an error message?
    Bruno Grossi

  • Error in this code?

    hi friends,
    when I run this code it is giving error as
    Cause: FDPSTP failed due to ORA-01427: single-row subquery returns more than one row
    ORA-06512: at "APPS.UPD_VAC", line 18
    ORA-06512: at line 1
    can some one suggest a solution pls
    the table vac_table has a single column... and it has only 1 record right now
    CREATE OR REPLACE package body APPS.upd_vac is
    procedure upd_prc(p_err_buf out VARCHAR2
    ,p_ret_code out NUMBER)
    is
    l_attr varchar2(100);
    l_attr1 varchar2(100);
    l_attr2 varchar2(100);
    l_attr3 varchar2(100);
    l_attr4 varchar2(100);
    begin
    SELECT MAX(ATTRIBUTE18) INTO L_ATTR FROM PER_VACANCIES;
    select (regexp_substr (l_attr, '.*C')) into l_attr1 from dual;
    select regexp_replace(l_attr,'^.*C(.+)$','\1') into l_attr2 from dual;
    select to_number(l_attr2)+1 into l_attr3 from dual;
    select l_attr1||l_attr3 into l_attr4 from dual;
    insert into vac_table
    (select l_attr4 from dual);
    UPDATE PER_VACANCIES SET ATTRIBUTE18 =(select attribute from kdd_vacancy)
    where vacancy_id =(select max(vacancy_id) from per_vacancies);
    commit;
    end;
    end;

    CREATE OR replace PACKAGE BODY apps.upd_vac
    IS
      PROCEDURE Upd_prc(p_err_buf  OUT VARCHAR2,
                        p_ret_code OUT NUMBER)
      IS
        l_attr  VARCHAR2(100);
        l_attr1 VARCHAR2(100);
        l_attr2 VARCHAR2(100);
        l_attr3 VARCHAR2(100);
        l_attr4 VARCHAR2(100);
      BEGIN
        SELECT MAX(attribute18)
        INTO   l_attr
        FROM   per_vacancies;
        SELECT ( Regexp_substr (l_attr, '.*C') )
        INTO   l_attr1
        FROM   dual;
        SELECT Regexp_replace(l_attr, '^.*C(.+)$', '\1')
        INTO   l_attr2
        FROM   dual;
        SELECT To_number(l_attr2) + 1
        INTO   l_attr3
        FROM   dual;
        SELECT l_attr1
               ||l_attr3
        INTO   l_attr4
        FROM   dual;
        INSERT INTO vac_table
        (SELECT l_attr4
         FROM   dual);
        UPDATE per_vacancies
        SET    attribute18 = (SELECT attribute FROM   kdd_vacancy)
        WHERE  vacancy_id = (SELECT MAX(vacancy_id)
                             FROM   per_vacancies);
        COMMIT;
      END;
    END; 
    (SELECT attribute FROM kdd_vacancy)must return only a single row
    ATTRIBUTE18 is a scalar & can only accept one value; which is correct value FROM KDD_VACANCY?

  • See my error against this code jasperPrint = JasperFillManager.fillReport(s

    sir i use this code for without database report
    jasperPrint = JasperFillManager.fillReport(stream, new HashMap(), new JREmptyDataSource());
    and comple then output window give me this error
    C:Documents and SettingsAdministratorMy DocumentsCreatorProjectswithoutdatasourceireportsrcwithoutdatasourceireportPage1.java:390: unreported exception net.sf.jasperreports.engine.JRException; must be caught or declared to be thrown
    jasperPrint = JasperFillManager.fillReport(stream, new HashMap(), new JREmptyDataSource());
    1 error
    C:Documents and SettingsAdministratorMy DocumentsCreatorProjectswithoutdatasourceireportnbprojectbuild-impl.xml:233: The following error occurred while executing this line:
    C:Documents and SettingsAdministratorMy DocumentsCreatorProjectswithoutdatasourceireportnbprojectbuild-impl.xml:122: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 13 seconds)
    see all error and
    plese give me idea
    thank's
    aamir

    See your other thread on the same topic
    Re: jsp give me this error javax.servlet.ServletException: oracle.jdbc.driv

  • What is the error in this code

    hi everone
    I write this code in push button
         declare
              x varchar2(222);
         begin
              x:=get_application_property(:system.mode);
              message(x);
              end;
    to know the system mode
    but the resullt was exeception ora-06502

    simple write
    x := :system.mode;
    or
    message(:system.mode);
    message(:system.mode);Best way to resolve the issue is always check Forms online help first

  • Can someone check this code?

    What I am trying to achieve is an "active" button state. I
    have six buttons. When one is clicked, i need it to change to a
    color which denotes that it is the active button.
    someone provided me with this code, but I can't seem to get
    it to work. I followed the directions precisely.
    The directions were as follows:
    One thing I think you could do is create another invisible
    layer of buttons above all your other buttons. You could make them
    all invisible, unless a button is clicked.
    Let's say your original layer of buttons is called a_but,
    b_but, and c_but.
    Then you could have another invisible layer of buttons called
    invA_but, invB_but, and invC_but. This layer of buttons would each
    be the color you want displayed while the button is selected. The
    code would look something like-
    invA_but._visible=false;
    invB_but._visible=false;
    invC_but._visible=false;
    a_but.onRelease=function(){
    invA_but._visible=true;
    invB_but._visible=false;
    invB_but._visible=false;
    b_but.onRelease=function(){
    invA_but._visible=false;
    invB_but._visible=true;
    invC_but._visible=false;
    c_but.onRelease=function(){
    invA_but._visible=false;
    invB_but._visible=false;
    invC_but._visible=true

    invA_but, invB_but, and invC_but refer to instance names for
    your buttons, not layer names as suggested in the description. It
    should work if you have the instance names for the buttons right. I
    would probably add code to make the nomal state invisible instead
    of just having the active button covering the inactive one. EX:
    a_but.onRelease=function(){
    invA_but._visible=true; //show the buttons active state
    a_but._visible = false; //hide the off state of the button
    invB_but._visible=false; //hides the active state of button b
    invC_but._visible=false; //hides the active state of button c

Maybe you are looking for

  • Report on slow-moving items

    Hello gurus, I would like to creat a report on slow-moving items in LIS, similar to report RMCBLH30 (TAC MC46). But in 'my' report I would like to see only those slow-moving items in stock. RMCBLH30 unfortunatelly gives my all slow-moving items, even

  • Slideshow export plugin with HTML5?

    Hello, is there available any plugin that would create simple HTML5 based slideshows? I guess while the appearance is a slideshow it would work as web gallery plugin. Fade effect would be nice as transition, it should autoplay (with manual override),

  • IPhone alarm clock fails when volume off

    I set my alarm to wake me up this morning. It went off, but made no sound. I'd turned my iTunes volume low. Surely it makes sense for the alarm clock to, by default, make a sound?

  • Granting priviledge to objects in different databases

    hey all, I wanted to know if there is a way to grant an insert priviledge to a user in a different database. I have one user in environment A(so his connection information is johndoe@A). In A, there is a table that I need to give insert priviledge to

  • Repair of Equipment through External Vendor

    Hi, I have a proble. When we want to repair some Equipment throug External Vendor then that Equipment should go outside the plant and again retuns back to plant. Please suggest what is the standard SAP process for that, how can I track the movements