Question 1 (30%) Write your code in Q1() that first asks the user to enter a positive integer, then prints out messages

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Question 1 (30%) Write your code in Q1() that first asks the user to enter a positive integer, then prints out messages

Post by answerhappygod »

Question 1 30 Write Your Code In Q1 That First Asks The User To Enter A Positive Integer Then Prints Out Messages 1
Question 1 30 Write Your Code In Q1 That First Asks The User To Enter A Positive Integer Then Prints Out Messages 1 (215.57 KiB) Viewed 16 times
Please help do this question by using C++, all program codesmust inside "int main() {return 0;}". And only #include<iostream>, #include <iomanip> can be libraries fordoing this question. No other libraries are allowed. Moreover,please note that Array, Pointer are not allowed for doing thisquestion, And any symbol such as "scarf", "[]" are notallowed, only the repetition statements (do-while, while, forloops) and selection statements (if, if-else, switch etc) areallowed. Please also test all cases and make sure all of them canbe displayed correctly according to the instructions.
Again, please don't use Array, Pointer, OOP and other C++libraries except "#include <iostream>" and "#include<iomanip>" for doing this question! Thank you.
Question 1 (30%) Write your code in Q1() that first asks the user to enter a positive integer, then prints out messages depending on the digits of the integer. The messages should be printed in the following correct order. ● Number of digits in the integer. Odd Version (6th digit of your student ID is 1, 3, 5, 7 or 9) Sum of all odd position digits of the integer. Note that the unit digit is the first position, the tenth digit is the second position and so on. For example, if the input is 123456, then the sum is 6+4+2=12. Some of the testing scenarios are given below for your reference. You should test your code using these and other important test cases to ensure it follows the specified requirements above. Odd Version (odd 6th digit in student ID) Even Version (even 6th digit in student ID) Even Version (6th digit of your student ID is 0, 2, 4, 6 or 8) Sum of all even position digits of the integer. Note that the unit digit is the first position, the tenth digit is the second position and so on. For example, if the input is 123456, then the sum is 5+3+1=9. Sample display Input: 123456 6 12 Sample display Input: 13579 5 15 2 8 Sample display Input: 38 1 0 Sample display Input: 0 Sample display Input: 123456 6 9 Sample display Input: 13579 5 10 Sample display Input: 38 2 3 Sample display Input: 0 1 0
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply