Question

write a program that behaves like this exe in c+++ pleaseSample exe: Perfect Abundant or Deficient.exe Positive number classification as perfect, abundant, or deficient By H. Delta E

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/*

Abundant: The sum of the proper factors is greater than the number itself.
Deficient: The sum of the proper factors is less than the number itself.
Perfect: The sum of the proper factors is equal to than the number itself.

*/

#include<iostream>

using namespace std;

int main()
{
    int n,sum;
    float m;
   

     cout<<"\n             Psitive number classification as\n";
     cout<<"             perfect, abundant, or deficient:\n\n\n";

    while(1)
    {
      
        cout<<"Enter a number to be classified as perfect, abundant, or deficient: ";
        /* here float m handle the floatin point input */
        cin>>m;

        /* after taking floating point input
           convert into int value for further calculation.
        */
        n = int(m);
      
      
        /* this loop cheching positive interger value */
        while( n <= 0)
        {
            cout<<"This classification is for POSITIVE interger only. please try again: ";
            cin>>m;
            n = int(m);
        }

        sum = 0;

        /* finding proper factors */
        for(int i=1;i<n;i++)
        {
            if( n%i == 0 ) // i devide n
            {
                sum = sum+i;
            }
        }

        /*Abundant: The sum of the proper factors is greater than the number itself. */
        if( sum > n )
          cout<<"        "<<n<<" is a ABUNDANT number.\n";

        /*Deficient: The sum of the proper factors is less than the number itself. */
        else if( sum < n )
          cout<<"        "<<n<<" is a DEFICIENT number.\n";

        /* Perfect: The sum of the proper factors is equal to than the number itself. */
        else
          cout<<"        "<<n<<" is a PERFECT number.\n";


        cout<<"    **********************************************************************\n\n";


    }


    return 0;
}

sample schreenshot :

Psitive number classification as perfect, abundant, or deficient: Enter a number to be classified as perfect, abundant, or de

Add a comment
Know the answer?
Add Answer to:
write a program that behaves like this exe in c+++ please Sample exe: Perfect Abundant or...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Part 3: More Numeric Analysis Now add three more functions to the num_stats module you created...

    Part 3: More Numeric Analysis Now add three more functions to the num_stats module you created in part 2. These will determine if a given positive integer is EVEN, PERFECT and ABUNDANT. Each of these functions should accept a single integer as an argument and return whether the integer meets the criteria for that classification. Here's some IPO notation to get you started: # function: is_even # input: a positive integer # processing: determines if the supplied number is even...

  • a C++ program that computes the cost of a long-distance call. The cost of the call...

    a C++ program that computes the cost of a long-distance call. The cost of the call is determined according to the following rate schedule: a. Any call started between 8:00 A.M. and 6:00 P.M., Monday through Friday, is billed at a rate of $0.40 per minute. b. Any call starting before 8:00 A.M. or after 6:00 P.M., Monday through Friday, is charged at a rate of $0.25 per minute. c. Any call started on a Saturday or Sunday is charged...

  • please code in basic c++ program Write a program that uses the following formula: n (ax...

    please code in basic c++ program Write a program that uses the following formula: n (ax - ib) i=1 Your program will prompt the user for the number of iterations for the calculation. input values for n, x, a, b, and c. n must be a positive integer, but x, a, b, and c can be any real numbers. Then it will perform the calculation and output the result. Then, it will ask the user if they would like to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT