Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
i know how to user scanner object but i dont know how to calculate

What I have tried:

im having a problem in ordering the program syntax
Posted
Updated 22-Feb-17 12:10pm
Comments
Graeme_Grant 22-Feb-17 17:45pm    
This sounds like homework ....
Jaw Duha 22-Feb-17 17:47pm    
i tried my best ! i need help :/
Graeme_Grant 22-Feb-17 17:55pm    
This is pretty simple. If you are stuck, then you should talk to classmates or your teacher. Google is a very good place to look. We are not going to do your homework for you.
Patrice T 22-Feb-17 18:23pm    
For now, your best is nothing.
Show your code, at least we will know you don't just want a full blowup solution.
Use Improve question to update your question.

Quote:
but i dont know how to calculate
im having a problem in ordering the program syntax

I am sorry, but this is "Coding 101" level, you need to reread your lessons.
Come back if you have a specific problem once you have some code.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.
 
Share this answer
 
Hello,

I'm not going to write it for you but here are a few clues.
First you need to ask for the number, using Java it could be something like

Scanner (Java Platform SE 8 )[^]

Google a bit and you should find how to do it. There are many ways to do it, this is just an example.

Secondly you need to loop from 1 to the number entered. This is achieved using a loop.

The for Statement (The Java™ Tutorials > Learning the Java Language > Language Basics)[^]

Thirdly you need to calculate the values requested, it's just a series of additions in the loop and a division after the loop.
Java Basic Operators[^]

lastly display the results.
Java Output[^]

Google is your friend. There are countless learning resources.

Valery
 
Share this answer
 
Comments
Graeme_Grant 22-Feb-17 18:15pm    
Homework is usually based on what is taught. So they already have the information on them. You have given too much.
Valery Possoz 22-Feb-17 18:42pm    
Fair enough.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900