Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are given a string variable with a series of intenger digits. Each digit is

ID: 3570050 • Letter: Y

Question

You are given a string variable with a series of intenger digits. Each digit is one position long, meaning you only consider the digits 0 thru 9, so"11" is not eleven but two single digits of one and one. Write a program in pseudo code to display a count of the number of 'even' digits, and count of the number of 'odd' digits. Also provide a sum of the 'even' digits and a sum of the 'odd' digits.

Example input

19623598233256

Example output

The number of even numbers in the string is XXX

The number of odd numbers in the string is XXX

The sum of the even numbers in the string is XXX

The sum of the odd numbers in the string is XXX

Can I Get assistance to check the psudo code for the problem above,

Main ()

   Declare String str

    Declare Intenger Counter

    Declare Intenger EvenNumbersCount

    Declare Intenger OddNumbersCount

    Declare Intenger SumOfEvenNumbers

    Declare Intenger SumOfOddNumbers

    // Getting the minimum and maximum

   Set Intenger sum =   IntengerSum()

   For Counter = 1 To Length (str)

        Set EvenNumbersCount = Counter+1

         //

       ELSE

        Set OddOfNumbers = Counter +1

     End If

     Display

Explanation / Answer

#include <stdio.h>
int main()
{
int n,even=0,odd=0,evencount=0,oddcount=0;
printf("Enter an integer: ");
scanf("%d", &n);
while(n!=0)
{
n/=10;   
if(n%2==0){
even=even+n;
evencount++;
}
else
{
odd=odd+n;
oddcount++;
} /* n=n/10 */
  
}
printf("Number of even digits: %d",evencount);
printf("Number of odd digits: %d",oddcount);
printf("Sum of even digits: %d",even);
printf("Sum of odd digits: %d",odd);
}

in java

import java.lang.Math;
public class Test{
public static void main(String args[]){
   int num = 123456789;
   while(num != 0) {
   int rightDigit = num % 10;
   if(rightDigit % 2 == 0)
       countEven++;
   else
       countOdd++;
   num /= 10;
}

   System.out.println("There are: " + countEven + " even and " + countOdd + " odd!");
}

}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote