Question

In: Computer Science

Ch 4 Program 4A: Factorial.java                                     &n

Ch 4 Program 4A: Factorial.java                                                 

Please adhere to the Standards for Programming Assignments and the Java Coding Guidelines.


Write a program that computes the factorial of a number that is input from the user.  

A factorial is the product of all the numbers up to the number entered.  

For example, 6-factorial is 720 because 6*5*4*3*2*1 is 720.  

Six-factorial is written as 6!  

Prompt the user for the numeric input between 1 and 10.  

Do not accept numbers greater than 10 or less than 1.( Check out the input/data Validation page on Canvas in module 4B)

Calculate and display the factorial. All code must reside in the main() method

Do not use any concept that is not covered in class.  

Include output from this Test Data:          22

                                                                        7

                                                                        1

Example Output with Valid inputs:

*******Factorial*********

Please enter a value between 1-10: 5

5! = 120

Goodbye!!

Example Output with an Invalid input:

*******Factorial*********

Please enter a value between 1-10: 12

Value is out of range. Please Re-enter a value between 1-10 :

17

Value is out of range. Please Re-enter a value between 1-10 :

8

8! = 40320

Goodbye!!

Solutions

Expert Solution

Ans-

}

}

}

}

OUTPUT-

​​​​


Related Solutions

Ch 4 Program 5: RockPaperScissors.java                                    &
Ch 4 Program 5: RockPaperScissors.java                                                  Please adhere to the Standards for Programming Assignments and the Java Coding Guidelines. In the game Rock Paper Scissors, two players simultaneously choose one of three options: rock, paper, or scissors. If both players choose the same option, then the result is a tie. However, if they choose differently, the winner is determined as follows Rock beats scissors because a rock can break a part of scissors Scissors beats paper because scissors can cut paper...
Ch 4 Program 3  – Geometry Calculator Please adhere to the Standards for Programming Assignments and the...
Ch 4 Program 3  – Geometry Calculator Please adhere to the Standards for Programming Assignments and the Java Coding Guideline. : List of source code with comments to document Test output listed as comments at the end of your program GeometryCalculator.java (15 pts) Write a program that displays the following menu: Calculate the area of a circle Calculate the area of a rectangle Calculate the area of a triangle Calculate the volume of a cylinder Quit Prompt the user to enter...
4A. When the price of normal good N increases, the amount of N consumed decreases. The...
4A. When the price of normal good N increases, the amount of N consumed decreases. The part of the decrease in N consumption due to an increase in the relative price of N is a the marginal rate of substitution b the income effect. c marginal utility. d the substitution effect. e the network externality effect. 4B Which of the following statements about a Giffen good is false? A For a Giffen good, the income effect dominates the substitution effect....
6.27 Ch 2 Program: Painting a wall (C++) (4)Calculate the cost of the paint. Paint comes...
6.27 Ch 2 Program: Painting a wall (C++) (4)Calculate the cost of the paint. Paint comes in six colors (Red, Yellow, Green, Blue, Black,White) Assign numbers 0-5 to these paint colors ie Red =0 and White =5. The costs for each of these paints is as follows:(2 pts) Now your program will be submission ready. Main.cpp #include <iostream> #include <cmath> using namespace std; #include "paint.h" int main() {    double wallHeight;    double wallWidth;    double wallArea;    double gallonsPaintNeeded;...
The electronegativities of the -C≡CH and -C≡N groups are the same, but the dipole moments of...
The electronegativities of the -C≡CH and -C≡N groups are the same, but the dipole moments of the CH3C≡CH and the CH3C≡N are 0.78 D and 3.92 D, respectively. Explain why the dipole moments are so different.
The thermal decomposition of dimethyl ether CH 3 2 O g CH 4 g H 2...
The thermal decomposition of dimethyl ether CH 3 2 O g CH 4 g H 2 g CO g is to be carried out in an isothermal 2.00-liter laboratory reactor at 600°C. The reactor is charged with pure dimethyl ether at a pressure of 350 torr. After about two hours, the reactor pressure is 875 torr. (a) Has the reaction proceeded to completion at the end of the two-hour period? If not, what percentage of the dimethyl ether has decomposed?...
Prove that for every n ∈ N: a) (10^n + 3 * 4^(n+2)) ≡ 4 mod...
Prove that for every n ∈ N: a) (10^n + 3 * 4^(n+2)) ≡ 4 mod 19, [note that 4^3 ≡ 1 mod 9] b) 24 | (2*7^(n) + 3*5^(n) - 5), c) 14 | (3^(4n+2) + 5^(2n+1) [Note that 3^(4n+2) + 5^(2n+1) = 9^(2n)*9 + 5^(2n)*5 ≡ (-5)^(2n) * 9 + 5^(2n) *5 ≡ 0 mod 14]
5. Write a CH program that takes the marks of a student as input and prints...
5. Write a CH program that takes the marks of a student as input and prints the grade on screen according to the following criteria: CRITERIA LESS THAN 60 GREATER THAN 60 BUT LESS THAN 65 GREATER THAN 65 BUT LESS THAN 70 GREATER THAN 70 BUT LESS THAN 75 GREATER THAN 75 BUT LESS THAN 80 GREATER THAN 80 BUT LESS THAN 85 GREATER THAN 85 BUT LESS THAN 90 GREATER THAN 90 GRADE F D D+ с C+...
3. Refer to Ch 4, pg 132- 4 in BM. We are going to calculate the...
3. Refer to Ch 4, pg 132- 4 in BM. We are going to calculate the velocity of the Earth today (let’s say 7 Feb 2020) using the vis viva equation. Take a deep breath... (a) Calculate the "mean anomaly" of the Earth M. This is the angle from perihelion to the position of Earth as if the Earth were in a circular orbit. You have to look up the perihelion of the Earth. See pg 34 in BM. This...
Biological Anthropology: Ch. 3- Genetics: Reproducing Life & Producing Variation Ch. 4-Genes Their Evolution: Population Genetics...
Biological Anthropology: Ch. 3- Genetics: Reproducing Life & Producing Variation Ch. 4-Genes Their Evolution: Population Genetics (Please TYpe) Chapter 4 1. Microevolution, macroevolution 2. Reproductive isolation 3. Hardy-Weinberg Law 4. Four forces of evolution 5. Mutation types 6. Three patterns of natural selection 7. Admixture, founder’s effect Chapter 5 1. Race: historical and modern concepts, issues with the concept, etc. 2. Blumenbach, Boas, Lewontin 3. Four levels of human adaptation 4. Terms related to adaptation (stress, homeostasis, plasticity, functional adaptation)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT