vendredi 28 mai 2021

Use "Else If" program that takes 3 integers x, y, z (3 kinds of goods) from the employee [closed]

You are a supermarket manager, aiming to place goods to the right place which are coded by number (odd and even number).

Write a program that takes 3 integers x, y, z (3 kinds of goods) from the employee and checks If x is even or odd.

  • If x is an even number, check whether y is greater than or equal to 20. If y >= 20, print "y to the A place", print "y to B place" otherwise.

  • If x is an odd number, check whether z is greater than or equal to 30. If z >= 30, print "z to the C place ", print "z to D place" otherwise

Example:

For x = 20, y = 33, z = 15, the output should be " y to the A place ".

Because x % 2 = 0 and y > 20

For x = 15, y =23, z = 20, the output should be " z to the D place ".

Because x % 2 != 0 and z < 30

Aucun commentaire:

Enregistrer un commentaire