I have done a program for my beginner C++ class. When I rebuild the solution, I don't get any errors, and when I start without debugging, the program runs perfectly. The problem is, when I look at the output file, there are a few things missing, and I don't know how to fix it.
I have a very strong urge to go full sarcasm mode here but I'll retain myself.
We can't read your mind or hack your computer, open your program and see what's wrong. Post your code, using code tags - http://www.cplusplus.com/articles/jEywvCM9/ And tell us what you think the problem might be. It would also help to post a bit of your output file as it is now, and how it should actually look like.
ha, yesss i was waiting for responses like this. This is my first time using this site and didn't know how much code to post. here is what I get when I run the program:
************************************************************************************************************************
Dwayne Johnson
CST 113 - Exercise 6
************************************************************************************************************************
Enter the name of input file to process
Select from these three files:
1. Ex6-1.txt
2. Ex6-2.txt
3. Ex6-3.txt
************************************************************************************************************************
Enter the input file choice: 1
The file Ex6-1.txt was successfully opened
************************************************************************************************************************
************************************************************************************************************************
Task 1 - Grocery Total and Points Awarded
The total groceries spent for the month are: 501.24
The total points awarded are: 140
************************************************************************************************************************
************************************************************************************************************************
Task 2 - C++ Academy Standing
Student's name: Karen Connolly
Total credits completed: 299
Standing of the student: Professional
Advisor's name: Mrs. Cooley
************************************************************************************************************************
************************************************************************************************************************
Task 3 - Tire Pressure
The psi of your tire is: 42
Your tire pressure is in the: Too High range
Decrease your pressure by: 7
************************************************************************************************************************
************************************************************************************************************************
Task 4 - High School Counselor Grouping
Name of the student: Fitzgerald, Kelsie
Group number assigned: 2
************************************************************************************************************************
Press any key to continue . . .
this is what the output file gives me:
************************************************************************************************************************
Task 1 - Grocery Total and Points Awarded
The total groceries spent for the month are: 501.24
************************************************************************************************************************
Task 2 - C++ Academy Standing
Student's name: Karen Connolly
Total credits completed: 299
Standing of the student: Professional
Advisor's name: Mrs. Cooley
************************************************************************************************************************
************************************************************************************************************************
Task 3 - Tire Pressure
Decrease your pressure by: 7
************************************************************************************************************************
This is my first time using this site and didn't know how much code to post.
You still haven't posted any code. How do you expect us to help you solve your problem if you are not even showing us the code which contains the problem? Please post your code.
Ok, I'm guessing you want your output file to contain the same information as cout? If so, you should probably write everything you write to cout to your output file stream as well.
As an example, we'll take part 4:
Your logic is perfectly fine, for as far as I can see. The problem arises when we come near the end:
1 2 3 4 5
//Output Name of Student heading to the screen
cout << "Name of the student: " << fullName << endl;
//Output Group Number heading to the screen
cout << "Group number assigned: " << groupNum << endl;
Here you write your information to cout, but you never write to the output file stream. You should probably change this into:
1 2 3 4 5 6 7 8 9
//Output Name of Student heading to the screen
cout << "Name of the student: " << fullName << endl;
//Output Name of Student heading to the file
outfile << "Name of the student: " << fullName << endl;
//Output Group Number heading to the screen
cout << "Group number assigned: " << groupNum << endl;
//Output Group Number heading to the file
outfile << "Group number assigned: " << groupNum << endl;
This way you write it to both cout and your file stream, making sure everything ends up in both. You'll have to do this for every time you use cout, otherwise you won't write the information to your file.
that worked perfectly! thank you. Now the only problem I have, is getting the name and course number to go to the output file. when I try to use the outfile for that, too, it doesn't go over.
I'm looking at my last program that also has an output file, and I don't see anything that I'm missing in the code... yet the name show up in the output file.