Hello and welcome to our community! Is this your first visit?
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
    Thanked 0 Times in 0 Posts

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

    /* 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[]){
    	Scanner ninjatext = new Scanner(System.in);
    	Scanner Clarinet_Request = new Scanner(System.in);
    	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("So i bought you ");
    		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
    	/* Guaranteed to not work */
    public class testingthiscrap extends GraphicsProgram {
    	/** Runs the program */
    	public void LetsDoThis() {
    		GRect rect = new GRect(100, 50, 100, 100 / PHI);
    		GOval oval = new GOval(150, 50 + 50 / PHI, 100, 100 / PHI);
    /** 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
    Saskatoon, Saskatchewan
    Thanked 2,662 Times in 2,631 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'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


    Posting Permissions

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