Using C# Microsft Visual C#, Console Application
I'm needing help with the user entering in a number to tell if it perfect or not. I have the perfect number figure out. Here in the instruction:
1. An integer number is said to be a perfect number if its factors, including 1 (but not the number itself), sum to the number. For example, 6 is a perfect number, because 6 = 1 + 2 + 3. Write a method Perfect that determines whether parameter numberis a perfect number. Use this method in an application that determines and displays all the perfect numbers between 2 and 1000. Display the factor of each perfect number to confirm that the number is indeed perfect.
Your solution shoud be the followings:
Write a class called PerfectNumber with two methods. The first method:
public string Perfect( int value ) that determines if value is perfect and if so returns a string that contains the factors.
Hint on how to have a string that contains the factors:
string factors = “1“;
factor += “ + “ + fac; // fac is a factor of the perfect number
The second method:
public void FindPerfects()
that determintes the perfect numbers between 2 and 1000 and prints their factors.
The Main method simply creates an object of PerferNumber and calls
FindPerfects().
You must compile and test the program.
I'm needing help with the user entering in a number to tell if it perfect or not. I have the perfect number figure out. Here in the instruction:
1. An integer number is said to be a perfect number if its factors, including 1 (but not the number itself), sum to the number. For example, 6 is a perfect number, because 6 = 1 + 2 + 3. Write a method Perfect that determines whether parameter numberis a perfect number. Use this method in an application that determines and displays all the perfect numbers between 2 and 1000. Display the factor of each perfect number to confirm that the number is indeed perfect.
Your solution shoud be the followings:
Write a class called PerfectNumber with two methods. The first method:
public string Perfect( int value ) that determines if value is perfect and if so returns a string that contains the factors.
Hint on how to have a string that contains the factors:
string factors = “1“;
factor += “ + “ + fac; // fac is a factor of the perfect number
The second method:
public void FindPerfects()
that determintes the perfect numbers between 2 and 1000 and prints their factors.
The Main method simply creates an object of PerferNumber and calls
FindPerfects().
You must compile and test the program.
Comment