MHB ZyBooks: 2.4.1: Enter the output of the integer expressions.

Click For Summary
The discussion focuses on understanding a programming problem involving variable assignments and print statements. Initially, variables x and y are set to 3 and 0, respectively. The command "y = (2 * (x + 3)) + 6" calculates the new value of y based on the current value of x. After executing this command, y will be updated accordingly. The conversation then explores the output of various print statements: "system.out.print(x)" displays the value of x, while "system.out.print(y)" shows the updated value of y. The combined print statement "System.out.print(x + " " + y)" outputs both values of x and y in a formatted string. The discussion emphasizes understanding variable manipulation and output in programming.
zbandicoot1491
Messages
1
Reaction score
0
I'm not sure how to do these problems here. Help me learn them please!
View attachment 7289
 

Attachments

  • Capture.PNG
    Capture.PNG
    13.6 KB · Views: 122
Technology news on Phys.org
Okay, let's go through it step by step. Initially, x is set to 3 and y is set to 0. Now, do you understand what the command "y= (2*(x+ 3))+ 6" means? What will x and y be after that is executed?

Then what would "system.out.print(x)" do? What about "system.out.print(y)". So what about "System.out.print(x+ " "+ y)?
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
Replies
1
Views
8K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 34 ·
2
Replies
34
Views
5K
Replies
9
Views
3K
  • · Replies 59 ·
2
Replies
59
Views
11K
  • · Replies 21 ·
Replies
21
Views
3K
Replies
18
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K