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

February 6th, 2006, 11:24 PM
|
|
Registered User
|
|
Join Date: Feb 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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?
|
|

February 7th, 2006, 10:20 AM
|
|
Registered User
|
|
Join Date: Feb 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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...
|
|

February 7th, 2006, 10:30 AM
|
|
Registered User
|
|
Join Date: Feb 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

February 22nd, 2006, 07:32 AM
|
|
Registered User
|
|
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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));
}
}
|
|

March 20th, 2007, 11:42 PM
|
|
Authorized User
|
|
Join Date: Mar 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

March 25th, 2007, 06:49 AM
|
|
Registered User
|
|
Join Date: Mar 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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 |
|
 |