Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a factorial code in visual studio. product = 1 * 2 * 3 . * N In your program, define the variable product as

Write a factorial code in visual studio.

product = 1 * 2 * 3 . * N

In your program, define the variable product as of type double. The product of the first N integers is also known as the factorial of N. Use the built-in function FACT in Excel to verify that your program indeeds finds the correct value of the factorial of N.

Through trial and error, find out the maximum value of N that your program correctly computes. Include that threshold value of N in the message to the user asking for a value of N.

As part of the input validation checks, ensure that the number N entered by the user is a positive integer greater than or equal to 0 and less than or equal to the maximum threshold value for N. Also, ensure that your program does not crash if the user enters non-numeric characters at the console. Print on the console a suitable message for an invalid value of N.

Valid input values of N are: 0 (the factorial of 0 is 1, hence 0 is actually a valid value of N) Any positive integer greater than 0 such as 45 but less than or equal to the maximum threshold of correct operation of the program.

Invalid input values of N are: Any negative number such as -20 Any number with a decimal such as 78.4 Anything that has non-numeric characters such as 272eft& Any positive integer that exceeds the threshold within which the program works correctly.

The error message that your program prints out should not be a generic error message but should identify the type of error that the user made. For example, if the user entered a negative number, then the error message printed on the console should be:

Error: Negative numbers are not valid values for N

As another example, if the user entered a number that exceeds the maximum threshold within which the program works correctly, then error message should be: Error: A number larger than ___ is not a valid value of N (of course, here you have to supply the largest permissible value of N in the error message) So check for all erroneous input values and provide suitable error messages.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions