Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Problem 2 Digit Parity Write a program that uses a sentinel loop to input numbers

Problem 2 Digit Parity Write a program that uses a sentinel loop to input numbers

Computer Science

Problem 2 Digit Parity Write a program that uses a sentinel loop to input numbers. The loop should end when the input is the number 0. After each input the program must print whether the sum of all the digits of the number is an even or odd number. Implement a method called digits_sum that takes an integer number as argument and returns the sum of all its digits. The program must check the validity of the input, and ask again if the input was not a valid number. Before finishing, the program must state whether the sum of all the digits of all the numbers is odd or even. Here is a sample run: Submitting your assignment Your submission will consist of one zip file containing solutions to all problems (see below). This file will be submitted via a link provided on our Moodle page just below the assignment description. This file must be uploaded by 5pm (Moodle time) on the due date in order to be accepted. You 3 Enter a number (B to Quit) : 34 The sum of the digits is odd. Enter a number (B to Quit): 51 The sum of the digits is even. Enter a number (B to Quit) : number Not a valid number. Enter a number (6 to Quit) : 23 The sum of the digits is odd. Enter a number (6 to Quit) : @ The sum of the digits of all the numbers is even. Figure 2: Program output Example can submit your solution any number of times prior to the cutoff time (each upload overwrites the previous one). Therefore, you can (and should) practice uploading your solution and verifying that it has arrived correctly.

 

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE