What is wrong in this program?

public class TestDog{
public static void main(String[] args){
Dog d = new Dog();
System.out.println("Dog d's weight is "+d.getWeight());
d.setWeight(42);
System.out.println("Dog d's weight is "+d.getWeight());
d.setWeight(-42);
System.out.println("Dog d's weight is "+d.getWeight());
}

public class TestDog {
public static void main(String[] args){
Dog d = new Dog();
System.out.println("Dog d's weight is " + d.getWeight());
d.setWeight(42);
System.out.println("Dog d's weight is " + d.getWeight());
d.setWeight(-42);
System.out.println("Dog d's weight is " + d.getWeight());
}I am getting following error messages
TestDog.java:4: cannot find symbol
Symbol : class Dog
Location : class TestDog
Dog d =new Dog();
^
TestDog.java:4: cannot find symbol
Symbol : class Dog
Location : class TestDog
Dog d =new Dog();
^
Message was edited by:
Reddy_Prasad
Message was edited by:
Reddy_Prasad

Similar Messages

  • What's wrong with this program?

    /* Daphne invests $100 at 10% simple interest. Deirdre invests $100 at 5% interest compounded annually. Write a program that finds how many years it takes for the value of Deirdre's investment to exceed the value of Daphne's investment. Aso show the two values at that time.*/
    #include <stdio.h>
    #define START 100.00
    int main(void)
    int counter = 1;
    float daphne = START;
    float deirdre = START;
    printf("Daphne invests $100 at 10 percent simple interest. Deirdre invests $100 at 5 percent interest compounded annually.
    When will Deirdre's account value exceed Daphne's?
    Let\'s find out.
    while (daphne > deirdre)
    daphne += 10.00;
    deirdre *= 1.05;
    printf("%f %f
    ", daphne, deirdre);
    printf("At year %d, Daphne has %.2f dollars. Deirdre has %.2f dollars.
    ", counter, daphne, deirdre);
    counter++;
    printf("By the end of year %d, Deirdre's account has surpassed Daphne's in value.
    ", counter);
    return 0;
    This is my output:
    *Daphne invests $100 at 10 percent simple interest. Deirdre invests $100 at 5 percent interest compounded annually.*
    *When will Deirdre's account value exceed Daphne's?*
    *Let's find out.*
    *By the end of year 1, Deirdre's account has surpassed Daphne's in value.*
    What's wrong with it?
    Message was edited by: musicwind95
    Message was edited by: musicwind95

    John hadn't responded at the time I started typing this, but I'll keep it posted anyways in order to expand on John's answer a little bit. The answer to your last question is that the loop's condition has to return true for it to run the first time around. To examine this further, let's take a look at the way you had the while loop before:
    while (daphne > deirdre)
    Now, a while loop will run the code between its braces as long as the condition inside the parenthesis (daphne > deirdre, in this case) is true. So, if the condition is false the first time the code reaches the while statement, then the loop will never run at all (it won't even run through it once -- it will skip over it). And since, before the while loop, both variables (daphne and dierdre) are set equal to the same value (START (100.00), in this case), both variables are equal at the point when the code first reaches the while statement. Since they are equal, daphne is NOT greater than dierdre, and therefore the condition returns false. Since the condition is false the first time the code reaches it, the code inside the loop's braces is skipped over and never run. As John recommended in the previous post, changing it to this:
    while (daphne >= deirdre)
    fixes the problem because now the condition is true. The use of the "greater than or equal to" operator (>=) instead of the "great than" operator (>) means that the condition can now be returned true even if daphne is equal to deirdre, not just if it's greater than deirdre. And since daphne and deirdre are equal (they are both 100.00) when the code first reaches the while loop, the condition is now returned true and the code inside the loop's braces will be run. Once the program reaches the end of the code inside the loop's braces, it will check to see if the condition is still true and, if it is, it will run the loop's code again (and again and again and again, checking to see if the condition is still true each time), and if it's not true, it will skip over the loop's bottom brace and continue on with the rest of the program.
    Hope this helped clear this up for you. Please ask if you have any more questions.

  • What is wrong with this program segment? I could not understand the error..

    public class Hmw3
         public static char[] myMethod(char[]p1,int p2, char p3)
         {                             //13 th row
              if(p2<p1.length)
                   p1[p2]=p3;
                   System.out.println(p1);
         public static void main(String[] args)
              String sentence="It snows";
              char[] tmp=sentence.toCharArray();
              System.out.println(tmp);
              myMethod(tmp,3,'k');
              sentence=String.copyValueOf(tmp);
              System.out.println(sentence);     
    i wrote this program segment and compiler gave this error:
    C:\Program Files\Xinox Software\JCreator LE\MyProjects\hmw3\Hmw3.java:13: missing return statement
    What is wrong???

    Your method signature states that myMethod should return an array for chars.
    But in ur implementation of myMethod, there is nothing returned.
    Just add a return statement like "return p1"

  • What is wrong with this program it keeps telling me the file doesn't exist?

    this program is supposed to write the file so why does it need the file to already exist?
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.ArrayList;
    import java.util.Scanner;
    public class NewClass implements ActionListener{
        static List list = new List();
        static TextField input = new TextField(20);
        static Button submit = new Button("Submit");
        static Frame f = new Frame("RealmList editor");
        static File file = new File("/Applications/World of Warcraft/realmlist.wtf");
        static Label status = new Label("");
        static Button selected = new Button("Change to Selected");
        static File config = new File("/Applications/RealmLister/config.txt");
        static File dir = new File("/Applications/RealmLister/");
        public static void main(String[] args) {
            f.setLayout(new BorderLayout());
            f.add(list, BorderLayout.CENTER);
            Panel p = new Panel();
            p.add(input);
            p.add(submit);
            p.add(selected);
            f.add(p, BorderLayout.NORTH);
            f.add(status, BorderLayout.SOUTH);
            new NewClass();
            f.setSize(500,500);
            f.setVisible(true);
            try {
                loadConfig();
            } catch(Exception e) {}
            f.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent we) {
                    try {
                      writeConfig();
                      System.exit(0);
                    } catch(Exception e) {
                       status.setText("Error: config couldn't be written!("+e+")");
        public NewClass() {
            submit.addActionListener(this);
            input.addKeyListener(new KeyAdapter() {
                public void keyPressed(KeyEvent e) {
                    if(e.getKeyCode() == KeyEvent.VK_ENTER) {
                    try {
                    editRealmlist(input.getText(), true);
                    input.setText("");
                 catch(Exception ex) {
                   status.setText("Error: "+e);
            selected.addActionListener(this);
        public void actionPerformed(ActionEvent e) {
            if(e.getSource() == submit) {
                try {
                    editRealmlist(input.getText(), true);
                    input.setText("");
                } catch(Exception ex) {
                   status.setText("Error: "+e);
                   wait(3000);
                   status.setText("");
            if(e.getSource() == selected) {
                try {
                    editRealmlist(list.getSelectedItem(),false);
                } catch(Exception ex) {
                    status.setText("Error: "+e);
                    wait(3000);
                    status.setText("");
        public static void loadConfig() throws Exception{
            if(config.exists()) {
                Scanner scan = new Scanner(config);
                ArrayList<String> al = new ArrayList<String>();
                while(scan.hasNext()) {
                    al.add(scan.nextLine());
                for(int i = 0; i < al.size(); i++) {
                    list.add(al.get(i));
        public static void writeConfig() throws Exception{
            FileWriter fw = new FileWriter(config);
            dir.mkdir();
            config.mkdirs();
            String temp = "";
            for(int i = 0; i < list.getItemCount(); i++) {
                temp += list.getItem(i)+"\n";
            fw.write(temp);
            fw.flush();
            System.gc();
        public static void editRealmlist(String realm, boolean addtoList) throws Exception{
            FileWriter fw = new FileWriter(file);
            fw.write("set realmlist "+realm+"\nset patchlist us.version.worldofwarcraft.com");
            fw.flush();
            status.setText("Editing RealmList.wtf Please Wait...");
            Thread.sleep(3000);
            status.setText("");
            System.gc();
            if(addtoList)
                list.add(realm);
        public void wait(int time) {
            try {
                Thread.sleep(time);
            catch(Exception e) {}
    }

    Erm, you should call mkdirs() on a File object that represents a directory.

  • What's wrong with this program that about socket

    package example;
    import java.net.*;
    import java.io.*;
    public class Server implements Runnable{
        Thread t;
        ServerSocket sSocket;
        int sPort=6633;
        public Server(){
            try{
                sSocket=new ServerSocket(sPort);
                System.out.println("server start....");
            }catch(IOException e){
                e.printStackTrace();
            t=new Thread(this);
            t.start();
        public void run(){
            try{
                while(true){
                    Socket cSocket=sSocket.accept();
                    ClientThread cThread=new ClientThread(cSocket);
                    cThread.start();
            }catch(IOException e){
                e.printStackTrace();
       public static void main(String[] args){
            new Server();
    package example;
    import java.net.*;
    import java.io.*;
    public class ClientThread extends Thread{
        Socket cSocket;
        PrintStream writer;
        BufferedReader reader;
        public ClientThread(Socket s){
            cSocket=s;
            try{
                writer=new PrintStream(cSocket.getOutputStream());
                reader=new BufferedReader(new InputStreamReader(cSocket.getInputStream()));
            }catch(IOException e){
                e.printStackTrace();
        public void run(){
            try{
                while(true){
                    String message=reader.readLine();
                    System.out.println("Server get:"+message);
            }catch(IOException e){
                e.printStackTrace();
    package example;
    import java.net.*;
    import java.io.*;
    public class Client{
        public static void main(String[] args){
            String ipaddr="localhost";
            PrintStream writer;
            try{
                Socket  cSocket=new Socket(ipaddr,6633);
                System.out.println(cSocket);
                writer=new PrintStream(cSocket.getOutputStream());
                System.out.println("client send:hello");
                writer.print("hello");
            catch(Exception e){
                e.printStackTrace();
    }first,I run Server,and then I run Client,
    output at Server:
    server start....
    java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:168)
    at java.net.SocketInputStream.read(SocketInputStream.java:90)
    at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java:285)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:182)
    at java.io.InputStreamReader.read(InputStreamReader.java:167)
    at java.io.BufferedReader.fill(BufferedReader.java:136)
    at java.io.BufferedReader.readLine(BufferedReader.java:299)
    at java.io.BufferedReader.readLine(BufferedReader.java:362)
    at example.ClientThread.run(ClientThread.java:20)
    what' wrong??????

    In your Client class, after doing writer.print("hello"); you should flush
    the output stream. As it is now, you attempt to write something (without actually
    sending something to your server) and main simply terminates. The server,
    still waiting for some input (you didn't flush on the client side), is confronted with
    a closed client socket (main on the client side terminated and implicitly closed
    the client socket), hence the 'connection reset' exception on the server side.
    kind regards,
    Jos

  • What is wrong with this program?

    When I run a get these messages:
    ^
    MULTIPLYIMP.java:25: 'class' or 'interface' expected
    ^
    MULTIPLYIMP.java:7: cannot resolve symbol
    symbol : class UnicastRemoteObject
    location: class MULTIPLYIMP
    UnicastRemoteObject implements multiply {
    ^
    MULTIPLYIMP.java:6: MULTIPLYIMP should be declared abstract; it does not define
    greet() in MULTIPLYIMP
    public class MULTIPLYIMP extends
    ^
    MULTIPLYIMP.java:11: cannot resolve symbol
    symbol : method supa ()
    location: class MULTIPLYIMP
    supa (); //Export
    ^
    MULTIPLYIMP.java:15: missing method body, or declare abstract
    public int mult (int a,int b) throws RemoteException
    ^
    9 errors
    //MULTIPLYIMPL.JAVA
    import java.rmi.*;
    import .rmi.server.*;
    public class MULTIPLYIMP extends
    unicastRemoteObject implements multiply {
    public MULTIPLYIMPL () throwsRemoteException {
    supa (); //Export
    public int mult (int a,int b) throws RemoteException
    return (a * b)
    public String greet () throws RemoteException
    return("CCM 3061");

    When I run a get these messages:
    ^
    MULTIPLYIMP.java:25: 'class' or 'interface' expected
    ^
    MULTIPLYIMP.java:7: cannot resolve symbol
    symbol : class UnicastRemoteObject
    location: class MULTIPLYIMP
    UnicastRemoteObject implements multiply {
    ^
    You haven't imported the right package.
    You need to import
    java.rmi.server.UnicastRemoteObject
    or
    java.rmi.server.*
    MULTIPLYIMP.java:6: MULTIPLYIMP should be declared
    abstract; it does not define
    greet() in MULTIPLYIMP
    public class MULTIPLYIMP extends
    ^
    It says that you don't define greet() because it doesn't have curly braces after the method name.
    I'm reasonably sure
    public String greet () throws RemoteException
    return("CCM 3061");is not acceptable, usepublic String greet () throws RemoteException
    return("CCM 3061");
    MULTIPLYIMP.java:11: cannot resolve symbol
    symbol : method supa ()
    location: class MULTIPLYIMP
    supa (); //Export
    ^
    MY GOD MAN, SUPER(), SUPER!!!!!!
    MULTIPLYIMP.java:15: missing method body, or declare
    abstract
    public int mult (int a,int b) throws RemoteException
    ^
    9 errors
    Same with mult(), need to have curly braces around the method body
    //MULTIPLYIMPL.JAVA
    import java.rmi.*;
    WHAT IS THIS LINE?
    import java.rmi.server.*
    import .rmi.server.*;
    public class MULTIPLYIMP extends
    unicastRemoteObject implements multiply {
    public MULTIPLYIMPL () throwsRemoteException {
    supa (); //Export
    public int mult (int a,int b) throws RemoteException
    return (a * b)
    public String greet () throws RemoteException
    return("CCM 3061");
    }Messy messy code mate,
    Good luck,
    Radish21

  • What's wrong in this program, I want to insert a row using this program

    TABLES: zemployee, sscrfields.
    TYPES: BEGIN OF t_zemployee,
            empid TYPE zemployee-empid,
            empname TYPE zemployee-empname,
            dob TYPE zemployee-dob,
            dept TYPE zemployee-dept,
            END OF t_zemployee.
    DATA: it_zemployee TYPE STANDARD TABLE OF t_zemployee WITH HEADER LINE,
           wa_zemployee TYPE t_zemployee .                       " OCCURS 0.
    *DATA: gd_ucomm TYPE sy-ucomm.
    LOAD-OF-PROGRAM.
       SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE t1.
       SELECTION-SCREEN SKIP.
       PARAMETERS: empid1 TYPE zemployee-empid,
                   empname1 TYPE zemployee-empname,
                   dob1 TYPE zemployee-dob,
                   dept1 TYPE zemployee-dept.
       SELECTION-SCREEN BEGIN OF LINE.
       SELECTION-SCREEN PUSHBUTTON (10) w_button USER-COMMAND but1.
       SELECTION-SCREEN END OF LINE.
       SELECTION-SCREEN END OF BLOCK block1.
    INITIALIZATION.
       t1 = 'ENTER THE VALID DATA'.
    *  w_button = 'SAVE'.
       MOVE 'SAVE' TO W_BUTTON.
    AT SELECTION-SCREEN.
    *  AT SELECTION-SCREEN OUTPUT.
       IF empid1 IS INITIAL OR empname1 IS INITIAL OR dob1 IS INITIAL OR dept1 IS INITIAL.
         MESSAGE: 'PLEASE FILL ALL THE DATA PROPERLY' TYPE 'I'.
       ELSE.
         wa_zemployee-empid = empid1.
         wa_zemployee-empname = empname1.
         wa_zemployee-dob = dob1.
         wa_zemployee-dept = dept1.
         APPEND wa_zemployee TO it_zemployee.
       ENDIF.
      IF sscrfields-ucomm = 'BUT1'.
         sy-ucomm = 'BUT1'.
      ENDIF.
       IF sy-ucomm = 'BUT1'.
         LOOP AT it_zemployee INTO wa_zemployee.
           INSERT zemployee FROM wa_zemployee.
           IF sy-subrc = 0.
             MESSAGE 'DATABASE SUCCESSFULLY RECORDED' TYPE 'S'.
           ELSEIF sy-subrc = 4.
             MESSAGE 'EMPLOYEE ID ALREADY EXISTS' TYPE 'E'.
             CLEAR: empid1, empname1, dob1, dept1.
           ENDIF.
    *CLEAR: WA_ZEMPLOYEE, IT_ZEMPLOYEE.
         ENDLOOP.
       ENDIF.

    Hi
    You have written this definition;
    wa_zemployee TYPE t_zemployee
    but the type T_ZEMPLOYEE is not like the table ZEMPLOYEE:
    TYPES: BEGIN OF t_zemployee,
            empid TYPE zemployee-empid,
            empname TYPE zemployee-empname,
            dob TYPE zemployee-dob,
            dept TYPE zemployee-dept,
            END OF t_zemployee.
    so probably some fields of ZEMPLOYEE are missing, you should use this declaration:
    DATA WA_ZEMPLOYEE TYPE ZEMPLOYEE
    Max

  • What's wrong with this program, nothing displays.

    Compile ok, but nothing displays.
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    public class Card{
    JFrame f;
    JLabel nameTF;
    JComboBox jobChoice;
    JButton B1, B2, B3, B4;
    public static void main(String[] av) {
    new Card( );
    public Card( ) {
    f=new JFrame();
    f.setSize(500,500);
    Container cp = f.getContentPane( );
    cp.setLayout(new GridLayout(0, 1));
    f.addWindowListener(new WindowAdapter( ) {
    public void windowClosing(WindowEvent e) {
    f.setVisible(false);
    f.dispose( );
    System.exit(0);
    JMenuBar mb = new JMenuBar( );
    f.setJMenuBar(mb);
    JMenu aMenu;
    aMenu = new JMenu("filemenu");
    mb.add(aMenu);
    JMenuItem mi = new JMenuItem("exit");
    aMenu.add(mi);
    mi.addActionListener(new ActionListener( ) {
    public void actionPerformed(ActionEvent e) {
    System.exit(0);
    aMenu = new JMenu("editmenu");
    mb.add(aMenu);
    aMenu = new JMenu("viewmenu");
    mb.add(aMenu);
    aMenu = new JMenu("optionsmenu");
    mb.add(aMenu);
    aMenu =new JMenu("helpmenu");
    mb.add(aMenu);
    JPanel p1 = new JPanel( );
    p1.setLayout(new GridLayout(0, 1, 50, 10));
    nameTF = new JLabel("My Name", JLabel.CENTER);
    nameTF.setFont(new Font("helvetica", Font.BOLD, 18));
    nameTF.setText("MYNAME");
    p1.add(nameTF);
    jobChoice = new JComboBox( );
    jobChoice.setFont(new Font("helvetica", Font.BOLD, 14));
    String next;
    int i=1;
    do {
    next = "job_title" + i;
    if (next != null)
    jobChoice.addItem(next);
    } while (next != null);
    p1.add(jobChoice);
    cp.add(p1);
    JPanel p2 = new JPanel( );
    p2.setLayout(new GridLayout(2, 2, 10, 10));
    B1 = new JButton( );
    B1.setText("button1.label");
    p2.add(B1);
    B2 = new JButton( );
    B2.setText("button2.label");
    p2.add(B2);
    B3 = new JButton( );
    B3.setText("button3.label");
    p2.add(B3);
    B4 = new JButton( );
    B4.setText("button4.label");
    p2.add(B4);
    cp.add(p2);
    f.pack( );
    f.show();
    }

    hi there
    try this code i changed a little bil and one more thing yr LOOP is not working Properly check that out
    rest is fine
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    public class Card extends JFrame
        JLabel nameTF;
        JComboBox jobChoice;
        JButton B1, B2, B3, B4;
        public static void main(String[] av)
            Card C = new Card( );
            C.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        public Card( )
            setSize(500,500);
            Container cp = getContentPane( );
            cp.setLayout(new GridLayout(0, 1));
            addWindowListener(new WindowAdapter( )
                public void windowClosing(WindowEvent e)
                    dispose( );
                    System.exit(0);
        JMenuBar mb = new JMenuBar( );
        setJMenuBar(mb);
        JMenu aMenu;
        aMenu = new JMenu("filemenu");
        mb.add(aMenu);
        JMenuItem mi = new JMenuItem("exit");
        aMenu.add(mi);
        mi.addActionListener(new ActionListener( )
            public void actionPerformed(ActionEvent e)
                dispose( );
                System.exit(0);
        aMenu = new JMenu("editmenu");
        mb.add(aMenu);
        aMenu = new JMenu("viewmenu");
        mb.add(aMenu);
        aMenu = new JMenu("optionsmenu");
        mb.add(aMenu);
        aMenu =new JMenu("helpmenu");
        mb.add(aMenu);
        JPanel p1 = new JPanel( );
        p1.setLayout(new GridLayout(0, 1, 50, 10));
        nameTF = new JLabel("My Name", JLabel.CENTER);
        nameTF.setFont(new Font("helvetica", Font.BOLD, 18));
        nameTF.setText("MYNAME");
        p1.add(nameTF);
        jobChoice = new JComboBox( );
        jobChoice.setFont(new Font("helvetica", Font.BOLD, 14));
        String next;
    //    int i=1;
    //    do
    //        next = "job_title" + i;
    //        if (next != null)
    //           jobChoice.addItem(next);
    //    } while (next != null);
        p1.add(jobChoice);
        cp.add(p1);
        JPanel p2 = new JPanel( );
        p2.setLayout(new GridLayout(2, 2, 10, 10));
        B1 = new JButton( );
        B1.setText("button1.label");
        p2.add(B1);
        B2 = new JButton( );
        B2.setText("button2.label");
        p2.add(B2);
        B3 = new JButton( );
        B3.setText("button3.label");
        p2.add(B3);
        B4 = new JButton( );
        B4.setText("button4.label");
        p2.add(B4);
        cp.add(p2);
        pack( );
        setVisible(true);
    }Regards
    Satinderjit

  • What is wrong in this program?? I keep getting a mismatch error.

    import java.util.Scanner;
    public class Exercise2_11 {
    public static void main(String []args){
    Scanner input = new Scanner(System.in);
    System.out.println("Enter employee's name:");
    int employee = input.nextInt();
    System.out.println("Enter number of hours worked: ");
    int hours = input.nextInt();
    System.out.println("Enter hourly pay rate: ");
    int pay = input.nextInt();
    int gross_pay = pay * hours;
    System.out.println("Enter federal tax withholding rate: ");
    int fedtax = input.nextInt();
    int fedtaxr = fedtax * (20/100);
    System.out.println("Enter state tax withholding rate: ");
    int statetax = input.nextInt();
    int statetaxr = statetax * (20/100);
    int deductions = fedtaxr + statetaxr;
    int total_pay = gross_pay - deductions;
    System.out.println("Employee name: " + employee);
    System.out.println("Hours worked: " + hours);
    System.out.println(" Enter payrate: " + pay);
    System.out.println(" Enter gross pay: " + gross_pay);
    System.out.println(" Deductions: ");
    System.out.println("\t Federdal Withholding (20.0%): " + fedtaxr);
    System.out.println("\t State Withholding (9.0%)" + statetaxr);
    System.out.println("\t Total deductions:" +deductions);
    System.out.println("Total pay: "+total_pay);
    }

    Ok here is the working code, with doubles instead of ints so you can enter say 6.5 or 0.002 for pay and tax.
    Toodles!
    import java.util.Scanner;
    public class Exercise2_11
       public static void main(String[] args)
          Scanner input = new Scanner(System.in);
          System.out.println("Enter employee's name:");
          String employee = input.next();
          System.out.println("Enter number of hours worked: ");
          double  hours = input.nextDouble();
          System.out.println("Enter hourly pay rate: ");
          double  pay = input.nextDouble();
          double  gross_pay = pay * hours;
          System.out.println("Enter federal tax withholding rate: ");
          double  fedtax = input.nextDouble();
          double fedtaxr = fedtax * 0.20;
          System.out.println("Enter state tax withholding rate: ");
          double  statetax = input.nextDouble();
          double statetaxr = statetax * 0.20;
          double deductions = fedtaxr + statetaxr;
          double total_pay = gross_pay - deductions;
          System.out.println("Employee name: " + employee);
          System.out.println("Hours worked: " + hours);
          System.out.println(" Enter payrate: " + pay);
          System.out.println(" Enter gross pay: " + gross_pay);
          System.out.println(" Deductions: ");
          System.out.println("\t Federdal Withholding (20.0%): " + fedtaxr);
          System.out.println("\t State Withholding (9.0%)" + statetaxr);
          System.out.println("\t Total deductions:" + deductions);
          System.out.println("Total pay: " + total_pay);
    }

  • Does ANYONE know whats wrong with this program?!?!

    Hey(again),
    Does anyone know whats wrong with this program?:
    public class FloatingNumbersTest
    public static void main(String args[])
    float float1 =50.0f;
    float closeFloat=0.001f
    float farfloat=100.0f
    if (float1<=closeFloat)
    System.out.print("Float1 pretty close to zero");
    if (float1>=closeFloat)
    System.out.print("Float1 is near 0");
    if (float1>=farfloat)
    System.out.print("Float1 is not even close to zero!"0
    }There has seemed to be 5 errors!

    public class FloatingNumbersTest
    public static void main(String args[])
    float float1 =50.0f;
    float closeFloat=0.001f
    float farfloat=100.0f
    if (float1<=closeFloat)
    HERE        System.out.print("Float1 pretty close to zero");
    if (float1>=closeFloat)
    System.out.print("Float1 is near 0");
    if (float1>=farfloat)
    System.out.print("Float1 is not even close to zero!"0
    }you're missing the opening { for the first if.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • I can't figure out what's wrong with this code

    First i want this program to allow me to enter a number with the EasyReader class and depending on the number entered it will show that specific line of this peom:
    One two buckle your shoe
    Three four shut the door
    Five six pick up sticks
    Seven eight lay them straight
    Nine ten this is the end.
    The error message i got was an illegal start of expression. I can't figure out why it is giving me this error because i have if (n = 1) || (n = 2) statements. My code is:
    public class PoemSeventeen
    public static void main(String[] args)
    EasyReader console = new EasyReader();
    System.out.println("Enter a number for the poem (0 to quit): ");
    int n = console.readInt();
    if (n = 1) || (n = 2)
    System.out.println("One, two, buckle your shoe");
    else if (n = 3) || (n = 4)
    System.out.println("Three, four, shut the door");
    else if (n = 5) || (n = 6)
    System.out.println("Five, six, pick up sticks");
    else if (n = 7) || (n = 8)
    System.out.println("Seven, eight, lay them straight");
    else if (n = 9) || (n = 10)
    System.out.println("Nine, ten, this is the end");
    else if (n = 0)
    System.out.println("You may exit now");
    else
    System.out.println("Put in a number between 0 and 10");
    I messed around with a few other thing because i had some weird errors before but now i have narrowed it down to just this 1 error.
    The EasyReader class code:
    // package com.skylit.io;
    import java.io.*;
    * @author Gary Litvin
    * @version 1.2, 5/30/02
    * Written as part of
    * <i>Java Methods: An Introduction to Object-Oriented Programming</i>
    * (Skylight Publishing 2001, ISBN 0-9654853-7-4)
    * and
    * <i>Java Methods AB: Data Structures</i>
    * (Skylight Publishing 2003, ISBN 0-9654853-1-5)
    * EasyReader provides simple methods for reading the console and
    * for opening and reading text files. All exceptions are handled
    * inside the class and are hidden from the user.
    * <xmp>
    * Example:
    * =======
    * EasyReader console = new EasyReader();
    * System.out.print("Enter input file name: ");
    * String fileName = console.readLine();
    * EasyReader inFile = new EasyReader(fileName);
    * if (inFile.bad())
    * System.err.println("Can't open " + fileName);
    * System.exit(1);
    * String firstLine = inFile.readLine();
    * if (!inFile.eof()) // or: if (firstLine != null)
    * System.out.println("The first line is : " + firstLine);
    * System.out.print("Enter the maximum number of integers to read: ");
    * int maxCount = console.readInt();
    * int k, count = 0;
    * while (count < maxCount && !inFile.eof())
    * k = inFile.readInt();
    * if (!inFile.eof())
    * // process or store this number
    * count++;
    * inFile.close(); // optional
    * System.out.println(count + " numbers read");
    * </xmp>
    public class EasyReader
    protected String myFileName;
    protected BufferedReader myInFile;
    protected int myErrorFlags = 0;
    protected static final int OPENERROR = 0x0001;
    protected static final int CLOSEERROR = 0x0002;
    protected static final int READERROR = 0x0004;
    protected static final int EOF = 0x0100;
    * Constructor. Prepares console (System.in) for reading
    public EasyReader()
    myFileName = null;
    myErrorFlags = 0;
    myInFile = new BufferedReader(
    new InputStreamReader(System.in), 128);
    * Constructor. opens a file for reading
    * @param fileName the name or pathname of the file
    public EasyReader(String fileName)
    myFileName = fileName;
    myErrorFlags = 0;
    try
    myInFile = new BufferedReader(new FileReader(fileName), 1024);
    catch (FileNotFoundException e)
    myErrorFlags |= OPENERROR;
    myFileName = null;
    * Closes the file
    public void close()
    if (myFileName == null)
    return;
    try
    myInFile.close();
    catch (IOException e)
    System.err.println("Error closing " + myFileName + "\n");
    myErrorFlags |= CLOSEERROR;
    * Checks the status of the file
    * @return true if en error occurred opening or reading the file,
    * false otherwise
    public boolean bad()
    return myErrorFlags != 0;
    * Checks the EOF status of the file
    * @return true if EOF was encountered in the previous read
    * operation, false otherwise
    public boolean eof()
    return (myErrorFlags & EOF) != 0;
    private boolean ready() throws IOException
    return myFileName == null || myInFile.ready();
    * Reads the next character from a file (any character including
    * a space or a newline character).
    * @return character read or <code>null</code> character
    * (Unicode 0) if trying to read beyond the EOF
    public char readChar()
    char ch = '\u0000';
    try
    if (ready())
    ch = (char)myInFile.read();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (ch == '\u0000')
    myErrorFlags |= EOF;
    return ch;
    * Reads from the current position in the file up to and including
    * the next newline character. The newline character is thrown away
    * @return the read string (excluding the newline character) or
    * null if trying to read beyond the EOF
    public String readLine()
    String s = null;
    try
    s = myInFile.readLine();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (s == null)
    myErrorFlags |= EOF;
    return s;
    * Skips whitespace and reads the next word (a string of consecutive
    * non-whitespace characters (up to but excluding the next space,
    * newline, etc.)
    * @return the read string or null if trying to read beyond the EOF
    public String readWord()
    StringBuffer buffer = new StringBuffer(128);
    char ch = ' ';
    int count = 0;
    String s = null;
    try
    while (ready() && Character.isWhitespace(ch))
    ch = (char)myInFile.read();
    while (ready() && !Character.isWhitespace(ch))
    count++;
    buffer.append(ch);
    myInFile.mark(1);
    ch = (char)myInFile.read();
    if (count > 0)
    myInFile.reset();
    s = buffer.toString();
    else
    myErrorFlags |= EOF;
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    return s;
    * Reads the next integer (without validating its format)
    * @return the integer read or 0 if trying to read beyond the EOF
    public int readInt()
    String s = readWord();
    if (s != null)
    return Integer.parseInt(s);
    else
    return 0;
    * Reads the next double (without validating its format)
    * @return the number read or 0 if trying to read beyond the EOF
    public double readDouble()
    String s = readWord();
    if (s != null)
    return Double.parseDouble(s);
    // in Java 1, use: return Double.valueOf(s).doubleValue();
    else
    return 0.0;
    Can anybody please tell me what's wrong with this code? Thanks

    String[] message = {
        "One, two, buckle your shoe",
        "One, two, buckle your shoe",
        "Three, four, shut the door",
        "Three, four, shut the door",
        "Five, six, pick up sticks",
        "Five, six, pick up sticks",
        "Seven, eight, lay them straight",
        "Seven, eight, lay them straight",
        "Nine, ten, this is the end",
        "Nine, ten, this is the end"
    if(n>0)
        System.out.println(message[n]);
    else
        System.exit(0);

  • I HATE my new MACBOOK PRO, it will not let me open any PDF files and I downloaded the ADOBE READER three freaking times and it keeps saying that all the files are corrupt. I would rather have my 2008 Dell at this point. what is wrong with this thing

    I HATE my new MACBOOK PRO, it will not let me open any PDF files and I downloaded the ADOBE READER three freaking times and it keeps saying that all the files are corrupt or damaged. I would rather have my 2008 Dell at this point. what is wrong with this thing

    Perhaps the PDF files are corrupted.
    Hit the command key and spacebar, a blue Spotlight in the upper right hand corner appears, now type Preview and press return on the Preview program.
    Now you can try opening the PDF's from the file menu and see what's going on.
    If they are corrupted, perhaps they are trojans from your Windows PC or gotten from a bad location online.
    Download the free ClamXav and run a scan on the possibly infected folder.

  • What is wrong in this code..please

    first of all,i kindly request team please not kill me by giving suggestion using xml parser.......can u please tell how this handle in reading follwing lines....
    orderREF="1036578"><edm:OrderItem><edm:Order orderID="1036579"/> ineed to retoeve value 1036578 i use following code
    final String START6_TAG="orderREF=";
    final String END6_TAG=">";
    final String END7_TAG="/>";
    as per my observation,the follwing code need not work
    if(line.indexOf(START6_TAG)> -1 ) {
    //this code handle "orderREF=" in stands for order id
    if(line.indexOf(END7_TAG,line.indexOf(START6_TAG))>-1){ //because if we use line.indexOf(END7_TAG)it take only first indexof that..
    efound9=false;
    asper above line this code cannot excecute.but igo to loop and set flag efound9=false, what is wrong in this code for handling
    orderREF="1036578"/><edm:OrderItem><edm:Order orderID="1036579"/> this type of line that also comes in same program,here also we need output as 1036578.please tell me what i will do to hanndle these

    first of all,i kindly request team please not kill
    me by giving suggestion using xml parser.......can u
    please tell how this handle in reading follwing
    lines.... I don't understand why you are so opposed to an xml parser. You could have spent 3 hours learning how to use it and been done with this problem in the time you've spent trying to hack your way around it.
    jdom tutorials: http://www.jdom.org/downloads/docs.html
    dom4j tutorials: http://www.dom4j.org/cookbook.html

  • What is wrong in this java code?

    Can someone please tell me what is wrong in this java code?
    /* The program is intended to start animating text at the click of a button, pause it at another click and resume at the next click. It should continue like this */
    import javax.swing.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    public class TextAnime implements Runnable
    JFrame frame;
    boolean flag;
    Thread animeThread;
    JLabel label;
    String[] textArray;
    public TextAnime()
    flag = false;
    animeThread = new Thread(this);
    frame = new JFrame("Animate Text");
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    frame.setLayout(gbl);
    JButton button = new JButton("Start");
    label = new JLabel("Stopped");
    textArray = new String[5];
    String textArray1[] = {"Programmer", "SportsMan", "Genius", "Friend", "Knowledgable"};
    for(int ctr = 0; ctr<5 ; ctr++)
    textArray[ctr] = textArray1[ctr];
    gbc.weightx = 1;
    gbc.gridx = 0;
    gbl.setConstraints(button,gbc);
    frame.getContentPane().add(button);
    ButList bl = new ButList();
    button.addActionListener(bl);
    gbc.gridx = 1;
    gbl.setConstraints(label,gbc);
    frame.getContentPane().add(label);
    frame.setSize(200,150);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS E);
    frame.setVisible(true);
    public class ButList implements ActionListener
    public void actionPerformed(ActionEvent evt)
    if(flag == false)
    flag = true;
    animeStart();
    else
    flag = false;
    //animeStop();
    public synchronized void animeStart()
    animeThread.start();
    Thread newThread;
    newThread = Thread.currentThread();
    newThread.notify();
    public void animeStop()
    animeThread.interrupt();
    public void run()
    int i = 0;
    try
    while(i == i)
    if(i==5)
    i=0;
    label.setText(textArray);
    animeThread.sleep(1000);
    i++;
    if (flag == false)
    animeThread.wait();
    catch(InterruptedException ie)
    label.setText("Stopped");
    public static void main(String args[])
    TextAnime ta = new TextAnime();
    Please tell me if this can be written in a more simpler manner. Also please correct this code. I am tired after trying many times.

    When I fix your error, compile and run it, I get this exception:
    Exception in thread "AWT-EventQueue-0" java.lang.IllegalMonitorStateException
         at java.lang.Object.notify(Native Method)
         at cruft.TextAnime.animeStart(TextAnime.java:81)
         at cruft.TextAnime$ButList.actionPerformed(TextAnime.java:63)
         at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
         at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
         at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
         at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
         at java.awt.Component.processMouseEvent(Component.java:6038)
         at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
         at java.awt.Component.processEvent(Component.java:5803)
         at java.awt.Container.processEvent(Container.java:2058)
         at java.awt.Component.dispatchEventImpl(Component.java:4410)
         at java.awt.Container.dispatchEventImpl(Container.java:2116)
         at java.awt.Component.dispatchEvent(Component.java:4240)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
         at java.awt.Container.dispatchEventImpl(Container.java:2102)
         at java.awt.Window.dispatchEventImpl(Window.java:2429)
         at java.awt.Component.dispatchEvent(Component.java:4240)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
    %

  • What is wrong with this code? on(release) gotoAndPlay("2")'{'

    Please could someone tell me what is wrong with this code - on(release)
    gotoAndPlay("2")'{'
    this is the error that comes up and i have tried changing it but it is not working
    **Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 2: '{' expected
         gotoAndPlay("2")'{'
    Total ActionScript Errors: 1 Reported Errors: 1
    Thanks

    If you have a frame labelled "2" then it should be:
    on (release) {
        this._parent.gotoAndPlay("2");
    or other wise just the following to go to frame 2:
    on (release) {
         this._parent.gotoAndPlay(2);
    You just had a missing curly bracket...

Maybe you are looking for

  • Error while converting RTF to PDF

    Hi, I have got a requirement to convert .rtf file to .pdf file while downloading. The .rtf file is in application server. I have used the FM CONVERT_RTF_TO_ITF to convert to ITF format. After this I am using the FM CONVERT_OTF to convert it to pdf fo

  • Insert with Where Clause

    Hi, Can we write Insert with 'Where' clause? I'm looking for something similar to the below one (which is giving me an error) insert into PS_AUDIT_OUT (AUDIT_ID, EMPLID, RECNAME, FIELDNAME, MATCHVAL, ERRORMSG) Values ('1','10000139','NAMES','FIRST_NA

  • Error while using comments

    Hi, When I try to create a comment I get the following error - "The cell cannot be updated. Submission status must be modified to allow changes". On the Input schedule I have data cells where I can enter the data and that gets saved to the Database w

  • Adobe Color Printer Utility and PS CS6

    When attempting to print without Color Management in PS CS6 (in the Color Handling section of the Photoshop CS6 Print dialog box) I get a pop-up error message that says I must use the Adobe Color Printer Utility. It refers me to this page: http://hel

  • Transfer DVD to Ipad

    How to transfer DVD content to Ipad?