User in put is in bold: Test 1 > run Enter integer: -5 Number must be positive. Enter integer: 0 Number must be positive. Enter integer: 1 Factors of all numbers up to l 1: 1
Test 5 > run Enter integer: 7 Factors of all numbers up to 7 1: 1 2: 1, 2 3: 1, 3 4: 1, 2, 4 5: 1, 5 6: 1, 2, 3, 6 7: 1, 7 Test 6 >
run Enter integer: 21
Factors of all numbers up to 21
1: 1
2: 1, 2
3: 1, 3
4: 1, 2, 4
5: 1, 5
6: 1, 2, 3, 6
7: 1, 7
8: 1, 2, 4, 8 9: 1, 3, 9 10: 1, 2, 5, 10 11: 1, 11 12: 1, 2, 3, 4, 6, 12 13: 1, 13 14: 1, 2, 7, 14 15: 1, 3, 5, 15 16: 1, 2, 4, 8, 16 17: 1, 17 18: 1, 2, 3, 6, 9, 18 19: 1, 19 20: 1, 2, 4, 5, 10, 20 21: 1, 3, 7, 21
Programming Assignment
Your solution will be graded based upon program behavior (passing tests). Your solution will not receive full credit (or receives no credit) if you fail to follow these restrictions:
- Your program must compile and run. Otherwise it will receive a zero.
- Add your solution to the provided code template.
- Do NOT use the do-while statement. Only use the while and for statements where appropriate.
- Use descriptive variable names. Avoid too short variable names, especially single letter variable names.
- DO NOT start a variable name with a capital letter.
- DO NOT use == true or == false in your boolean expressions (see lecture notes).
- DO NOT use explicit type casting. Instead use coercion (see lecture notes).
- DO NOT unnecessarily use parenthesis in an expression, e.g. an equation or formula. Parenthesis should only be used for grouping portions of an expression to change operator precedence order. For example, parenthesis are unnecessary in the expression (a + b + c). Instead use a + b + c. Parenthesis are necessary in the expression (a + b + c) / 3.
- DO NOT use the break and continue statements in your solution.
- Your program must be readable including indenting, spaces, and avoid lines that are too long. Use the the sample programs in the lecture notes as a guide.
- Comment your program. Read the document at the "Lecture" link on Carmen under Modules->Commenting Your Program-> Commenting your program. DO NOT comment every line.
- Only use C++ statements presented in the course. I.e. statements and notation presented in the lecture notes and assigned readings.
To receive full credit, only use C++ statements presented in the lecture notes and assigned readings. Your solution will be graded based on passing test cases, formatting, and good choice of variable names. Write your solution in the provided code template.
Important!: Write your code incrementally. This means implement your solution one portion at a time where you compile, run, and test the code portion before moving on to the next portion. Use the provided test cases to help you arrive at your final solution.
TASK 3: Write C++ code to prompt the user for a positive integer. Repeatedly re-prompt the user if the value entered is not a positive value. Compile, run, and test this solution before continuing to the next task.
TASK 4: Write C++ code to display factors (comma separated) for each integer from 1 to the value entered in TASK 3.
-
Be sure that there is a comment documenting each variable (see the document on Carmen under Modules on how to comment your code).
-
Do not start a variable name with a capital letter. Be sure that your code is properly indented, readable, and use good descriptive names.
-
Test your solution.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images