Question
Write a C++ program to allow a user to enter in any positive number greater than or equal to zero. The program should not continue
Write a C++ program to allow a user to enter in any positive number greater than or equal to zero. The program should not continue until the user has entered valid input. Once valid input has been entered the application will determine if the number is a deficient number or not and display whether or not the number is a deficient number. If the user enters in a 0 the program should quit.
An abundant number is a number n for which the sum of its proper divisors is less than itself (i.e., <n).
Consider 12: the proper divisors = ( 1,2 ,3,4,6)
1+2+3+4+6 = 16 > 12 (12 is NOT deficient)
Consider 10: the proper divisors = ( 1,2 ,5 )
1+2+5 = 8< 10 (10 is deficient)
Make sure your program conforms to the following requirements: 1. This program should be called DeficientNumbers.cpp 2. Keep running until the user enters a 0. (5 points) 3. Make sure the number is positive (at least 0). (5 points). 4. Determine if the number is deficient or not and print a message to the user. (35 points) 5. Add comments wherever necessary. (5 points)
Sample Runs:
NOTE: not all possible runs are shown below.
Sample Run 1
Welcome to the deficient numbers program Please enter in an number (>=0)...10 10 is a deficient number Please enter in a number (>=0)...12 12 is NOT a deficient number Please enter in a number (>=0)...-8 Please enter in a number (>=0)...4 4 is a deficient number Please enter in a number (>=0)...0
Process finished with exit code 0
General Requirements: 1. No global variables (variables outside of main() )
2. Please make sure you are only using the concepts already discussed in class. That is, please try and restrict yourself to input/output statements, variables, selection statements and loops. Using any other concept (like functions or arrays) will result in loss of points.
3. All input and output must be done with streams, using the library iostream
4. You may only use the cmath, iostream, and iomanip libraries (you do not need any others for these tasks)
5. NO C style printing is permitted. (Aka, dont use printf). Use cout if you need to print to the screen.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started