Wow. It never even occurred to me to put in widths like that, since quilting fabric is almost always 45" wide, sometimes 60" wide - certainly not 1" wide. Of course, now I'm going "D'oh!"
The math is inelegant, but that's a basic fact of calculating fabric yardages for quilts. Simple math, but annoying.
I like the module idea. Of course, I have no idea how to go about such a thing, but learning is really the whole point.
Price estimation is simple:
print "No, you may not buy more fabric. \n";