Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement