Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #2252 > unrolled thread

Wont compile!!!

Started bytyrelmatadin921@gmail.com
First post2012-11-10 16:06 -0800
Last post2012-11-11 01:51 +0100
Articles 6 — 4 participants

Back to article view | Back to comp.lang.java.help


Contents

  Wont compile!!! tyrelmatadin921@gmail.com - 2012-11-10 16:06 -0800
    Re: Wont compile!!! Knute Johnson <nospam@knutejohnson.com> - 2012-11-10 16:16 -0800
      Re: Wont compile!!! tyrelmatadin921@gmail.com - 2012-11-10 16:39 -0800
        Re: Wont compile!!! Knute Johnson <nospam@knutejohnson.com> - 2012-11-10 20:44 -0800
        Re: Wont compile!!! Roedy Green <see_website@mindprod.com.invalid> - 2012-11-11 02:51 -0800
    Re: Wont compile!!! Joerg Meier <joergmmeier@arcor.de> - 2012-11-11 01:51 +0100

#2252 — Wont compile!!!

Fromtyrelmatadin921@gmail.com
Date2012-11-10 16:06 -0800
SubjectWont compile!!!
Message-ID<35e5c178-ae32-4b1b-930e-5ab16276c3dc@googlegroups.com>
This code will not complile and it is really stressing me out.
If someone could help me out i would really apreciate it. thanks in advanced

package sheridan;

import java.util.Scanner;

public class PayrollStatement 
{
    PayrollStatement payState = new PayrollStatment();
    
    payState.printEmployeeName();
        
    public void printEmployeeName()
    {
        System.out.println ("Please enter name");
        Scanner input = new Scanner(System.in);
        String employeeName = input.nextLine();
        
        payState.isEmpty();
      
        
    }
    public boolean isEmpty();
    {
        String employeeName;
        if (employeeName == true)
        {
            System.out.println ("Not entered");
            Scanner input = new Scanner(System.in);
            String employeeName = input.nextLine();
        }
         
    }
}      

[toc] | [next] | [standalone]


#2253

FromKnute Johnson <nospam@knutejohnson.com>
Date2012-11-10 16:16 -0800
Message-ID<k7mqpm$tho$1@dont-email.me>
In reply to#2252
On 11/10/2012 4:06 PM, tyrelmatadin921@gmail.com wrote:
> This code will not complile and it is really stressing me out.
> If someone could help me out i would really apreciate it. thanks in advanced
>
> package sheridan;
>
> import java.util.Scanner;
>
> public class PayrollStatement
> {
>      PayrollStatement payState = new PayrollStatment();
>
>      payState.printEmployeeName();
>
>      public void printEmployeeName()
>      {
>          System.out.println ("Please enter name");
>          Scanner input = new Scanner(System.in);
>          String employeeName = input.nextLine();
>
>          payState.isEmpty();
>
>
>      }
>      public boolean isEmpty();
>      {
>          String employeeName;
>          if (employeeName == true)
>          {
>              System.out.println ("Not entered");
>              Scanner input = new Scanner(System.in);
>              String employeeName = input.nextLine();
>          }
>
>      }
> }
>

I'm sure it won't.  Why don't you show us the error messages and tell us 
a bit about what it is you are trying to do?


-- 

Knute Johnson

[toc] | [prev] | [next] | [standalone]


#2254

Fromtyrelmatadin921@gmail.com
Date2012-11-10 16:39 -0800
Message-ID<f869ea35-cb8f-4d89-9035-c9825ae9847f@googlegroups.com>
In reply to#2253
On Saturday, November 10, 2012 7:16:55 PM UTC-5, Knute Johnson wrote:
> On 11/10/2012 4:06 PM, tyrelmatadin921@gmail.com wrote:
> 
> > This code will not complile and it is really stressing me out.
> 
> > If someone could help me out i would really apreciate it. thanks in advanced
> 
> >
> 
> > package sheridan;
> 
> >
> 
> > import java.util.Scanner;
> 
> >
> 
> > public class PayrollStatement
> 
> > {
> 
> >      PayrollStatement payState = new PayrollStatment();
> 
> >
> 
> >      payState.printEmployeeName();
> 
> >
> 
> >      public void printEmployeeName()
> 
> >      {
> 
> >          System.out.println ("Please enter name");
> 
> >          Scanner input = new Scanner(System.in);
> 
> >          String employeeName = input.nextLine();
> 
> >
> 
> >          payState.isEmpty();
> 
> >
> 
> >
> 
> >      }
> 
> >      public boolean isEmpty();
> 
> >      {
> 
> >          String employeeName;
> 
> >          if (employeeName == true)
> 
> >          {
> 
> >              System.out.println ("Not entered");
> 
> >              Scanner input = new Scanner(System.in);
> 
> >              String employeeName = input.nextLine();
> 
> >          }
> 
> >
> 
> >      }
> 
> > }
> 
> >
> 
> 
> 
> I'm sure it won't.  Why don't you show us the error messages and tell us 
> 
> a bit about what it is you are trying to do?
> 
> 
> 
> 
> 
> -- 
> 
> 
> 
> Knute Johnson
Ensure the name entered by the user is not empty (HINT: a string variable is an object which means you can call methods. Search JavaDoc for a method that will tell you if a string is empty or not (empty string = a string with no characters “”). If the name of the employee is empty print “not entered” instead of the name.

1 error found:
File: C:\Users\Turel\Documents\Object-Oriented Programing 1\employee payroll\sheridan\PayrollStatement.java  [line: 9]
Error: <identifier> expected

I have been trying to get this program to work for 2 days. ive tried every combination i could think of. 

[toc] | [prev] | [next] | [standalone]


#2256

FromKnute Johnson <nospam@knutejohnson.com>
Date2012-11-10 20:44 -0800
Message-ID<k7naeg$5e4$1@dont-email.me>
In reply to#2254
On 11/10/2012 4:39 PM, tyrelmatadin921@gmail.com wrote:
> On Saturday, November 10, 2012 7:16:55 PM UTC-5, Knute Johnson
> wrote:
>> On 11/10/2012 4:06 PM, tyrelmatadin921@gmail.com wrote:
>>
>>> This code will not complile and it is really stressing me out.
>>
>>> If someone could help me out i would really apreciate it. thanks
>>> in advanced
>>
>>>
>>
>>> package sheridan;
>>
>>>
>>
>>> import java.util.Scanner;
>>
>>>
>>
>>> public class PayrollStatement
>>
>>> {
>>
>>> PayrollStatement payState = new PayrollStatment();
>>
>>>
>>
>>> payState.printEmployeeName();
>>
>>>
>>
>>> public void printEmployeeName()
>>
>>> {
>>
>>> System.out.println ("Please enter name");
>>
>>> Scanner input = new Scanner(System.in);
>>
>>> String employeeName = input.nextLine();
>>
>>>
>>
>>> payState.isEmpty();
>>
>>>
>>
>>>
>>
>>> }
>>
>>> public boolean isEmpty();
>>
>>> {
>>
>>> String employeeName;
>>
>>> if (employeeName == true)
>>
>>> {
>>
>>> System.out.println ("Not entered");
>>
>>> Scanner input = new Scanner(System.in);
>>
>>> String employeeName = input.nextLine();
>>
>>> }
>>
>>>
>>
>>> }
>>
>>> }
>>
>>>
>>
>>
>>
>> I'm sure it won't.  Why don't you show us the error messages and
>> tell us
>>
>> a bit about what it is you are trying to do?
>>
>>
>>
>>
>>
>> --
>>
>>
>>
>> Knute Johnson
> Ensure the name entered by the user is not empty (HINT: a string
> variable is an object which means you can call methods. Search
> JavaDoc for a method that will tell you if a string is empty or not
> (empty string = a string with no characters “”). If the name of the
> employee is empty print “not entered” instead of the name.
>
> 1 error found: File: C:\Users\Turel\Documents\Object-Oriented
> Programing 1\employee payroll\sheridan\PayrollStatement.java  [line:
> 9] Error: <identifier> expected
>
> I have been trying to get this program to work for 2 days. ive tried
> every combination i could think of.
>

PayrollStatement is not the same thing as PayrollStatement. 
Mis-spellings cause unending problems when you attempt to compile.

The lines;

PayrollStatement paystate = PayrollStatement();
paystate.printEmployeeName();

need to be in the main() method.

public static void main(String[] args) {
	PayrollStatement ..............
	paystate.pr.................
}

Without a main() it isn't going to run even if it does compile.

You've got another problem with the semi-colon on the end of the 
function declaration for isEmpty().

-- 

Knute Johnson

[toc] | [prev] | [next] | [standalone]


#2257

FromRoedy Green <see_website@mindprod.com.invalid>
Date2012-11-11 02:51 -0800
Message-ID<hn0v9815rpaaoaa0tcct8u8o1vcrbnjga0@4ax.com>
In reply to#2254
On Sat, 10 Nov 2012 16:39:26 -0800 (PST), tyrelmatadin921@gmail.com
wrote, quoted or indirectly quoted someone who said :

>Error: <identifier> expected

                                                    
see http://mindprod.com/jgloss/compileerrormessages.html
for hints on what various error messages mean and possible causes.
-- 
Roedy Green Canadian Mind Products http://mindprod.com
Ironically, even though the Internet was created by the US military 
[DARPA (Defense Advanced Research Projects Agency)]
to withstand a nuclear attack, it is almost defenceless against malice
from any of its users

[toc] | [prev] | [next] | [standalone]


#2255

FromJoerg Meier <joergmmeier@arcor.de>
Date2012-11-11 01:51 +0100
Message-ID<11nhzaieixmnl$.16mungf4vrnml$.dlg@40tude.net>
In reply to#2252
On Sat, 10 Nov 2012 16:06:22 -0800 (PST), tyrelmatadin921@gmail.com wrote:

> This code will not complile and it is really stressing me out.
> If someone could help me out i would really apreciate it. thanks in advanced

There are really a multitude of problems with your code.

>     PayrollStatement payState = new PayrollStatment();

This creates an infinite loop: every time someone makes an instance of your
class, that instance then executes that line, which makes a new instance,
which then executes that line, which makes a new instance, which then
executes that line, which makes a new instance, which then executes that
line, which makes a new instance, which then executes that line, which
makes a new instance, which then executes that line, which makes a new
instance, which then executes that line, which makes a new instance, which
then executes that line, which makes a new instance, which then executes
that line, which makes a new instance, which then executes that line, which
makes a new instance, which then executes that line, which makes a new
instance, which then executes that line, which makes a new instance, which
then Exception in thread "main" java.lang.StackOverflowError

;)

>     payState.printEmployeeName();

This is neither a method declaration nor a variable/field declaration. It's
a 'command', and should be inside a method. You can't just randomly litter
method calls and hope they will be executed when you want them to by pure
chance. Odds are you want to put this call in your classes 'main' method -
read up on main methods and how to write one.

>         payState.isEmpty();

Your method claims to return a boolean, but here you call it and don't do
anything with that boolean. What do you expect to happen with the result ?

>     public boolean isEmpty();

Here is the method, and the claim that it will at some point return true or
false. It doesn't, however, which is also a critical compile time error. A
method must always return what it claims to return in its signature.

>         String employeeName;
>         if (employeeName == true)

StringS cannot be true, they can only be a string or null. As your teacher
told you, StringS have a method to test whether they are empty. Read the
documentation for String and look for that method, like you were told to.

>         {
>             System.out.println ("Not entered");
>             Scanner input = new Scanner(System.in);
>             String employeeName = input.nextLine();
>         }

This block does not do what you want it to do. You read in a new String,
but you assign it to a local variable, which is then immediatly discarded
on the next line.

Liebe Gruesse,
		Joerg

-- 
Ich lese meine Emails nicht, replies to Email bleiben also leider
ungelesen.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.help


csiph-web