Task: Write a program that reads in a user's name, ID #, gender, and major. Print that information back out, plus a grading sheet, in the following format:
Jeremy Gottlieb, 123456, M CS Homework 1 - Build/Compile: Style: Comments:
Purpose: The primary purpose of this lab is to get practice with reading information in from the keyboard and with using different data types for variables. A secondary goal is to have practice formatting output so that it looks nice.
#include <iostream> #include <string> using namespace std; int main() { /* Declare variables to store all the info */ string first, last, major; int ID; char gender; /* Read in the info from the user */ cout << "What is your name? "; cin >> first >> last; cout << "ID number: "; cin >> ID; cout << "Gender: "; cin >> gender; cout << "Major: "; cin >> major; /* Print out the grading sheet */ cout << first << " " << last << ", " << ID << ", " << gender << endl; cout << major << endl << endl; cout << "Homework 1 -" << endl; cout << " Build/Compile:" << endl; cout << " Style:" << endl; cout << " Comments:" << endl; }