write a statement in java for. If A has a value greater than equal to 10 then increment the value of X by 2 otherwise decrement the value by 1.
Plz give me fast
Answers
Answered by
17
Language:
JAVA
Program:
import java.util.Scanner;
public class brainly {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Enter the value of n: ");
int n = scan.nextInt();
if (n > 10) {n += 2; System.out.println("New value:" + n); }
else {n -= 1; System.out.println("New value:" + n);}}}
Output:
Enter the value of n: 15
New value:17
Explanation:
- num+=a increases the previous value of num by a.
Attachments:
Attachments:
Similar questions
Computer Science,
1 month ago
Math,
1 month ago
Math,
1 month ago
English,
3 months ago
Political Science,
9 months ago
Math,
9 months ago
Social Sciences,
9 months ago