- 2

help code jave

Write a java program to display the sum of 2 numbers a and b if a>b and their product if a<=b.

9th Feb 2021, 12:08 PM
yous
yous - avatar
3 odpowiedzi
+ 1
It will be better if you scanner input
9th Feb 2021, 1:23 PM
Atul [Inactive]
+ 1
Show your attempt first
9th Feb 2021, 12:09 PM
Atul [Inactive]
0
public static void main(String[] args) { int a; int b; int sum; System.out.print("Enter two numbers to add\n"); String tempVar = ConsoleInput.scanfRead(); if (tempVar != null) { a = Integer.parseInt(tempVar); } String tempVar2 = ConsoleInput.scanfRead(); if (tempVar2 != null) { b = Integer.parseInt(tempVar2); } sum = a + b; System.out.printf("Sum of the numbers = %d\n", sum); }
9th Feb 2021, 12:15 PM
yous
yous - avatar