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 33 times
please help me do this question by using C++ programme language, only "#include <iostream>" can be used as a library for doing this question. Don't use other libraries with corresponding procedures such as <string>, <iomanip>, <cmath>, <studio.h> and so on. Please also make sure that all program codes are inside "int main() {return 0;}", don't use other return functions such as return 1, return sum and so on! Please also note that Repetition Statement (do-while, while, for loops) and Selection Statement (if, if-else, switch) are allowed in this question ONIY. Finally, please make sure that you answer this question according to the question's instruction and no error (And only the even cases are needed to test!!).
The instructions are clear, don't send me a reply about the instructions and/or information is not enough/not clear. I just need your answer. 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