The Cavern of the Metal Cap is in Hazy Maze Cave. Go to the Underground Lake, and ride Dorrie (the large sea creature) over to the platform in the corner with the double doors. When you get there, ground pound while on Dorrie to make him lower his head and hop up onto the platform so you can enter the double doors into the Metal Cavern. The Metal Cap course is in the pool inside. It's a long level with a strong water current. Don't get sucked in to the water; you'll end up in the waterfall outside Peach's castle into the moat.
Finding the Switch
At the start of the level you'll be encased in metal, so the water current will have no effect on you. Throughout this level are Sniffits that fire bullets at you when they see you. Stomp on them to get some coins. When you reach the flowing water in the cavern, make a left, not a right. There is a 1-Up Mushroom in the block by the waterfall, though. Hop from the small platforms in the current to the platform with the green Metal Cap Switch. Hop onto it and all of the green blocks will become solid. Now you can use the Metal Cap. Any time you use it, you become Metal Mario, invincible and unaffected by water in any way. You can even walk underwater without breathing!
4 coins are found around the platform at the end. Two are found on the platform, and two are found close to the Bob-omb buddy.
The first two red coins are in an alcove with a 1-Up Mushroom right before the platform with the Metal Cap Switch. The next two are beside the Metal Cap Switch. To get the last four red coins, break open a green block and grab the Metal Cap from it. Now as Metal Mario, hop into the water nearby the Metal Cap Switch platform to find the last four coins. Then, the star will appear right by the platform as well. Grab it before the Metal Cap wears off and you'll have another one of the castle's secret stars!
Please Note: If the water current pushes you out of the level, you will end up outside Peach's Castle where the waterfall is. If you get the star, you will end up outside the entrance to Hazy Maze Cave.