Java Program Write a program which asks calculates the factorial of a number n. The number...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Java Program Write a program which asks calculates the factorial of a number n. The number n must be taken from the user. The program should calculate the factorial and should ask user that does he/she wants to calculate factorial of another number. If the user enters 'y' or 'Y' then the program must ask for another number for which factorial needs to be calculated. A sample output is shown on next page. (Hint: Factorial of any integer is multiplication of that integer with all other integers less than that integer till integer 1. For example factorial of 4 is 4*3*2*1 and factorial of 7 is 7*6*5*4*3*2*1. Specifications . . Ask the user to enter a number and then calculate factorial of that number (Hint: use loop to calculate factorial). (Marks 5) Ask user do you want calculate factorial of another number. If the user types 'y or 'Y' ask the user to enter another number. The process should continue until the user keeps on entering 'y or 'Y. Use a loop for asking user to enter number again. (Marks 2) Please enter the number for which you want to calculate the factorial: 4 24 Do you want to calculate factorial of another number? Y Please enter the number for which you want to calculate the factorial: 5 120 Do you want to calculate factorial of another number? Y Please enter the number for which you want to calculate the factorial: 6 720 Do you wady to calculate factorial of another number? n Bye! Your answer Java Program Write a program which asks calculates the factorial of a number n. The number n must be taken from the user. The program should calculate the factorial and should ask user that does he/she wants to calculate factorial of another number. If the user enters 'y' or 'Y' then the program must ask for another number for which factorial needs to be calculated. A sample output is shown on next page. (Hint: Factorial of any integer is multiplication of that integer with all other integers less than that integer till integer 1. For example factorial of 4 is 4*3*2*1 and factorial of 7 is 7*6*5*4*3*2*1. Specifications . . Ask the user to enter a number and then calculate factorial of that number (Hint: use loop to calculate factorial). (Marks 5) Ask user do you want calculate factorial of another number. If the user types 'y or 'Y' ask the user to enter another number. The process should continue until the user keeps on entering 'y or 'Y. Use a loop for asking user to enter number again. (Marks 2) Please enter the number for which you want to calculate the factorial: 4 24 Do you want to calculate factorial of another number? Y Please enter the number for which you want to calculate the factorial: 5 120 Do you want to calculate factorial of another number? Y Please enter the number for which you want to calculate the factorial: 6 720 Do you wady to calculate factorial of another number? n Bye! Your answer
Expert Answer:
Answer rating: 100% (QA)
Code import javautilScanner public class FactorialCalculator p... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
ABC Ltd prepares its financial statements to 31 October each year. Its trial balance at 31 October 2019 was as follows: Premises-cost Manufacturing plant-cost Office equipment-cost Accumulated...
-
Briefly describe the key characteristics of each of the following forms of interest paying checking accounts: (a) NOW account, (b) MMDA, and (c) MMMF.
-
In 2003, the American Psychological Association conducted a survey (at research.apa.org) of a random sample of psychologists to estimate mean incomes for psychologists with various academic degrees...
-
An \(R L C\) circuit consists of a \(48 \Omega\) resistor, a \(200 \mu \mathrm{F}\) capacitor, and an inductor. The rms current is \(2.5 \mathrm{~A}\) when the circuit is connected to a \(120...
-
Taussig Technologies Corporation (TTC) has been growing at a rate of 20% per year in recent years. This same growth rate is expected to last for another 2 years, then decline to gn = 6%. a. If D0 =...
-
locate a Credit Union or Bank that offers auto loans. Identify a potential new vehicle that you are interested in. Utilizing the purchase price and the Annual Percentage Rate (APR) that is identified...
-
Determine the magnitude and direction, measured counterclockwise from the positive x' axis, of the resultant force of the three forces acting on the bracket. Given: F1 = 300 N F2 = 200 N F3 = 180 N...
-
In Canada, chartered banks are legally allowed to engage in all but which of the following activities through their branches? Multiple Choice Make commercial loans. Accept deposits. Help investors...
-
Create a Java class named Student with the following attributes: private String lName; private double GPA; private int currentCredits; private int totalCredits; private String fName; Create a method...
-
True, False, Uncertain. Explain. Q.1 A rise in the Canadian interest rate R $ relative European rates raises Canadian money demand L(R $ , Y C ) thereby causing an appreciation of the dollar...
-
The NPV method measures change in value and is thus easy to align with the firm objective of maximizing value. True False
-
You are a CFO of a large company and you are aware that some of your managers are overcharging on their expense reports for lunches and dinners. In some cases, you know that charges are being made...
-
BACHELOR OF BANKING AND FINACE ANS FINANCIAL RISK MANAGEMENT why did you choose to study the discipline/field at Uni that you ended up choosing? What interests you about working with us here at the...
-
Find the Inverse Fourier Transform of the following functions: 1 (a) F(a) : 6+5ia-a2 2 sin a (b) F(a) %3D a(1+a2)
-
Parkin Industries, a U.S. company, acquired a wholly-owned subsidiary, located in Italy, at the beginning of the current year, for 200,000. The subsidiary's functional currency is the euro. The...
-
Write a question for this problem that involves critical thinking and explain why it involves critical thinking.
-
Go to the LearnChemE screencast link for Chapter 14 (http://www.learncheme.com/screencasts/kinetics-reactor design). View one or more of the screencast 5-to 6-minute videos and write a two-sentence...
-
The dehydration of butanol is carried out over a silica-alumina catalyst at 680 K. CH3CH2CH2CH2OHcatCH3CH=CHCH3+H2O The rate law is rBu=kPBu(1+KBuPBu)2 with k = 0.054 mol/gcathatm and K Bu = 0.32 atm...
-
For a sample of data where n = 4 given below: a. Calculate the mean, median, and mode. b. Calculate the range, variance, standard deviation, and coefficient of variation. c. Calculate the Z scores....
-
For a sample of data where n = 8 given below: a. Calculate the mean, median, and mode. b. Calculate the range, variance, standard deviation, and coefficient of variation. c. Calculate the Z score....
-
Assume that one of the investments listed in your investment portfolio had a 22% return in the first year and -28% return in the second. Calculate the geometric rate of return per year.
Study smarter with the SolutionInn App