Programming Assignment: P1

  1. Read the following sample program to find out the output if the user enters "John" for variable "customerName." Then run the program on computer and compare the output you found manually with the output from computer to make sure to understand the basic structures of C++ and how to input and output data into and from a program through console window.
    // Program Wrap writes out the contents of a sandwich wrap.
    #include <iostream>
    #include <string>
    using namespace std;
    
    int main()
    {
    	const string TUNA = "tuna";
    	const string PICKLE = "pickle";
    	const string LETTUCE = "lettuce";
    	const string WRAP = "tortilla";
    
    	string customerName;     //Just first name
    
    	string filling;
    	string wrap;
    	
    	cout << "Enter your first name:" << endl;
    	cin >> customerName;
    
    	filling = TUNA + " and " + PICKLE + " with " + LETTUCE;
    	wrap = filling + " in " + WRAP + '.';
    
    	cout << "Customer " << customerName << " wanted a sandwich wrap:" << endl;
    	cout  << "Filling : "  << filling  << endl;
    	cout  << "Wrap : " << wrap  << endl;
    
    	return 0;
    }
    
  2. Complete the following program to print out a greeting message as shown in the sample message.
    //Student: John Doe
    //Class: CSC1321-01
    //Programming Assignment: P1 (Printing)
    //Date: 8/22/2018
    
    //The program takes first and last names from the user and prints a greeting on the screen.
    
    #include 
    #include 
    using namespace std;
    
    int main ()
    {
      string greetingMessage;
      string firstName;
      string lastName;
      string fullName;
    
      //Ask the user to enter both first name and last name
      //and store into the two variables: firstName and lastName
      
      //...
    
      //Combine the first name and last name into a full name in form: "Last Name, First Name"
      //and store into variable fullName
      
      //...
      
      //Combine greeting "Good morning" with the full name and store into variable greetingMessage
      
      //...
      
      //Print out the greeting message in the format like the sample given below.
    
      //...
      
      return 0;
    }
    
    //Sample input:
    John Doe
    
    //Sample output:
    ***********************************************
       Good morning Doe, John.
    ***********************************************
    Press any key to continue . . .
    
  3. At the top section of your program you need to use C++ comments to include your name, class name, programming assignment name, and date the program was written. See the sample program.
  4. Your programs should be properly formatted using indentation and empty lines (spaces). Use "camel" notation for variable naming.
  5. Upon completion, save all programs and the required output into a single text file using notepad (or notepad++). The file should be named in this format: P1_YourName.txt, for example, P1_JohnDoe.txt. Then submit to the Blackboard (Bb) as attachment by the deadline. The submission link on the Bb will be closed automatically after the deadline. Assignments that fail to follow the instructions will NOT be graded.