Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.InputMismatchException;
- import java.util.Scanner;
- public class Addition {
- private int total = 0;
- private Scanner in = new Scanner(System.in);
- private boolean proceed = true;
- public int setNumber(){
- while(proceed){
- System.out.println("Type a number to add or any 'letter' to quit");
- if(in.hasNextInt()){
- int temp = in.nextInt();
- total += temp;
- }else{
- proceed = false;
- }
- }
- return total;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement