Help With Final Output

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Sep 2008
Posts: 29
Reputation: hurbano is an unknown quantity at this point 
Solved Threads: 0
hurbano hurbano is offline Offline
Light Poster

Help With Final Output

 
0
  #1
Apr 11th, 2009
i have my program doing what i want it to do untill it gets close to the end. the ouput that is transferred to the word document is not right. i have random charactes appearing before the "Date:". how can i fix this minor problem??
Thanks

  1.  
  2. #include <iostream>
  3. #include <string>
  4. #include <fstream>
  5. using namespace std;
  6.  
  7.  
  8. int main()
  9.  
  10. {
  11. ofstream outputFile;
  12. outputFile.open("C:\\Users\\Owner\\Desktop\\DoctorsOutPut.doc");
  13.  
  14. string Pname, CEmployer, AWUTDspecification, AMPM, RLhand,
  15. AllergiesSpecification, HPI, SSN, TDate, DOB,DOI, IBP, MOFI,Complaints;
  16. int age, n, y;
  17. char AWUTD, Allergies;
  18.  
  19. n=0;
  20. y=0;
  21. AWUTD=0;
  22.  
  23.  
  24. cout<<"Patients Name:"<<endl;
  25. getline (cin, Pname);
  26. cin.ignore(1000,'\n');
  27. cout<<'\n';
  28.  
  29. cout<<"What is todays date?"<<endl;
  30. getline (cin, TDate);
  31. cout<<'\n';
  32.  
  33.  
  34. cout<<"Age:"<<endl;
  35. cin>>age;
  36. cin.ignore(1000,'\n');
  37. cout<<'\n';
  38.  
  39.  
  40. cout<<"When is the patients birthday?"<<endl;
  41. getline (cin, DOB);
  42. cout<<'\n';
  43.  
  44.  
  45. cout<<"Patients Social Security Number: "<<endl;
  46. getline (cin, SSN);
  47. cout<<'\n';
  48.  
  49.  
  50.  
  51. cout<<"What was the date of the injury?"<<endl;
  52. getline (cin, DOI);
  53.  
  54.  
  55. cout<<"Was appointment AM or PM"<<endl;
  56. getline (cin, AMPM);
  57. cout<<'\n';
  58.  
  59.  
  60. cout<<"Employer:"<<endl;
  61. getline (cin, CEmployer);
  62. cout<<'\n';
  63.  
  64. cout<<"Right or Left Handed?"<<endl;
  65. getline (cin, RLhand);
  66. cout<<'\n';
  67.  
  68.  
  69. cout<<"Does the patient have any allergies? Y/N"<<endl;
  70. cin>>Allergies;
  71. cin.ignore(1000,'\n');
  72. cout<<'\n';
  73.  
  74. if(Allergies=='y'||Allergies=='Y')
  75. {
  76. cout<<"What is patient allergic to:"<<endl;
  77. getline (cin, AllergiesSpecification);
  78. cin.ignore(1000,'\n');
  79.  
  80. }
  81. else if (Allergies=='n'||Allergies=='N')
  82. {
  83. cout<<endl;
  84.  
  85. }
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93. cout<<"Patients HPI:"<<endl;
  94. getline (cin, HPI);
  95. cout<<'\n';
  96. cin.ignore(1000,'\n');
  97.  
  98.  
  99. cout<<"What are the injured body parts?"<<endl;
  100. getline (cin, IBP);
  101.  
  102. cout<<"What is the mechanism of injury?"<<endl;
  103. getline (cin, MOFI);
  104.  
  105. cout<<"Any complaints?"<<endl;
  106. getline (cin, Complaints);
  107. cin.ignore(1000, '\n');
  108.  
  109.  
  110.  
  111. cout<<"Any work up to date? Y/N"<<endl;
  112. cin>>AWUTD;
  113.  
  114.  
  115. if(AWUTD=='y'||AWUTD=='Y')
  116. {
  117. cout<<"Please Specify:"<<endl;
  118. getline (cin, AWUTDspecification);
  119.  
  120. }
  121. else if (AWUTD=='n'||AWUTD=='N')
  122. {
  123. cout<<endl;
  124. }
  125.  
  126.  
  127.  
  128.  
  129. cout<<'\n';
  130. cout<<'\n';
  131. cout<<'\n';
  132.  
  133.  
  134.  
  135. cout<<"Name: "<<Pname<<" "<<"Date: "<<TDate<<endl;
  136. outputFile<<"Name: "<<Pname<<" "<<outputFile<<"Date:"<<TDate<<endl;
  137.  
  138.  
  139.  
  140. cout<<"Age: "<<age<<" "<<"D.O.B: "<<DOB<<" "<<"SSN: "<<SSN<<endl;
  141. outputFile<<"Age: "<<age<<" "<<outputFile<<"D.O.B:"<<DOB<<" "<<outputFile<<"SSN: "<<SSN<<endl;
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148. cout<<"DOI: "<<DOI<<endl;
  149. outputFile<<"DOI: "<<DOI<<endl;
  150.  
  151.  
  152. cout<<"Appointment: "<<AMPM<<endl;
  153. outputFile<<"Appointment: "<<AMPM<<endl;
  154.  
  155.  
  156. cout<<"Employer: "<<CEmployer<<endl;
  157. outputFile<<"Employer: "<<CEmployer<<endl;
  158.  
  159.  
  160.  
  161. cout<<"Right or Left handed: "<<RLhand<<"handed"<<endl;
  162. outputFile<<"Right or Left handed: "<< RLhand<<"handed"<<endl;
  163.  
  164.  
  165.  
  166. cout<<"Allergies: "<<Allergies<<endl;
  167. if
  168. (Allergies=='y' || Allergies=='Y')
  169. {
  170. cout<<"Patient is allergic to:"<<AllergiesSpecification<<endl;
  171.  
  172. }
  173. else if (Allergies =='n' || Allergies=='N')
  174. {
  175. cout<<endl;
  176. }
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183. cout<<"HPI: "<<HPI<<endl;
  184. outputFile<<"HPI: "<<HPI<<endl;
  185.  
  186. cout<<"Injured body parts: "<<IBP<<endl;
  187. outputFile<<"Injured body parts: "<<IBP<<endl;
  188.  
  189. cout<<"Mechanism of injury:"<<MOFI<<endl;
  190. outputFile<<"Mechanism of injury:"<<MOFI<<endl;
  191.  
  192. cout<<"Complaints: "<<Complaints<<endl;
  193. outputFile<<"Complaints: "<<Complaints<<endl;
  194.  
  195. cout<<"Any work up to date?"<<AWUTD<<endl;//if statement to show correct output
  196. if
  197. (AWUTD=='y' || AWUTD=='Y')
  198. {
  199. cout<<"Work up to date includes:"<<AWUTDspecification<<endl;
  200. }
  201. else if (AWUTD =='n' || AWUTD=='N')
  202. {
  203. cout<<endl;
  204. }
  205.  
  206. outputFile.close();
  207. };
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 90
Reputation: unbeatable0 is an unknown quantity at this point 
Solved Threads: 12
unbeatable0 unbeatable0 is offline Offline
Junior Poster in Training

Re: Help With Final Output

 
0
  #2
Apr 11th, 2009
  1. outputFile<<"Name: "<<Pname<<" "<<outputFile<<"Date:"<<TDate<<endl;
You output what outputFile returns. This line should be
  1. outputFile<<"Name: "<<Pname<<" "<<"Date:"<<TDate<<endl;
Last edited by unbeatable0; Apr 11th, 2009 at 1:51 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 1,968
Reputation: tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute tux4life has a reputation beyond repute 
Solved Threads: 214
tux4life's Avatar
tux4life tux4life is offline Offline
Posting Virtuoso

Re: Help With Final Output

 
0
  #3
Apr 11th, 2009
Actually this:
  1. outputFile<<"Name: "<<Pname<<" "<<"Date:"<<TDate<<endl;


is the same as this:
  1. outputFile<<"Name: "<<Pname<<"\t\t"<<"Date:"<<TDate<<endl;
Last edited by tux4life; Apr 11th, 2009 at 2:04 pm.
"Never argue with idiots, they just drag you down to their level and then beat you with experience."
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 29
Reputation: hurbano is an unknown quantity at this point 
Solved Threads: 0
hurbano hurbano is offline Offline
Light Poster

Re: Help With Final Output

 
0
  #4
Apr 11th, 2009
ah thats true because the \t is a "tab" right
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 320
Reputation: cikara21 is an unknown quantity at this point 
Solved Threads: 63
cikara21's Avatar
cikara21 cikara21 is offline Offline
Posting Whiz

Re: Help With Final Output

 
0
  #5
Apr 11th, 2009
Hello..:p..Thats rite..
Last edited by cikara21; Apr 11th, 2009 at 2:25 pm.
.:-cikara21-:.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 29
Reputation: hurbano is an unknown quantity at this point 
Solved Threads: 0
hurbano hurbano is offline Offline
Light Poster

Re: Help With Final Output

 
0
  #6
Apr 11th, 2009
can you modify the font coming out to the word document throught the program?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC