To clarify one matter: it is unknown whether Starfleet makes any distinction between cadets and midshipmen.
In English, cadet is a generic word for a person enrolled as an officer trainee in a national armed forces service academy. And it is also used more broadly.
Starfleet seems to be based on the mid-20th US Navy that was more or less familiar to the creators of TOS who supported it with their taxes and in some cases served in it. Midshipman is the official term for cadets at the US Naval Academy. A midshipman is simultaneously a cadet and a midshipman, whether in a classroom at Annapolis or on a summer cruise on a ship. An Annapolis cadet is not a midshipman only when on a summer cruise on a naval vessel, an Annapolis cadet is a midshipman all the time.
It is logical to assume that Starfleet is more or less like the contemporary US Navy except where there is evidence suggesting otherwise.
So what is said about cadets and midshipmen in TOS and the TOS movies? The following quotes are from the search function at Star Trek Transcripts site.
At the end of "The Cage" Pike says:
What are we running here, a cadet ship, Number One? Are we ready or not?
In "The Menagerie" they talk about Pike's injury:
MCCOY: What's his problem, Commodore?
MENDEZ: Inspection tour of a cadet vessel. Old Class J starship. One of the baffle plates ruptured.
MCCOY: The delta rays?
MENDEZ: He went in bringing out all those kids that were still alive. Just wanted you gentlemen to be prepared.
KIRK: Yes. He was an instructor at the Academy when I was a midshipman, but that didn't stand in the way of our beginning a close friendship. His daughter Jamie, who was here last night, was named after me.
"The Ultimate Computer":
SPOCK: Dunsel, Doctor, is a term used by midshipmen at Starfleet Academy. It refers to a part which serves no useful purpose.
[now in "Kirk's quarters"]
"Whom Gods Destroy":
KIRK: When I was a cadet at the Academy, his exploits were required reading. He was one of my heroes. I'd like to see him.
KIRK: I agree there was a time when war was necessary, and you were our greatest warrior. I studied your victory at Axanar when I was a cadet. In fact it's still required reading at the Academy.
GARTH: As well it should be.
KIRK: Very well. But my first visit to Axanar was as a new fledged cadet on a peace mission.
Star tek II: The Wrath of Khan:
SPOCK: Trainees ...to the briefing room.
KIRK: Aren't you dead? I assume you are loitering here to learn what efficiency rating I plan to give your cadets.
SPOCK: Welcome, Admiral. I think you know my trainee crew. Certainly they have come to know you.
RESTON: Midshipman First Class Peter Preston, engineers mate, sir!
KIRK: First training voyage, Mister Preston?
PRESTON: Yes sir!
KIRK: Well, Mister Scott, are your cadets capable of handling a minor training cruise?
KIRK (OC): I told Starfleet all we had was a boatload of children but ...we're the only ship in the Quadrant. Spock, these cadets of yours, how good are they? How will they respond under real pressure?
SCOTT: He stayed at his post ...when the trainees ran.
MCCOY: Lieutenant, you are looking at the only Starfleet cadet who ever beat the no-win scenario.
Star Trek III: The Search For Spock
...Most of our trainee crew has been reassigned...
SCOTT: As promised, she's all yours, sir. All systems automated and ready. A chimpanzee and two trainees could run her.
Star Trek IV: The Voyage Home:
KIRK: They're still using money. We've got to find some. Spock! The rest of you stay here. ...The rest of you break up. You look like a cadet review.
Star Trek V: The Final Frontier:
KIRK: General Korrd's military strategies were required learning when I was a cadet at the Academy. When they put me out to pasture, I hope I fare better than Korrd.
They seem to use both midshipman and cadet when talking about Starfleet Academy students, and the only time what seems like an official rank is given it is Peter Preston's Midshipman First Class. Kirk describes himself as being a cadet, not a midshipman, on a voyage to Axanar.