Notice that you need color(red)(2)2 moles of ammonia to react with color(blue)(7)7 moles of oxygen gas in order to produce color(green)(4)4 moles of nitrogen dioxide and 6 moles of water.
For the compounds involved in your reaction, you will always have the same ratios between the number of moles of each that react.
So, if you have 5.64 moles of oxygen that react, you'd need
For the third scenario, you were given mass, not moles. To go from mass to moles, use ammonia's molar mass, which represents the mass of 1 mole of the substance