Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help me with this assignment. i cant understnad how to solve it i Task A perfect number is an integer that is equal to

please help me with this assignment. i cant understnad how to solve itimage text in transcribedi

Task A "perfect" number is an integer that is equal to the sum of its divisors (where is considered a divisor). For example, 6 is perfect because its divisors are 1,2, and 3, and2+3 is 6. Similarly, 28is perfect because it equals 12+4+7+14 A "quite good" number is an integer whose "badness-the size of the difference betwecn the sum of its divisors and the number itself-is not greater than a specified value. For example, if the maximum badness is set at 3, there are 12 "quite good" numbers less than 100: 2, 3,4, 6, 8, 10, 16, 18, 20, 28, 32, and 64; Your task is to write a C++program, quitegood, that determines numbers of a specified maximum badness that are less than a specified value. The limiting value and maximum badness are specified as command-line arguments when the program is executed. A simple strategy is to try all possible numbers from 2 up to the specified limit For each candidate number, calculate the sum of the candidate's divisors. If the difference between the sum and the candidate is not greater than the maximum badness, the number is considered "good enough Automatic Marking This task is available for automatic testing using the name quitegood. Run the demo using demo quitegood and test your work using try quitegood >. When you're ready to submit your work, use handin quitegood >. and submi the ticket number via FLO. If your source code consists of more than one file, youll need to submit a zip file. Level 1: Small perfect numbers Begin by writing a peogram that prints perfect numbers (badness 0) up to values less than 10000, separated by a single space. For example quitegood 100 should print 6 28 Level 2: Small near-perfect numbers Extend the program so that the badness limit can be specified as a second command-line parameter. For example quitegood 100 3 will print 2 3 4 6 8 10 16 18 20 28 32 64. Level 3: Large numbers Modify the program so that it will work efficiently for values up to at least 1000000. For example quitegood 1000000 1 should print 2 46 8 16 28 32 64 128 256 496 512 1024 2048 4096 8128 8192 16384 32768 65536 131072 262144 524288 Level 4: Displaying a count Modify the program so that a negative badness value causes the program to output a count of the "quite good" numbers, rather than the numbers themselves. For example Flinders University College of Science and Engineering Computer Programming 2 Prac 1 quitegood 1000000 1 should print 23 because there are 23 numbers less than 1000000 with badness no more than

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

More Books

Students also viewed these Databases questions