Question (1): Write a program that asks the user to enter an integer greater than zero...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Answer rating: 100% (QA)
class InvalidInputException extends Exception InvalidInputString s supers import javau... View the full answer
Related Book For
Posted Date:
Students also viewed these electrical engineering questions
-
Write a program that asks the user to enter three names, and then display the name sorted in ascending order. for example if the user enterd "Charlie" , "Leslie" , and "Andy", the program would...
-
Write a program that asks the user to enter a favorite color, a favorite food, a favorite animal, and the first name of a friend or relative. The program should then print the following two lines,...
-
Write a program that asks the user to enter the size of a triangle (an integer from 1 to 50). Display the triangle by writing lines of asterisks. The first line will have one asterisk, the next two,...
-
Mr. Paulo Rodriguez, a fund manager of The Blackstone Group Inc. holds a portfolio with a current value of RM7.83 million. The cash index currently stands at 1,075 points. He fears that the market...
-
Why is it important to understand the macro-environment when making decisions about an international retail venture?
-
Why is real-time processing essential in an ERP system?
-
10.A company contracted with a marketing firm to construct software and create a business website. A quote was requested and accepted. Sometime later, the business asked for updates and revisions but...
-
Johnson Chemicals is considering two options for its supplier portfolio. Option 1 uses two local suppliers. Each has a unique- event risk of 5%, and the probability of a super- event that would...
-
Calculate the following for a 3 ft 4 ft window with the label to the right. The summer design conditions for peak cooling load are 70 and 60% RH inside; 90 and 90% outside; and a peak direct solar...
-
a) Using the FCFS (first come, first served) decision rule for sequencing the jobs, the order is (assume that jobs came in the order in which they are listed in the table): Sequence 1 2 3 4 Sequence...
-
= Three parallel plates having the same surface area A, are positioned as shown in the figure. The upper two plates are moving at V and V velocities while the bottom plate is fixed. A fluid having...
-
Use the prompt below to answer the next series of questions: You are an elementary-school principal and have a budget of $1m per annum. You can spend this on teachers, each with a total salary and...
-
#11. Exercise 11 of Chapter 5 describes a palindrome. Can you use one of the ADTS described in this chapter instead of a stack to see whether a string is a palindrome? Write a program with an...
-
A human heart weighs about 311 grams. How much does the heart weigh in ounces (oz)? (453.6 g 1 lb, 16 oz 1 lb) = = Have factor (convert to oz) 3. 311 grams 1. 2. 4. Fill in the correct values for 1,...
-
Two important differences between symmetric key encryption and public key encryption are: Select one: O a. (1) Symmetric key encryption is faster to perform the encryption than Public key encryption...
-
I recently had a prospective client ask, "D o yo ur clients with hedge accounts make money trading futures and options most years?" The truth is no, they don't because the purpose of a hedge is to...
-
A coffee distributor needs to mix a(n) Breakfast coffee blend that normally sells for $10.90 per pound with a Ethiopian coffee blend that normally sells for $12.70 per pound to create 80 pounds of a...
-
The following cost information was provided to you for analysis: September 12,000 Units Produced Costs: TIC TAC TOE TING August 10,000 P80,000 70.000 60.000 50,000 How much is the fixed cost per...
-
Calculate: (a) 412- 5.22/e5- 100.53 (b) 3132 + ln(500)/8 The following problems can be solved by writing commands in the Command Window, or by writing a program in a script file and then executing...
-
Create a row vector that has the following elements: 15 x 103, 25/14 62, ln 35/0.43, sin65/cos80, 129, and cos2(/20).
-
The speed of a race car during the first seven seconds of a race is given by: Determine the distance the car traveled during the first six seconds. 4 v (mi/h)0 14 399 95 114 129 139
-
Consider two alternatives, each of which will accomplish the same EPA-mandated pollution control. Using an incremental IRR analysis, determine the preferred alternative assuming MARR is 20...
-
The production department of Zunni's Manufacturing is considering two numerically controlled drill presses; one must be selected. Comparison data is shown in the table below. MARR is 10 percent/year....
-
What do you know about the mathematical value of the annual worth of a project under each of the following conditions? a. The present worth of the project is greater than 0 . b. The present worth of...
Study smarter with the SolutionInn App