• Log in or sign up for an account here: https://www.sythe.org/login

A Day 3 Exercise In Learning Java

jamesm201

Forum Addict
Joined
Feb 7, 2011
Sythe Gold
22
Messages
308
Location
USA
Today we are going to learn how to make java add up pre set numbers for you.
Using the template that I've shown you before set up the file and declare the int num and int num2 and result. Then give them a value here i gave each a value. Using both num and num2 we are going to give result the multiplicative value of them multiplied

Then after declaring it give it a value, for now use the ones i have provided in my file at the bottom. Using the shown bellow give result the num * num 2 number(don't solve it put what i did bellow)
Then make java execute result to see if it equals what it should equal 14 if not look for mistakes then post on here so i can help you.

int num;
int num2;
int result;

num = 7;
num2 = 2;
result = num * num2;(*for Multiply / for devide - for subtraction + for adding)
System.out.print("num times num2 equals: ");
System.out.println(result);
}
}
Thanks for some edits from rsgold4u
 
if you going to post java code to help people at least post it correctly.

All of the "system.out.print" MUST be "System.out.print"

If you are going to add a commend you must have /**/ or //

If you are going to display numbers in a print statement you must do this.

system.out.print("num times num2 equals: ");

MUST BE

System.out.print(num + "times " + num2 + " equals: ");
 
Your incorrect its optional for putting it all in one system.out.print statement for the sake of them learning it and memorizing it i put it as split. Thanks though that is also another way.
Thanks its been a long day and i was sick thanks it would suck to see someone mess up from a little error like that
 
you should use
Code:
 Code
tags
 
Runescape Gamblingrunescape gambling
Back
Top