Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C# Only. Create a console application that reads a sequence of integers (they can be positive, negative, or zero) from the input. Do not use

C# Only.

Create a console application that reads a sequence of integers (they can be positive, negative, or zero) from the input. Do not use built-in functions or arrays to implement the logic. Perform the following tasks in each iteration:

(1) The app will sum up sequential evens or sequential oddswhichever the sequence the input values are in. Code number%2==0 can be used to determine whether a number is even or not.In general, sequential evens are even numbers that are together, and vice versa.

(2) When the input changes from even to odd or from odd to even OR when the iteration has terminated with CTRL-Z as an input(when the ReadLine() method returns a null), the app will display the sum calculated in Task 1.

(3) The app will identify the largest sum of sequential odds as well as the largest sum of sequential evens.

(4) When the app reaches the end-of-line with CTRL-Z as an input(when the ReadLine() method returns a null), the app will terminate and display the positive difference between the largest sum of sequential odds and the largest sum of sequential evens, calculated in Task 3.

For example, the inputs 2, 4, 6, 8, 1, 3, 5, 7 have sequential evens of 2, 4, 6, 8 and sequential odds of 1, 3, 5, 7. When you enter a "1" here, the app will display "The sum is 20" because the input has been changed from even (8) to odd (1). In the end, the app will display "The sum is 16" and then "The positive difference between the largest sums is 4" because of 2+4+6+8 - (1+3+5+7).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions