Write a python program that computes the zakat, obligatory charity, on camels. The program asks the user to input the number of camels, and then the zakat is calculated based on the following table: Rule for computing the zakat of 121 camels or more: You need to find the combinations of 40 camels and 50 camels that will minimize the number of “left over” camels not being “counted” in the zakat. For example, for 130 camels, we have (2*40) + (1*50)=130, with no left overs, and hence, the zakat consists of 2 bint Laboun and 1 Hiqqah. When we have 145 camels, we have the following scenarios: 1. (140) + (250) = 140 with 5 camels left over, 2. (240) + (150) = 130 with 15 camels left over, 3. (340) + (050) = 120 with 25 camels left over. Therefore, in this case the zakat is 1 bint Laboun and 2 Hiqqah, following the first scenario. Important Notes: Make sure that the input value is a positive integer. If not, the program must print the following message: Wrong input. Number should be an integer greater than 0. and continue reading input from the user, until a valid positive integer is entered. You need to use functions to develop this code. Make sure that the functions are meaningful and break your program in a logical manner. Your main program shall run by calling function main. The main function shall only consist of calls to other functions, and the print statements of the results. Your main function will specify what your program does. The details of the how are in the implementation of these functions. Global variables are not allowed. You should pass parameters to functions and receive results from them. Sample Run 1 Enter the number of camels: 12.0 Wrong input. Number should be an integer greater than 0. Enter the number of camels: -5 Wrong input. Number should be an integer greater than 0. Enter the number of camels: five Wrong input. Number should be an integer greater than 0. Enter the number of camels: 12 For 12 camels, the zakat consists of 2 sheep Sample Run 2 Enter the number of camels: 3 For 3 camels, there is no Zakat Sample Run 3 Enter the number of camels: 17 For 17 camels, the zakat consists of 3 sheep Sample Run 4 Enter the number of camels: 30 For 30 camels, the zakat consists of 1 bint Makhadh Sample Run 5 Enter the number of camels: 40 For 40 camels, the zakat consists of 1 bint Laboun Sample Run 6 Enter the number of camels: 50 For 50 camels, the zakat consists of 1 Hiqqah Sample Run 7 Enter the number of camels: 71 For 71 camels, the zakat consists of 1 Jathaah Sample Run 8 Enter the number of camels: 90 For 90 camels, the zakat consists of 2 bint Laboun Sample Run 9 Enter the number of camels: 92 For 92 camels, the zakat consists of 2 Hiqqah Sample Run 10 Enter the number of camels: 131 For 131 camels, the zakat consists of 2 bint Laboun ; 1 Hiqqah Sample Run 11 Enter the number of camels: 152 For 152 camels, the zakat consists of 0 bint Laboun ; 3 Hiqqah Sample Run 12 Enter the number of camels: 122 For 122 camels, the zakat consists of 3 bint Laboun ; 0 Hiqqah
Write a python
Rule for computing the zakat of 121 camels or more:
You need to find the combinations of 40 camels and 50 camels that will minimize the number of “left over” camels not being “counted” in the zakat. For example, for 130 camels, we have (2*40) + (1*50)=130, with no left overs, and hence, the zakat consists of 2 bint Laboun and 1 Hiqqah. When we have 145 camels, we have the following scenarios: 1. (140) + (250) = 140 with 5 camels left over, 2. (240) + (150) = 130 with 15 camels left over, 3. (340) + (050) = 120 with 25 camels left over. Therefore, in this case the zakat is 1 bint Laboun and 2 Hiqqah, following the first scenario.
Important Notes:
- Make sure that the input value is a positive integer. If not, the program must print the following message: Wrong input. Number should be an integer greater than 0. and continue reading input from the user, until a valid positive integer is entered.
- You need to use functions to develop this code. Make sure that the functions are meaningful and break your program in a logical manner. Your main program shall run by calling function main.
- The main function shall only consist of calls to other functions, and the print statements of the results. Your main function will specify what your program does. The details of the how are in the implementation of these functions.
- Global variables are not allowed. You should pass parameters to functions and receive results from them.
Sample Run 1
Enter the number of camels: 12.0
Wrong input. Number should be an integer greater than 0.
Enter the number of camels: -5
Wrong input. Number should be an integer greater than 0.
Enter the number of camels: five
Wrong input. Number should be an integer greater than 0.
Enter the number of camels: 12
For 12 camels, the zakat consists of 2 sheep
Sample Run 2
Enter the number of camels: 3
For 3 camels, there is no Zakat
Sample Run 3
Enter the number of camels: 17
For 17 camels, the zakat consists of 3 sheep
Sample Run 4
Enter the number of camels: 30
For 30 camels, the zakat consists of 1 bint Makhadh
Sample Run 5
Enter the number of camels: 40
For 40 camels, the zakat consists of 1 bint Laboun
Sample Run 6
Enter the number of camels: 50
For 50 camels, the zakat consists of 1 Hiqqah
Sample Run 7
Enter the number of camels: 71
For 71 camels, the zakat consists of 1 Jathaah
Sample Run 8
Enter the number of camels: 90
For 90 camels, the zakat consists of 2 bint Laboun
Sample Run 9
Enter the number of camels: 92
For 92 camels, the zakat consists of 2 Hiqqah
Sample Run 10
Enter the number of camels: 131
For 131 camels, the zakat consists of 2 bint Laboun ; 1 Hiqqah
Sample Run 11
Enter the number of camels: 152
For 152 camels, the zakat consists of 0 bint Laboun ; 3 Hiqqah
Sample Run 12
Enter the number of camels: 122
For 122 camels, the zakat consists of 3 bint Laboun ; 0 Hiqqah
Step by step
Solved in 2 steps with 3 images