• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

How to calculate Java code?

 
Ranch Hand
Posts: 230
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I could not make a copy paste
but i don't understand how to calculate this java code
Thank you for your help
 
Sheriff
Posts: 7123
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by "how to calculate this java code"?  Could you explain it in other words?  (I appreciate that English may not be your first language.)
 
Marshal
Posts: 76845
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can simply copy'n'paste code onto the white area in the post window. The same place as where you write the questions. You can drag'n'drop code, too.
Have you been taught how to indent code? I think it should look like this:-There is an error, that line 19 is missing a final ;
Change all your ""s to " " so you can see the numbers separately, then run the code.
Write the values of x y z on paper and go through the code like this:-

line 99 x = 3 y = 4 2x + y = 10
line 100 ...

or similar. Be sure to write the current values on your paper, otherwise you will forget what they are and will become confused.
 
ronald deux
Ranch Hand
Posts: 230
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
excuse me for my english, i'm not english, i'm using google translate
I know how to make a copy paste but it didn't work, I had to type the code by hand
I do calculations on paper to arrive at the same answers when you click on run but I can't
I give you the output, what interests me is to understand each line of code to arrive at the same results

3 0
1 2 4
4 3
5 2 4
8 1
5 9 4
 
Campbell Ritchie
Marshal
Posts: 76845
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do what I said yesterday: write down the values for all the variables for each line. I think that is the only way you will understand the code.
 
Saloon Keeper
Posts: 9724
80
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This code has a lot of things to try and confuse you. For example, the main method has a local variable 'x' and the mystery method has its own local variable 'x', these are not the same.
 
ronald deux
Ranch Hand
Posts: 230
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok, i haven't thought about that, without the mystery variable, i can't get the same answers.
I did all kinds of calculations without the mystery variable and it gave nothing
it took my head this code,
I have a question about z--, it's the same as z-1 ???
 
Campbell Ritchie
Marshal
Posts: 76845
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ronald deux wrote:. . . question about z--, it's the same as z-1 ???

No. i-- is the same as the original value of i. The value equal to i − 1 is not visible until later. That causes no end of confusion to inexperienced people. Look at this FAQ.
 
I knew that guy would be trouble! Thanks tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic