How can I make this code more efficient?

I’m trying to make a system for my game where you can buy a car for a certain amount of money
This is my current code

		if (Input.GetKeyUp(KeyCode.B))
		{ -= Price;
			carChoosen = true;

			if (carSelected == 0)
				Car0Bought = true

			if (carSelected == 1)
				Car1Bought = true

			if (carSelected == 2)
				Car2Bought = true


Obviously this isn’t efficient and could cause major problems if I had 30+ Cars.
Is there any more efficient way of doing this
Thank You

I sujest to use arrays and loops.

Use an array, or a generic List. So instead of a lot of separate variables, use a carBought boolean array, where each entry is true or false.