Computer Science, asked by rimjhimpaul737, 3 months ago

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 allysia
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