Program That Sums Inputted Numbers And Gives Error If It Is Not A Number Using Try/Catch Block In Java

LEVEL: Beginner

Whats in this post?

  1. Code
  2. Output
  3. Background and Explanation of the code

Code


To copy code: Click  View Source “View Source” on the right of this code snippet.

Background and Explanation of the code


A simple program that uses try/catch block to capture what the user inputs. If its a number it sums it and prints it out or else it prints an error message.