A living room measures 24ft by 15ft. An adjacent square dinning room measures 13ft on each side. If carpet costs $6.98 per square foot,what is the total cost of putting carpet in both rooms?