WHY?

The following code is pretty unreadable:

void start() {
	int q = 30;
	int r = 10;
	int a = 10 + 30 * q;
	int z = q * q + a;
	int sum = a * q + q;
	int x = 5000;
	int m = 20;
	int s = 30 + 60 * m;
	int l = s + s * m;
	int sum2 = m * s * l;
	int result = sum + sum2;
	System.out.println("This is the result: " + result);
}

Working with methods would result in this:

int difficultSum1() {
	int q = 30;
	int r = 10;
	int a = 10 + 30*q;
	int z = q * q + a;
	return a * q + q;
}

int difficultSum2 () {
	int m = 20;
	int s = 30 + 60 * m;
	int l = s + s * m;
	return m * s * l;
}

void start() {
	int result = difficultSum1() + difficultSum2();
	System.out.println("This is the result: " + result);

	//not used in the final result
	int x = 5000;
}

there was even a variable that wasn’t even included in the sum. It happens often when the code is not clear you forgot to delete┬áredundant variables.

What is return?

method return java