Tom Swift's father has been working diligently on a secret project, which he reveals at the beginning of the book as a submarine. With the submarine, named the Advance, he plans to enter a contest for a government prize of $50,000. While in New Jersey to launch the submarine, Tom reads in a newspaper that a ship named the Boldero sank off the coast of Uruguay during a storm, taking down with it the sum of $300,000 in gold bullion.
Tom persuades his father to pursue this treasure as opposed to competing for the government prize. While picking up a hired sea captain, Tom's plans are overheard by a contestant in the government contest, and a rivalry for the treasure begins. The other submarine, named the Wonder, soon sets off to follow Tom and his crew after they embark on their journey.
Tom's crew consists of Tom Swift, his father, Mr. Sharp, Captain West, and Mr. Damon. Each of these take chores on board, including Mr. Damon, who seems to be the cook of the voyage.
The submarines hold up at an island to resupply, and during the night, the Advance tries to slip away from the Wonder. Tom knows that the Wonder and its crew is not certain of the location of the wreck, and is merely following the Advance, hoping to steal the treasure at the last moment.
After the Wonder tries to ram the Advance, Tom and his father take to the heavy underwater cannons, and successfully disable the Wonder, leaving her damaged and immobile. Tom and the Advance seize the opportunity to push ahead.
An engine mishap forces the Advance to surface off the coast of Brazil, where they are soon confronted by the Brazilian battleship São Paulo. Tom and his crew are captured and scheduled to be executed two days later, and the submarine turned over to the Brazilian government. Tom and his friends are held prisoners aboard the battleship.
The night before their execution, a hurricane strikes, and the São Paulo is pushed aground by the winds. The crew take this opportunity to break out and escape, while the battleship's crew are busy trying to save the ship. Using cover from the ship, which is acting as a shield from the waves and winds, Tom's group take to a lifeboat, and escape to the Advance, diving just in time to escape the Brazilian crew of the São Paulo.
It is not long before the Advance arrives at the wreck. They struggle to find it at first, but soon are successful. In their extreme-depth diving suits, Tom and Captain West enter the waters where the wreck is, which is at a depth of over 2 miles—similar to the RMS Titanic. Sharks attack but are fought off.
Gold was found in a secret compartment behind the Captain's safe, and recovered from the Boldero just in time to escape from the now-arriving Wonder. With the $300,000 in gold as a deposit at Tom's local bank in Shopton, the bank considers Tom one of their biggest investors, and with this new power, Tom manages to bring his chum, Ned Newton, a promotion.

Question: What does the Brazilian government decide to do with Tom and his friends?
Answer: Execute them
Alternative answer: Execute them and take the submarine.