SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.InputMismatchException;
  2. import java.util.Scanner;
  3. public class Addition {
  4.     private int total = 0;
  5.     private Scanner in = new Scanner(System.in);
  6.     private boolean proceed = true;
  7.  
  8.     public int setNumber(){
  9.         while(proceed){
  10.             System.out.println("Type a number to add or any 'letter' to quit");
  11.             if(in.hasNextInt()){
  12.                 int temp = in.nextInt();
  13.                 total += temp;
  14.             }else{
  15.                 proceed = false;
  16.             }
  17.         }
  18.         return total;
  19.     }
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top