# Thread: New Learner Question

1. Member
Join Date
Feb 2017
Posts
4
Rep Power
0

## New Learner Question

Hi guys, I have been trying to learn java for a couple of weeks and managed to get some questions from my boyfriends old uni papers. I have been working through them and I have got stuck on a one that I can't quite work out. I was hoping someone could point me in the right direction please.

The question says. Create a Java program that uses two integers (number1 and number2) to calculate the result of number 1 squared plus number 2 squared.

Now I though it was something like Math.pow(number1*2) but I can't get it working, sorry about being so thick. It is brand new to me.

Thanks guys Emma.

2. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,226
Rep Power
13

## Re: New Learner Question

If you really want to use the Math.pow() function, then it takes two arguments, the number and the power (your * should be a ,). But for something
like this (where you are using integers), I would just write out the actual expression using multiplication and addition.

Regards,
Jim

3. Member
Join Date
Feb 2017
Posts
4
Rep Power
0

## Re: New Learner Question

Hi Jim, could you give me an example of how to set that out please, sorry I am really new to this.

4. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,226
Rep Power
13

## Re: New Learner Question

First, as someone new to Java, you should bookmark this -> Java Platform SE 8
It is the API and has the documentation on all methods. Here is the Math class -> Math (Java Platform SE 8 )

Math.pow(x,y) raises x to the yth power and returns the result.

Or to square a number, just do

int a = 10;
int sqr = a * a; // sqr is now 100.

EDIT: I forgot to include this link which is also useful -> http://docs.oracle.com/javase/tutorial/index.html

Regards,
Jim
Last edited by jim829; 02-07-2017 at 05:01 PM.

5. Member
Join Date
Feb 2017
Posts
4
Rep Power
0

## Re: New Learner Question

Ok I am in over my head here, I can't understand any of this. Think I will start learning something a little easier, thanks.

6. Member
Join Date
Jan 2017
Posts
38
Rep Power
0

## Re: New Learner Question

Did you write that equation on a paper?

7. Member
Join Date
Feb 2017
Posts
4
Rep Power
0

## Re: New Learner Question

Originally Posted by cronnin
Did you write that equation on a paper?
Hi, I don't really understand equations, I just wanted to try and do a few questions but I cant follow the answers given in here or any of the information from the links to other websites. I will just have to forget Java, thanks.

8. ## Re: New Learner Question

Originally Posted by NewLearnerEmma
Hi, I don't really understand equations, I just wanted to try and do a few questions but I cant follow the answers given in here or any of the information from the links to other websites. I will just have to forget Java, thanks.
Don't give up so quick. There are lots of people willing to help here.

9. Member
Join Date
Dec 2016
Posts
20
Rep Power
0

## Re: New Learner Question

I hear python is the new language that students pick up first. You might want to look into some python tutorials/courses to take if you are giving up on Java

10. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,226
Rep Power
13

## Re: New Learner Question

Perhaps. But every programming language I have every studied (sans APL) has similar operators and method, function, or subroutine calls. So the OP would still need to understand that in any language. Even some of the basic contructs of Java can be learned within the static main context without understanding the nature of a class or object. But I agree she (everyone actually) should become familiar with programming at its basic level.

Regards,
Jim

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•