Hi guys! New to the forums here. I am working on a C++ project and have been stuck on two parts:
1. Can someone help me understand why my setprecision is not working? Regardless of what I set the precision to the code always displays the same results.
2. Formatting rows and columns... all the values are correct (with the exception of the setprecision part) but before I get into displaying the calculations which are currently shown I want to display the temperature vertically (before each row) from -5 to 50 in increments of 5 and the wind speed horizontally (top of each column) from 5 to 45 in increments of 5.
First I would suggest this: std::cout << std::fixed << std::showpoint << std::setprecision(2);. This line has to be done only once, so I would put it above the for loop. The "setprecision()" will stay the same until another "setprecision()" changes this or the program ends and is started over again.
Beyond that it should work even in the for loop.
Give me a few minutes to test your program and I will know more. This will take about ten minutes or so because my old laptop is slow these days.
Awesome. Thank you Handy Andy and JLBorges. This has been very helpful! It looks like the major issue was having the setprecision in the wrong area. And looking at JLBorges code, I see why the initial temperatures and wind speeds were not showing up.