In the class 12 out of a possible 40 people voted for candidate A. There were in total only 30 voters (12 + 18). The percentage that voted for candidate A can be found with the following formula:

Filling in this formula learns us the following:

Hence, 40% of the voters voted for candidate A.