Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2009
    Posts
    13
    Thanks
    3
    Thanked 0 Times in 0 Posts

    ( or { expected & illegal start of operation & ; expected

    Code:
    /* My Java Program 
    Failing To Compile 2009 - CurrentDate()
    */
    /* Importing */
    import java.util.Scanner;
    import acm.graphics.*;
    import acm.program.*;
    
    
    class run {
    
    	public static void main(String args[]){
    	//Variables
    	Scanner ninjatext = new Scanner(System.in);
    	Scanner Clarinet_Request = new Scanner(System.in);
    	System.out.println(ninjatext.nextLine());
    	double pye, var1, ans;
    	String yodawg;
    	var1 = 2;
    	pye = 3.14;
    	yodawg ="I heard you like saxaphones  ";
    	ans = var1/pye;
    		System.out.println("Hello Cruel World?");
    		System.out.print(yodawg);
    		System.out.print("So i bought you ");
    		System.out.print(ans);
    		System.out.println(" Saxxes");
    		System.out.println("So How many Clarinets Would you like????");
    		System.out.println("Enter Number::");
    		System.out.println("So " + Clarinet_Request.nextLine() + " Is how many clarinets You would like? Cool");
    	/*Please end up working*/
    	// Declaring Variables Semi-Randomly Works, Right?
    	String test1 = "Ok i hope this works";
    	int test2 = 10;
    	double test3 = 4.9;
    	int test4 = test2/test3; //Random Weird Awnser right???
    	System.out.println(test2 + "Divided by" + test3 + "Is Equal To" + test4);
    	/* This all should work, at least in theory.... But it wont right? */
    	/** What have i gotten myself into? Oh well it sounds like it should work */
    	Console console = System.console();
    	String username = console.readLine("Lets Do This?: ");
    	if (/* String? */username == "yes" || "Yes" || "YES"){
    		testingthiscrap LeroyJenkins = new testingthiscrap
    		LeroyJenkins.LetsDoThis()
    	}
    	/* Guaranteed to not work */
    	}
    public class testingthiscrap extends GraphicsProgram {
    	/** Runs the program */
    	public void LetsDoThis() {
    		GRect rect = new GRect(100, 50, 100, 100 / PHI);
    		rect.setFilled(true);
    		rect.setColor(Color.RED);
    		add(rect);
    		GOval oval = new GOval(150, 50 + 50 / PHI, 100, 100 / PHI);
    		oval.setFilled(true);
    		oval.setColor(Color.GREEN);
    		add(oval);
    	}
    
    /** Constant representing the golden ratio */
    	public static final double PHI = 1.618;
    
    /* Standard Java entry point */
    /* This method can be eliminated in most Java environments */
    	public static void main(String[] args) {
    		new FeltBoard().start(args);
    	}//If anything i just typed i now feel heroic.
    }
    //
    }
    	// public static void 
    }

    Ok, sorry if the titles not good enough but i am a php programmer between begginer and intermediate but who wants to know java so i can say write a applet or something that can run from the desktop directly, also i wanted to lean OO and it in php confuses me infinately so i decided in the context of knowing nothing i might pick it up better thus java.

    So most of what im doing is confusing to me so i just tried to type some code (Well the first 20 maybe lines i compiled and tested but after that i couldnt test so i just ran with it. Today i tried to compile and poof, nothing.

    Any clues what im doing wrong and what i should do instead?

    BTW this stuff feels weird, i feel like to take imput it should have a html form or something. I dunno.

    also i dont even seem to have these acm packages im trying to import, any clue why?
    Last edited by jman888; 12-17-2009 at 04:46 AM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Assuming that all the custom classes exist, the only problems are int test4 = test2/test3; should be int test4 = (int)(test2/test3);, you have an extra closing } token, delete the last one, and equality on strings cannot be checked like this: if (/* String? */username == "yes" || "Yes" || "YES"){. You can do the last one using if(username.compareToIgnoreCase("yes") == 0).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •