Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TheSumBetweenTwoNumbers {
- public static void main(String[] args) {
- Scanner reader = new Scanner(System.in);
- System.out.println("First:");
- int first = Integer.parseInt(reader.nextLine());
- System.out.println("Last:");
- int last = Integer.parseInt(reader.nextLine());
- int y = 0;
- int sum = 0;
- while (y >= last) {
- sum = sum + y;
- y++;
- }
- System.out.println("The sum is " + sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement