Hey guys, new to programming, and my teacher wants us to declare two variables : num1 and num2, and have the user input values, then run it through 2*num1 - num2.
Here is what I have so far, and I am lost and frustrated:
Kindly use code tags when you post code here. It looks much better
Let's look at this line You need to receive an input from the user and assign it to num1, correct? Look at how you can do it using Scanner in this link.
You should be able to figure it out. Let us know how you go.
Thanks you for showing me this, I guess my greatest issue is that I have no idea how to use the code provided. As in, where should I put it in my program?
Think about what you're doing in this line of code. The nextInt() method is used to receive an integer input from the user. Do you need an input from the user to compute your answer?
You're right, I don't need an input. I need the program to take the inputed values of num1 and num2 and calculate them. How should I go about doing that?
Dan Good wrote:You're right, I don't need an input. I need the program to take the inputed values of num1 and num2 and calculate them. How should I go about doing that?
Simply do System.out.println(2 * num1 - num2); or make answer equal (2 * num1 - num2) first and then System.out.println(); it out
Inputs, Outputs, decrements, increments, class string, at Fairfield University. We use the book Java Programming: From Problem Analysis to Program Design. The book is difficult to follow if you know nothing about coding...
Dan Good wrote:Inputs, Outputs, decrements, increments, class string, at Fairfield University. We use the book Java Programming: From Problem Analysis to Program Design. The book is difficult to follow if you know nothing about coding...
well for beginners Head first java is the best book so far