Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-17-2009, 04:43 AM   PM User | #1
jman888
New Coder

 
Join Date: Apr 2009
Posts: 13
Thanks: 3
Thanked 0 Times in 0 Posts
jman888 is an unknown quantity at this point
( 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..
jman888 is offline   Reply With Quote
Old 12-17-2009, 12:56 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,661
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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).
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:27 AM.


Advertisement
Log in to turn off these ads.