How can I use only 1 variable to store the results of 5 arithmetic operations to be used inside the System.out.println? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I use only 1 variable to store the results of 5 arithmetic operations to be used inside the System.out.println?

7th Oct 2018, 9:03 AM
King Riou
King Riou - avatar
5 Answers
0
basically I have the result of five different operations in five different variables. Then the question said I need to use only one variable to store the results of the five operations.
7th Oct 2018, 10:13 AM
King Riou
King Riou - avatar
0
and yes I need to store five different results
7th Oct 2018, 10:14 AM
King Riou
King Riou - avatar
0
public class ArithmeticOperators { public static void main(String[] args){ int op1 = 15; int op2 = 4; int Sum = op1 + op2; int Difference = op1 - op2; int Product = op1 * op2; int Quotient = op1 / op2; int Remainder = op1 % op2; }}
7th Oct 2018, 10:38 AM
King Riou
King Riou - avatar
0
Question: use only one variable to store the results of each arithmetic operations to be used inside System.out.println statement
7th Oct 2018, 10:39 AM
King Riou
King Riou - avatar
0
Thanks alottt!!!😭 I just found out that the question given to us isn't taught yet. You're a big help😢
7th Oct 2018, 11:03 AM
King Riou
King Riou - avatar