(Solved):Two variables, x and y, supposedly hold strings of digits. Write code that converts these to integers and assigns a variable z the sum of these two integers. Make sure that if either x and y has ba… View Answer…

 

Question

Two variables, x and y, supposedly hold strings of digits. Write code that converts these to integers and assigns a variable z the sum of these two integers. Make sure that if either x and y has bad data (that is, not a string of digits), z will be assigned the value of -1.

 

EXPERT ANSWER

We create a function named xandy() that asks the user for 2 numbers. Even though we

Scroll to top