Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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?
  #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
  #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...



  #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.




  #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));
}
}
  #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
  #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..



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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.