Write a Java program that reads a positive, non-zero integer as input and checks if the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Java program that reads a positive, non-zero integer as input and checks if the integer is deficient, perfect, or abundant. A positive, non-zero integer, N, is said to be perfect if the sum of its positive proper divisors (i.e.. the positive integers, other than N itself, that divide N exactly) is equal to the number itself. If this sum is less than N, the number is said to be deficient. If the sum is greater than N. the number is said to be abundant. The first few perfect numbers are 6, 28, 496, and 8128. Illustrations: Number 6 28 Factors of the number less than itself Sum of Factors 3,2.1 14, 7, 4, 2, 1 6 28 For example, the number 6 is perfect, since 6=1+2+3, the number 8 is deficient, since 8>1+2+4, while the number 12 is abundant, since 12 <1+2+3+4+6. Sample Input/Output: Depicted below are sample outputs when the program is executed (the items in bold characters are input from the user, while the items in bold italic are calculated and printed by the program): Input N: 5 5 is deficient. Input N: 6 6 is perfect. Input N: 18 18 is abundant. Required: The flowchart, the java file (Family Name Perfect.java) containing the code and 3 image files (Sample1, Sample2 and Sample3) containing different sample input/output of the program. Write a Java program that reads a positive, non-zero integer as input and checks if the integer is deficient, perfect, or abundant. A positive, non-zero integer, N, is said to be perfect if the sum of its positive proper divisors (i.e.. the positive integers, other than N itself, that divide N exactly) is equal to the number itself. If this sum is less than N, the number is said to be deficient. If the sum is greater than N. the number is said to be abundant. The first few perfect numbers are 6, 28, 496, and 8128. Illustrations: Number 6 28 Factors of the number less than itself Sum of Factors 3,2.1 14, 7, 4, 2, 1 6 28 For example, the number 6 is perfect, since 6=1+2+3, the number 8 is deficient, since 8>1+2+4, while the number 12 is abundant, since 12 <1+2+3+4+6. Sample Input/Output: Depicted below are sample outputs when the program is executed (the items in bold characters are input from the user, while the items in bold italic are calculated and printed by the program): Input N: 5 5 is deficient. Input N: 6 6 is perfect. Input N: 18 18 is abundant. Required: The flowchart, the java file (Family Name Perfect.java) containing the code and 3 image files (Sample1, Sample2 and Sample3) containing different sample input/output of the program.
Expert Answer:
Answer rating: 100% (QA)
Here is a Java program that reads a positive nonzero integer as input from the user and determines whether the number is deficient perfect or abundant import javautilScanner public class PerfectNumber public static void mainString args Scanner scanner new ScannerSystemin SystemoutprintInput N int num scannernextInt int sum 0 for int i 1 i num i if num i 0 sum i if sum num Systemoutprintlnnum is deficient else if sum num Systemoutprintlnnum is perfect else Systemoutprintlnnum is abundant In the program We take an input integer N from the user We calculate the sum of all positive proper divisors of N numbers less than N that divide N exactly Based on the comparison of the sum with N we determine ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Predictive text entry systems are familiar on touch screens and mobile phones. This question asks you to consider how the same principles might be used in a programming editor for creating Java code....
-
Let r and s be solutions to the quadratic equation x 2 b x + c = 0. For n N, define d0 = 0 d1 = r s dn = b dn1 c dn2 (n 2) Prove that dn = r n s n for all n N. [4 marks] (b) Recall that a commutative...
-
In 2006, Walmart was operating more than 6,500 stores with 1.8 million employees around the world. In the early 1990s, Walmart Stores Inc. expanded into Canada, with the purchase of 122 stores from...
-
The National Hurricane Center provides data that list the numbers of large (category 3, 4, or 5) hurricanes that have struck the United States, by decade since 1851 (www.nhc.noaa.gov/dcmi.shtml). The...
-
Empty Fields Company pays its salaried employees monthly on the last day of each month. The annual salary payroll for 20-- follows. Compute the following for the payroll of December 31: OASDI Taxable...
-
Long has been engaged to audit the financial statements of Maylou Corporation. To help consider controls over purchases. Long obtained the purchases flowchart Required: Identify the procedures for...
-
1. What are the costs to other stakeholders in society beyond those that Reuters included? How would these costs be estimated? 2. Has the cost of lost reputation been included by Reuters? If no, how...
-
Parex Ltd., a listed Canadian company that follows IFRS, acquired 90% of outstanding shares of sheet information and other information are as below: balance Cash and receivables Parex Carrying value...
-
write a closed-research legal memo using the case cases given, addressing whether Mr. Adler can assert an adverse possession claim to Scrub Lot 40. Please write up your memo using the issue , brief...
-
Use the arc-approximation formula to calculate the price-elasticity of demand coefficient of a firm's product demand between the (quantity, price) points of (12, $20) and (18, $16). (b) Calculate the...
-
AndrIt iss dissolved 36.167gSn(C2H302), in enough distilled water to make 200.0mL of solution. Perform the following calculations regarding this solution: A. What is the molarity of this solution?...
-
By definition, an important aspect of culture is that it is living and living things evolve and change over time; they leave legacies. For this week, please discuss the connections you see between...
-
Peter Drucker indicated that it might be a waste of resources for organisations to invest in a training programme that is either unnecessary or inaccurate. Critically examine situations that may...
-
The Company produces organic butter for sale. No direct materials other than milk are used. Production data for April 2 0 1 5 are shown below: April Beginning Work in Process Inventory: Units (...
-
We're going to create a Google Sheet showing the value of an investment in your future. Well compare two different scenarios: Account A) Investing $1000 when you are 20 years old into an account...
-
1. Which of the following BEST describes a business unit where the manager is primarily responsible for generating sales revenue? A. Investment center B. Cost center C. Revenue center D. Profit...
-
Refer to the situation described inBE 18-13, but assume a 2-for-1 stock split instead of the 5% stock dividend. Prepare the journal entry to record the stock split if it is to be effected in the form...
-
A coil of # 12 AWG copper wire wound in a single layer on a cylindrical form so that the mean diameter of each turn is 6.0 in., and it has a resistance of 4.0 . How many turns of wire are there in...
-
Consider the following circuit setup shown below. Determine the voltage drop across the 7 resistor. 120 V DC 12 www 5 H 402 www 50 70 V
-
Find the capacitance that minimizes the source current when connected in parallel with a single-phase induction motor drawing 10 A at a power factor of pf = 0.80 (lagging) when connected to 120 V, 60...
Study smarter with the SolutionInn App