Question: Question (1): Write a program that asks the user to enter an integer greater than zero and store it in a variable called n.

Question (1): Write a program that asks the user to enter an integer greater than zero and store it in a variable called "n". Then it calculates the final value that will be stored in a variable called "s" according to the following equation. S = 1! - 2! + 3! - 4! + (+ or - ) N! .. And add an exception when the user enters any value other than integer or zero shows the message "You entered non-integer or zero value, please try again.", and let the user to enter a new value. Enter an integer: 4 S=-19 Example 1 Enter an integer: a You entered non-integer value or zero, please try again. Enter an integer: 4 S--19 Example 2
Step by Step Solution
3.52 Rating (155 Votes )
There are 3 Steps involved in it
class InvalidInputException extends Exception InvalidInputString s supers import javau... View full answer
Get step-by-step solutions from verified subject matter experts
