Democratic Underground Latest Greatest Lobby Journals Search Options Help Login
Google

Anyone Familiar with programming Java?

Printer-friendly format Printer-friendly format
Printer-friendly format Email this thread to a friend
Printer-friendly format Bookmark this thread
This topic is archived.
Home » Discuss » The DU Lounge Donate to DU
 
Mr. Blonde Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 06:07 PM
Original message
Anyone Familiar with programming Java?
I'm in desperate need of help for my class. I might eventually be able to figure it out, but I just need some quick help.
What is wrong with this:
system.out.println(n + 3 = + (n * n * n) )
Printer Friendly | Permalink |  | Top
phantom power Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 06:09 PM
Response to Original message
1. Well, the "= +" part looks suspicious
Edited on Tue Jun-15-04 06:09 PM by e j e
And the fact that you are printing what may be a numeric expression, but I'm not even sure about that.

What are you trying to do (in english)?
Printer Friendly | Permalink |  | Top
 
Mr. Blonde Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 06:11 PM
Response to Reply #1
2. it is for a class
I'm trying to find the error in this program. Should I take out the plus?
Printer Friendly | Permalink |  | Top
 
phantom power Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 06:14 PM
Response to Reply #2
4. Or, you might take out the "="
That way, it will evaluate to a numeric expression, which should then get cast into a string automatically.

Is this some kind of homework question, where you are just supposed to find a syntax error and correct it? Or are you trying to achieve some actual programming goal?
Printer Friendly | Permalink |  | Top
 
Mr. Blonde Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 06:17 PM
Response to Reply #4
5. As far as I'm concerned
I just need to fix the syntax. The program will do something, but I don't get any points for the program.
Printer Friendly | Permalink |  | Top
 
Mr. Blonde Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 06:13 PM
Response to Original message
3. messed up
Edited on Tue Jun-15-04 06:16 PM by Mr. Blonde
system.out.println(n + "^3 = " + (n * n * n) )

Here is the full file but the error is in the above line.

import java.io.*;

public class CubeIt

{
public static void main(String[] args) throws IOException

{
// set up an input stream
BufferedReader stdin = new BufferedReader(
new InputStreamReader(System.in));

// prompt the user for input
System.out.print("Please enter a number: ");
// extract the user input
double n = Double.parseDouble(stdin.readLine());

// print the results

System.out.println(n + "^3 = " + (n * n * n))

}
}

Printer Friendly | Permalink |  | Top
 
phantom power Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 06:20 PM
Response to Reply #3
6. semicolon should be at the end
Printer Friendly | Permalink |  | Top
 
Mr. Blonde Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 06:21 PM
Response to Reply #6
8. next question
I'm struggling adding to the file. I think I'm in over my head.
Printer Friendly | Permalink |  | Top
 
phantom power Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 06:23 PM
Response to Reply #8
10. what are you editing the file with?
Printer Friendly | Permalink |  | Top
 
Mr. Blonde Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 06:27 PM
Response to Reply #10
12. Its
a unix thing I believe. Or csa if that means anything.
Printer Friendly | Permalink |  | Top
 
Renew Deal Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 06:20 PM
Response to Reply #3
7. I am running it through jGrasp right now.
I will try to figure it out. That looks like a mess.
Printer Friendly | Permalink |  | Top
 
Mr. Blonde Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 06:22 PM
Response to Reply #7
9. thank you n/t
Printer Friendly | Permalink |  | Top
 
Renew Deal Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 06:24 PM
Response to Reply #9
11. You should be able to figure this out.
Edited on Tue Jun-15-04 06:26 PM by Bleachers7
You are close. Here is the result when I fixed it.

Please enter a number: 33
35973.0

The program works. Your only mistake is in the System.out.println line. You have bad syntax and bad math.

PEMDAS
Printer Friendly | Permalink |  | Top
 
Mr. Blonde Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 08:34 PM
Response to Original message
13. One more problem
I have the file working and it did what it is supposed to do I guess because I was able to go on to the next step. But when on that step I recieve this message:
Exception in thread "main" java.lang.noclassDeffounderror: CubeIt/class

Any further help would be appreciated.
Printer Friendly | Permalink |  | Top
 
Renew Deal Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 08:41 PM
Response to Reply #13
14. Where is your code?
Printer Friendly | Permalink |  | Top
 
Mr. Blonde Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 08:44 PM
Response to Reply #14
15. code?
what I put in for the last part?
Printer Friendly | Permalink |  | Top
 
LincolnMcGrath Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Jun-15-04 08:54 PM
Response to Original message
16. Who needs Leo LaPorte!
Just Kidding, Leo is the man.
Printer Friendly | Permalink |  | Top
 
DU AdBot (1000+ posts) Click to send private message to this author Click to view 
this author's profile Click to add 
this author to your buddy list Click to add 
this author to your Ignore list Tue Apr 23rd 2024, 09:26 PM
Response to Original message
Advertisements [?]
 Top

Home » Discuss » The DU Lounge Donate to DU

Powered by DCForum+ Version 1.1 Copyright 1997-2002 DCScripts.com
Software has been extensively modified by the DU administrators


Important Notices: By participating on this discussion board, visitors agree to abide by the rules outlined on our Rules page. Messages posted on the Democratic Underground Discussion Forums are the opinions of the individuals who post them, and do not necessarily represent the opinions of Democratic Underground, LLC.

Home  |  Discussion Forums  |  Journals |  Store  |  Donate

About DU  |  Contact Us  |  Privacy Policy

Got a message for Democratic Underground? Click here to send us a message.

© 2001 - 2011 Democratic Underground, LLC