Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A useful approximation to the value of n! for large values of n is given by S n = sqrt(2pi)e -n n n+(1/2) Develop a

A useful approximation to the value of n! for large values of n is given by Sn = sqrt(2pi)e-nnn+(1/2)

Develop a Java application in a class named FactorialApproximation that prompts for and reads one integer numeric amount that represents the value of n for n!. Use the approximation formula to calculate n!.

Requirements

Use at least 2 named constants in your code

Display a header for your application.

Ask the user for the value of n.

Restrict the values of n to whole numbers that are greater than 0 and less than 100. Any value that is outside this range should cause the program to end after an error message is printed.

If the value of n is in the proper range, calculate the estimated value of n!

Display the approximation of n! that results, with an appropriate label.

If the value of n is equal to 5 or 7, compare the actual value of 5!, or 7!, to the value calculated by the formula. Then print the difference (actual value - calculated value) with an appropriate label.

Display your name as programmer at the end.

Use the Scanner class for input, and use System.out.print or System.out.println for output.

Your program must use the single class FactorialApproximation and only one static void main method.

Your code must not use loops, return statements, System.exit(), arrays or collections

The equation is ((sqrt(2pi))(e^-n)(n^n+(1/2))

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

Students also viewed these Databases questions

Question

How are members held accountable for serving in the assigned roles?

Answered: 1 week ago