Jump to content

help with computer science homweork

Go to solution Solved by Wtalk2,

I'm pretty sure the issue is the evenodd function is never closed. Just add another '}' right above the posotivenegative function and that should fix it :)

right now i'm a junior in high school and our school offers some online courses, I thought some sounded cool so i decided to try them. Right now i'm taking "computer science honors" and need some help or quick suggestions on how to fix this problem.

 

it says there is an illegal start of expression for the underlined portion, but i cant figure out how to fix it, if anyone here knows any java programming using netbeans the help would be appreciated.

 

here is the code, its pretty short:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

package favoritenumber;

 
import java.util.Scanner;
 
public class FavoriteNumber {
 
    // Obtain favorite number
    public static void main(String[] args) {
    int favoritenumber;
        Scanner reader = new Scanner (System.in);
        
        System.out.println ("What is your favorite number?");
        favoritenumber = reader.nextInt ();
    
        evenodd (favoritenumber);
        positivenegative (favoritenumber);
    }
    
    //calculate stuff with number
    public static boolean evenodd (int favoritenumber){
      boolean evenorodd = (favoritenumber%2 == 0);    
      
      if (evenorodd) {
      System.out.println ("your favorite number is both even ");
      
      } else {
      System.out.println ("your favorite number is both odd ");
      return false;
      }     
 
    public static boolean positivenegative (int favoritenumber){         <------this is the part that is the "illegal start of expression"
      boolean positiveornegative = (favoritenumber > 0);    
 
      if (positiveornegative) {
      System.out.print ("and positive");
      
      } else {
      System.out.print ("and negative");
      return false;
      }      
   return false;
    }
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
any help is appreciated :)
"Anything that makes a console more like a PC, makes it better" 

-Linus Sebastian

Link to comment
Share on other sites

Link to post
Share on other sites

The number 69 is missing from all those strings.

jk sorry don't kill me

~Just the tips


 The only good human being is a dead human being. 


I5 4690K MSI GTX 970 GAMING 4G MSI Z97 GAMING 5 G.SKILL RIPJAWS X 2X8GB 1600MHZ CL10 CORSAIR CX750M CRUCIAL MX100 512GB 2X WD BLUE 1TB CORSAIR 300R BENQ RL2455HM ♦ WIN 8.1 PRO ♦ UBUNTU 14.04

Link to comment
Share on other sites

Link to post
Share on other sites

The number 69 is missing from all those strings.

jk sorry don't kill me

hey its better than making a topic without any responses

"Anything that makes a console more like a PC, makes it better" 

-Linus Sebastian

Link to comment
Share on other sites

Link to post
Share on other sites

I'm pretty sure the issue is the evenodd function is never closed. Just add another '}' right above the posotivenegative function and that should fix it :)

My Current Build: 

Intel i5 3570K @ 4.4GHz 1.11V, Cooler Master Hyper 212 EVO, Asrock Z77 Extreme4, Corsair Vengeance 8GB 1600MHz, Samsung 840 EVO 250GB, Asus GTX 760 DCII Overclocked, Corsair CX600M

Link to comment
Share on other sites

Link to post
Share on other sites

I'm pretty sure the issue is the evenodd function is never closed. Just add another '}' right above the posotivenegative function and that should fix it :)

many thanks

"Anything that makes a console more like a PC, makes it better" 

-Linus Sebastian

Link to comment
Share on other sites

Link to post
Share on other sites

many thanks

Wow, I'm kinda surprised I found that :P Anyways glad I could help :)

My Current Build: 

Intel i5 3570K @ 4.4GHz 1.11V, Cooler Master Hyper 212 EVO, Asrock Z77 Extreme4, Corsair Vengeance 8GB 1600MHz, Samsung 840 EVO 250GB, Asus GTX 760 DCII Overclocked, Corsair CX600M

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×