Advertisement
J2112O

Practice

Mar 4th, 2015
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.65 KB | None | 0 0
  1.  #include <iostream>                                                                                          
  2.   2 using namespace std;                                                                                          
  3.   3 int main()                                                                                                    
  4.   4 {                                                                                                            
  5.   5     cout << "Enter the name of the person you want to write too (followed by 'enter'): " << flush;            
  6.   6     string first_name;            // first_name is a variable                                                
  7.   7     cin >> first_name;                                                                                        
  8.   8     cout << "Dear," << first_name << "!" << endl;                                                            
  9.   9     cout << "How are you doing? I am fine but I miss you terribly." << endl;                                  
  10.  10     cout << "I am fine these days just busy with work is all." << endl;                                      
  11.  11     cout << "Seems like I am doing good with my weight loss though." << endl;                                
  12.  12     cout << "I am eating healthy and exercising 5 days a week." << endl;                                      
  13.  13     cout << "What is your other friends name ? "<< flush;                                                    
  14.  14     string friend_name;                                                                                      
  15.  15     cin >> friend_name;                                                                                      
  16.  16     cout << "How is "  << friend_name << " doing these days? " << endl;                                      
  17.  17     cout << "Have you seen " << friend_name << " lately? " << endl;                                          
  18.  18     char(0); // still not sure if this helps or not yet. Confused on it a bit                                
  19.  19     cout << "Please tell me if your friend is male(m) or female(f) (followed by 'enter') ." << endl;          
  20.  20     string input;                                                                                            
  21.  21     string male = "m";                                                                                        
  22.  22     string female = "f";                                                                                      
  23.  23     cin >> input;                                                                                            
  24.  24     if(input == male)  // finally got this one figured out. Had to remove the ; same as below                
  25.  25     {                                                                                                        
  26.  26         cout << "If you see " << friend_name << " please ask him to call me. " << endl;                      
  27.  27     }                                                                                                        
  28.  28     if(input != male)  // had to swap the string names above to get it to accept m or f like book says to    
  29.  29     {                                                                                                        
  30.  30         cout << "If you see " << friend_name << " please ask her to call me. " << endl;                      
  31.  31     }                                                                                                        
  32.  32     return 0;                                                                                                
  33.  33 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement