assignment13 - int main string firstname,middlename...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/* Write a program which asks the user his or her age, then asks for his or her name. Based on the age entered, display the appropriate messages as shown in the table below: Age Message >= 18 You can smoke cigarettes. >= 18 and <= 30 You can join the military. >= 21 You can drink alcohol. >= 18 You can vote. >= 62 You can draw Social Security. Here is a sample run of the program (Green text is user input): What is your age? 40 What is your full name? Steven Shaffer Okay, Steven Shaffer, You can smoke cigarettes. You can drink alcohol. You can vote. */ #include<iostream> #include<string> using namespace std;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: int main () { string firstname,middlename, lastname; int age; cout << "What is your age? "; cin >> age; cout << "What is your full name? "; cin >> firstname >> lastname ; cout << "Okay, " << firstname << " " <<lastname << "," << endl; if (age >= 18) {cout << "You can smoke cigarettes."<< endl;} if (age >= 18 && age <= 30) {cout<< "You can join the military."<<endl;} if (age >= 21) {cout << "You can drink alcohol."<< endl;} if (age >= 18) {cout << "You can vote."<< endl;} if (age >= 62) {cout << "You can draw Social Security."<< endl;} { }...
View Full Document

This note was uploaded on 01/11/2010 for the course CMPSC 101 taught by Professor Drobish,renee during the Summer '07 term at Penn State.

Ask a homework question - tutors are online