Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 6th, 2006, 11:24 PM
Registered User
 
Join Date: Feb 2006
Location: Belleville, NJ, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to nappydyno234 Send a message via Yahoo to nappydyno234
Default Source Code

I am trying to create source code that outputs my name and the pow(x,y) function where x and y are inputed and the power is outputted after my name. I have tried various things, but nothing seems to work. Does anyone have any basic pseudocode, or even source code that could be of use?
Reply With Quote
  #2 (permalink)  
Old February 7th, 2006, 12:33 AM
Authorized User
 
Join Date: Aug 2005
Location: Chelmsford, MA, USA.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There are various ways to do this. You can do this using Graphics2D.
If you want to do this using null layout, look at this absolute positioning example, See the demonstration at the end.

http://www.javareference.com/jrexamp...mple.jsp?id=26

Thanks,
Rahul

rahul@javareference.com
--------------------------
http://www.javareference.com
Reply With Quote
  #3 (permalink)  
Old February 7th, 2006, 10:20 AM
Registered User
 
Join Date: Feb 2006
Location: Belleville, NJ, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to nappydyno234 Send a message via Yahoo to nappydyno234
Default

I created my program, and it looks like this:

public class power {
    public static void main(String[] args) {
     int base;
     int order;
     int p;
     System.in.println(base, order);
     System.out.println("Java power" base order);
     System.out.println("Mariner Eccles");
     p = pow(base, order);
     System.out.println(p);
    }
}

When I go to compile, it comes up with this:

power.java:7: ')' expected
     System.out.println("Java power" base order);
                                     ^
1 error

I am new at this, so I dont quite understand what the error i...if anyone out there knows, I would appreciate it greatly...



Reply With Quote
  #4 (permalink)  
Old February 7th, 2006, 10:30 AM
Registered User
 
Join Date: Feb 2006
Location: Belleville, NJ, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to nappydyno234 Send a message via Yahoo to nappydyno234
Default

I figured out that initial error, but I received three more errors for the following source code:

public class power {
    public static void main(String[] args) {
     int base;
     int order;
     int p;
     System.in.println(base, order);
     System.out.println("Java power" base order);
     System.out.println("Mariner Eccles");
     p = pow(base, order);
     System.out.println(p);
    }
}

power.java:6: cannot find symbol
symbol : method println(int,int)
location: class java.io.InputStream
     System.in.println(base, order);
              ^
power.java:7: cannot find symbol
symbol : method println(java.lang.String,int,int)
location: class java.io.PrintStream
     System.out.println("Java power", base, order);
               ^
power.java:9: cannot find symbol
symbol : method pow(int,int)
location: class power
     p = pow(base, order);
         ^
3 errors

Once again, if anyone knows anything on how to help, please let me know. It would be greatly appreciated.




Reply With Quote
  #5 (permalink)  
Old February 22nd, 2006, 07:32 AM
Registered User
 
Join Date: Feb 2006
Location: Karachi, Sindh, Pakistan.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You are missing import statement. Try the following code. It will work; however use of System.in needs thorough knowledge of streams/buffers/channels.

import static java.lang.Math.*;
public class Test {
public static void main(String[] args) {
int base = 2;
int power = 5;
System.out.println(base+" power "+ power + " = "+pow(2,5));
}
}
Reply With Quote
  #6 (permalink)  
Old March 20th, 2007, 11:42 PM
Authorized User
 
Join Date: Mar 2007
Location: Hyderabad, A.P, India.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

u get error because in java the fileds must be intlized.
and u try every time in System.out.println the concate operator is used

K.Mallikarjunarao
Reply With Quote
  #7 (permalink)  
Old March 25th, 2007, 06:49 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zhangzhangt
Default

look..

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
source code in C# rajum BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 December 26th, 2006 09:06 AM
where is the source code allenjiang Wrox Book Feedback 2 November 1st, 2006 01:32 AM
source code please sureshganni J2EE 0 November 18th, 2004 08:42 AM
Source code amit_Kinariwala All Other Wrox Books 2 February 17th, 2004 12:54 AM



All times are GMT -4. The time now is 10:00 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.