Cantaloupe/muskmelons:In addition to the above responses, the blossom end should have a little give to it. It should give under fairly firm pressure and then spring back. Hard means it was picked unripe - and cantaloupes don't ripen after picking. If it gives to gentle pressure or doesn't spring back, it's probably going bad.
One other thing with cantaloupe, if it's torn up around the stem end, it was picked green - before it was ready to slip from the vine. It may have nice color, but probably won't be as sweet as it should be. Unfortunately, I have a hard time finding cantaloupe in stores that were picked at full-slip. Good thing my kids aren't
too picky about cantaloupe or they wouldn't eat any 8 months out of the year.
But since I don't pick cantaloupes until they are fully ripe, the kids think my homegrown cantaloupes are amazing.
Watermelon:The yellow ground spot test everybody mentioned is important! Here are three more tests for watermelon:
1. If you are picking it yourself, the tendril nearest the watermelon should be completely dry. Unfortunately, this is no help if you aren't the one picking it.
2. The skin will turn from glossy to dull. Some watermelons also have a subtle color change, usually if they do, they will become paler or develop a yellowish cast. But many watermelons do not change color.
3. The skin will feel pebbly or lumpy, not smooth.
So, find a watermelon with a dry tendril (if you're picking it), dull skin, and a yellow ground spot. Then stroke your fingertips along the fruit. It should feel pebbly or lumpy. If it's perfectly smooth, the melon may be underripe.
Here are two pictures I took several years ago with a small Yellow Moon & Stars watermelon I grew.
Ground spot color:
Pebbly/lumpy skin:
You can see the irregularity in the play of light on the surface, especially at the upper left of the image. You can usually see the irregularities if you look for them, and you should definitely be able to feel them. You just want it a
little lumpy - not sunken anywhere.
And you can see the dull skin in both pictures. Unfortunately I don't have a good comparison shot to show the shinier skin on a large but unripe melon.
I've been known to tap watermelons, too, but I am not all that good at judging the sound. So far, every watermelon I have picked or bought that passed both the yellow ground spot and lumpy skin tests has been ripe.