0

I am confused on this

(1) Output the user's input. Enter integer: 4 You entered: 4 (2) Extend to output the input squared and cubed. Hint: Compute squared as userNum * userNum. Enter integer: 4 You entered: 4 4 squared is 16 And 4 cubed is 64!! (3) Extend to get a second user input into userNum2. Output sum and product. Enter integer: 4 You entered: 4 4 squared is 16 And 4 cubed is 64!! Enter another integer: 5 4 + 5 is 9 4 * 5 is 20 This is what I got so far on it. I'm hoping someone could help me on it and I can look over it to see how you did it for reference thanks. import java.util.Scanner; public class OutputWithVars { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int userNum= 0; System.out.println("Enter another integer: "); userNum = scnr.nextInt(); return; } }

4th Sep 2019, 5:32 AM
chad
1 ответ
0
For square and cube int sq = userNum * userNum; int cube = userNum * userNum * userNum; For product and and addition: Simply take 2nd numbers from user and multiply the input with first input and store it in some variable and same with addition.
4th Sep 2019, 6:03 AM
blACk sh4d0w
blACk sh4d0w - avatar