There is only one equation but there are two variables, so a unique solution is not possible without further constraints. But we can find x in terms of y and y in terms of x.
y=(240-18x)/21 and x=(240-21y)/18.
Both equations simplify:
y=(80-6x)/7 and x=(80-7y)/6.
We are dealing with money, so we might expect a solution involving exact amounts of money—no fractions of a cent. We can take this further and allow only whole dollars.
If we take the latter constraint, we limit the number of solutions. We can also assume that x,y>0–no negative amounts of money. Take the equation x=(80-7y)/6. If x>0, 80-7y>0, y<80/7, which means y≤$11.
But 80-7y must be divisible by 6. 80-7y=78+2-6y-y. Since 78 and 6 are both divisible by 6, we only need 2-y to be divisible by 6 (including negative values for 2-y). So y can be 8 which meets the requirement for 0<y≤11.
x=(80-56)/6=24/6=4. Therefore x=$4 and y=$8.
The same logic applies if x and y are numbers of priced objects, the price of one being $21 and the other $18. x and y have to be whole numbers so the solution would still be x=4 and y=8 meaning 4 objects at $18 each and 8 objects at $21 each. 4×18+8×21=72+168=$240.