Graduation cap, books and cash © Brand X Pictures, Photolibrary

The University of Michigan and University of Virginia are two of the best public universities in the country. Students living in those states can get a first-rate education at a bargain, but undergrads crossing state lines to attend should expect to fork over some cash.

Sticker price for nonresident students at Michigan topped $39,000 for the 2012-2013 school year, making it the most expensive public school for out-of-state students. Virginia came in a close second with tuition and fees of more than $38,000 for nonresident students, according to data reported to U.S. News in an annual survey.

The University of California-Davis, College of William and Mary, UC-Santa Barbara and UC-Los Angeles are also among the 10 priciest public schools for nonresidents. Each school also landed among the top 10 public schools in the 2013 Best Colleges rankings.

Out-of-state tuition and fees at these 10 schools averaged nearly $36,500 for 2012-2013, up about $1,000 from the previous year.

By comparison, nonresident tuition averaged roughly $19,100 nationwide, according to data reported by 331 ranked public colleges.

The University of California-Berkeley, UC-Irvine and UC-San Diego, which appeared on this list in 2011 and 2012, did not report 2012-2013 tuition and fees to U.S. News.

Prospective students don't seem to be deterred by the steep price tag. The number of nonresident applicants to the University of Michigan has exploded in recent years, according to local news site AnnArbor.com.

The influx of capital from out-of-state students can be good news for local applicants -- if they can secure admission, that is. Public schools often rely on tuition dollars from nonresident students, both domestic and international, to fill budget gaps and ease public pressure over in-state tuition rates.

The University of California school system bumped international undergraduate enrollment to roughly 13% last fall, up from a historical average of 3% to 5%, according to the East Bay Express in Oakland, Calif.

"This has been a big boost for the UC's coffers, as international students pay nearly three times as much in tuition as Californians," the paper reports.

Michigan's governing board recently approved a tuition hike of 3.2% for nonresident students, allowing the university to cap the increase for resident students at 1.1% -- the lowest increase in three decades, AnnArbor.com notes.

Below are the 10 most expensive public schools for out-of-state students. These figures do not include room and board, books, transportation or other costs. Schools designated by U.S. News as Unranked were excluded from this list. U.S. News did not calculate a numerical ranking for Unranked programs because the program did not meet certain criteria that U.S. News requires to be numerically ranked.

School name (state) Tuition and fees (2012-2013) U.S. News rank and category
University of Michigan—Ann Arbor $39,109 29, National Universities
University of Virginia $38,018 24, National Universities
University of California—Davis $36,755 38, National Universities
College of William and Mary (VA) $36,753 33, National Universities
University of California—Santa Barbara $36,549 41, National Universities
University of California—Santa Cruz $36,294 77, National Universities
University of California—Riverside $35,801 101, National Universities
University of Vermont $35,582 92, National Universities
University of California—Los Angeles $35,570 24, National Universities
Virginia Military Institute $33,811 70, National Liberal Arts Colleges

Don't see your school in the top 10? Access the U.S. News College Compass to find tuition data, complete rankings and much more. School officials can access historical data and rankings, including of peer institutions, via U.S. News Academic Insights.

Click here to become a fan of MSN Money on Facebook

More from U.S. News & World Report: