Final answer:
The problem with the code is that it does not calculate the percentages correctly for each subject and does not correctly calculate the total percentage. To fix this, you can take input from the user for the marks of each subject, calculate the percentage of each subject, add the percentages of all three subjects, and calculate the total percentage.
Step-by-step explanation:
The problem with the code is that it does not calculate the percentages correctly for each subject and does not correctly calculate the total percentage. To fix this, you can use the following steps:
- Take input from the user for the marks of each subject.
- Calculate the percentage of each subject by dividing the marks by the maximum marks for that subject and multiplying by 100.
- Add the percentages of all three subjects.
- Calculate the total percentage by dividing the sum of the percentages by 3.
For example, if the marks for subject 1 are 80 out of 100, subject 2 are 70 out of 100, and subject 3 are 90 out of 100, the percentage for each subject would be 80%, 70%, and 90% respectively. The total percentage would be (80+70+90)/3 = 80%.