AI says.....
According to AutoZone, replacing an engine can cost between $3,000 and $8,000 or more when a mechanic does the work. Doing it yourself may also cost at least $2,000, even if you use the most economical options.
You can also buy used engines and engine parts for the Genesis G90 on eBay. For example, a pre-owned 2017–2019 Genesis G90 AWD 5.0L V8 engine motor with 63,000 miles is listed for $7,124.99 plus $450 shipping
I thought that was low. Especially for a luxury car, but I kept clicking around. Those numbers are correct.
A search on a replacement for a Mercedes engine of similar build is about $12,000
Bottom Line. Never buy European.
The newer cars have more problems.
Some brands have replaced a lot of more durable meta parts under the hood with plastic parts, that do not last, or get damaged when you are trying to get to other parts.
Further, cars may develop problems not because the engine, transmission, or alternator (an actual working part) fails, but because a sensor fails, and the newer the car, the more sensors they have, that can fail.
Engines locally available for $2-4K. Some quite low mileage.
https://car-part.com/cgi-bin/search.cgi