Hi, I am having troubles figuring out how to get the leading white space out of my output file.
Below is the line in a .txt file I am supposed to get
328 23.5 1/4 pound hamburger
This is my code for inputting it onto another .txt file
1 2 3
outFile<<setw(25)<<left<<"\n\nFood"<<setw(18)<<"Total Calories"<<setw(22)<<"Calories From Fat"<<"Percent of Fat"<<endl;
outFile<<endl;
outFile<<foodName<<calories<<fatgram*9<<fatgram*9/calories;
And this is the output... I want to line the 1/4 pound hamburger with the Food
Food Total Calories Calories From Fat Percent of Fat
1/4 pound hamburger328211.50.644817
Its from an assignment. I want to get the 1 right underneath the F in food but everything I try dosent work.
this is the assignment.....
That file food.txt contains information about six different foods. For each food it has the number of calories in the food, the number of grams of fat, and the name of the food. The information about each food is on a single line with spaces between the values.
Write a program that reads the information from a file named food.txt and computes the number of calories from fat and the percent of calories that come from fat for each food.
Print a report to the file fatReport.txt that includes the following:
name of the food
total calories
number of calories that come from fat
There are 9 calories in each gram of fat
percent of fat in the food
percentage of fat = calories from fat / total calories
Use iomanip commands to make this report professional. Label each column. Foods with 30% or less fat are considered low fat foods. In the report, put an * by the name of each food that meets the requirements for a low fat food. At the bottom of the report put a note explaining the *