Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @(#)Program5.java
- *
- * Edward Jones
- * @version 1.00 2011/1/31
- */
- import java.util.Scanner;
- class Program3
- {
- public static void main(String[] args)
- {
- Scanner input = new Scanner(System.in);
- // VARS
- int counter;
- int num=0;
- String inRange=("N");
- int total=0;
- String numbers=("x");
- int answer=("x");
- while (inRange.equalsIgnoreCase ("N"))
- {
- System.out.println("Please Enter A number between 1-200");
- num=input.nextInt();
- if (num >=1 && num <=200)
- {
- for (counter=1;counter<=num;counter++)
- numbers = (numbers + "+" + counter);
- answer= (num * (num + 1)) / 2 ;
- System.out.println(numbers+" "+Integer.toString(answer));
- }
- else
- {
- System.out.println("You enterd "+num+" this is out of range");
- inRange=("N");
- }
- System.out.println(total);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement