Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in c++ that submits a value between 4-8 digits that follow the rules below. The value must be greater than 1000 and

Write a program in c++ that submits a value between 4-8 digits that follow the rules below.

The value must be greater than 1000 and less than 100,000,000 (to ensure that there are between four and eight digits and that the integer is positive).

The last digit in the number (in the 1s place) must be even. The second-to-last digit (in the 10s place) in the number must be odd. The third-to-last digit (in the 100s place) in the number must be even. The fourth-to-last digit (in the 1000s place) must be odd. This pattern should repeat until there are no more digits left.

The number representing the summation of the digits must be even.

two example integer codes that would be allowed are: 1234 and 21416. For 1234, the digits alternate in an even/odd pattern from the last digit (4 is even; 3 is odd; 2 is even; and 1 is odd) and the number representing the summation of the digits (1+2+3+4=10) is even. For 21416, the digits alternate in an even/odd pattern from the last digit (6 is even; 1 is odd; 4 is even; 1 is odd; 2 is even) and the number representing the summation of the digits (2+1+4+1+6=14) is even.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions