Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class alternatechecker {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int[] num = new int[10];
- int sum = 0;
- int sign = 1;
- for (int i = 0; i < 10; i++)
- {
- System.out.println("Numbers please" + (i+1) );
- num [i] = in.nextInt();
- sum += sign*num[i];
- sign *= -1;
- }
- System.out.println("sum = " + sum);
- }
- }
Add Comment
Please, Sign In to add comment