Got Homework?
Connect with other students for help. It's a free community.
Here's the question you clicked on:
 0 viewing
Write a program which given an integer n, classifies it as 'perfect', 'abundant' or 'deficient'. A number is perfect if the sum of its divisors ( excluding the number itself) is equal to the number, e.g. 6. A number is abundant if the sum of its divisors(excluding the number itself) is greater than the number, e.g. 12. A number is deficient if it is neither perfect nor abundant
 one year ago
 one year ago
Write a program which given an integer n, classifies it as 'perfect', 'abundant' or 'deficient'. A number is perfect if the sum of its divisors ( excluding the number itself) is equal to the number, e.g. 6. A number is abundant if the sum of its divisors(excluding the number itself) is greater than the number, e.g. 12. A number is deficient if it is neither perfect nor abundant
 one year ago
 one year ago

This Question is Closed

time_to_learnBest ResponseYou've already chosen the best response.0
What do you need help with in this problem?
 one year ago

bunyonbBest ResponseYou've already chosen the best response.0
Give at least a pseudocode so that I can understand what to do
 one year ago

KonradZuseBest ResponseYou've already chosen the best response.0
you should try this program out yourself first, before asking people to do it for you.
 one year ago

bunyonbBest ResponseYou've already chosen the best response.0
#include <iostream> 08 using namespace std; 09 10 int main() 11 { 12 int number,counter,total; 13 14 /* Asks for user input*/ 15 cout << "Welcome to the program Factors, this program check to see\n" 16 << "if the number you enter is deficent, perfect or abundant\n" 17 << "this program will read in numbers till you enter 1 and or negitive numbers"; 18 19 while (number > 1) 20 { 21 22 counter = 1; 23 cout << endl; 24 cout << "Please enter a Integer:\n"; 25 cin >> number; 26 cout << endl; 27 28 29 30 if (number % counter == 0) 31 { 32 total= counter + (number % counter); 33 34 cout << total << "+"; 35 counter++; 36 } 37 38 39 40 if (number < total) 41 { 42 cout << endl; 43 cout << number <<" is abundant\n"; 44 45 } 46 else if (number>total) 47 { 48 cout << endl; 49 cout << number << " is deficient\n"; 50 51 cout << endl; 52 } 53 else 54 { 55 cout << endl; 56 cout << number << " is Perfect\n"; 57 58 cout << endl; 59 } 60 61 } 62 63 cout<< endl << endl << endl; 64 system ("pause"); 65 return 0; 66 }
 one year ago

KonradZuseBest ResponseYou've already chosen the best response.0
I mean, what are they?
 one year ago

bunyonbBest ResponseYou've already chosen the best response.0
I think something is wrong with my values?
 one year ago

bunyonbBest ResponseYou've already chosen the best response.0
But i cannot put my finger on it...
 one year ago

KonradZuseBest ResponseYou've already chosen the best response.0
The thing which is annoying is you have to add up EVERY possible combination. So for 12 it's 3 + 4 + 2 + 6....
 one year ago

bunyonbBest ResponseYou've already chosen the best response.0
its like adding prime factors of 12 excluding itself?
 one year ago

bunyonbBest ResponseYou've already chosen the best response.0
so if it is working on a number that isnt perfect It will work through the IF statements to see if it is abundant and another to see if it is deficient
 one year ago

bunyonbBest ResponseYou've already chosen the best response.0
I will post the code properly
 one year ago

bunyonbBest ResponseYou've already chosen the best response.0
#include <iostream> using namespace std; int main() { int number = 0,counter,total; /* Asks for user input*/ cout << "Welcome to the program Factors, this program check to see\n" << "if the number you enter is deficent, perfect or abundant\n" << "this program will read in numbers till you enter 1 and or negitive numbers"; while (number > 1) { cout << endl; cout << "Please enter a Integer:\n"; cin >> number; if (number < 0) { break; } cout << endl; counter = 1; total = 0; while (counter < number) { if (number % counter == 0) { cout << total << "+" << counter; total += counter; cout << "=" << total << endl; } counter++; } if (number < total){ cout << endl; cout << number <<" is abundant\n"; } else if (number>total) { cout << endl; cout << number << " is deficient\n"; cout << endl; } else { cout << endl; cout << number << " is Perfect\n"; cout << endl; } } cout<< endl << endl << endl; system ("pause"); return 0; }
 one year ago

bunyonbBest ResponseYou've already chosen the best response.0
#include <iostream> using namespace std; /* */ int main () { int highNum, abunTotal, defTotal, perfTotal; abunTotal = 0; // sum of divisors more than the number itself defTotal = 0; // sum of divisors less than the number itself perfTotal = 0; // sum of divisors equal to the number itself int sum = 0; cout<< "Please enter a positive integer:"; cin>> highNum; for(int i = 1; i <= highNum; i++ ) { sum = 0; for(int j = 1; j < i; j++ ) { if((i % j) == 0) { sum += j; } } if ( sum == i) //the number is perfect { perfTotal++; cout << "PERFECT NUMBER: " << i << endl; } if ( sum < i) //the number is deficient { defTotal++; } if ( sum > i) //the number is abundant { abunTotal++; } } cout << "The perfTotal is:" << perfTotal << endl; cout << "The defTotal is:" << defTotal << endl; cout << "The abunTotal is:"<< abunTotal << endl; cout << endl; }
 one year ago
See more questions >>>
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.