Given an integer n, print the value of n after applying the following operations: increment n by 1, then decrement n by 2, then double the resulting value of n.
Increment and decrement
Increment, decrement, then double n
Report a typo
Sample Input 1:
5Sample Output 1:
8Sample Input 2:
10Sample Output 2:
18Write a program in Java 17
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// Read the integer input
int n = Integer.parseInt(reader.readLine());
// TODO: Increment n by 1
// TODO: Decrement n by 2
// TODO: Double the resulting value of n
// Print the final value of n
System.out.println(n);
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.