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 &lt;&lt; &quot;What is your age? &quot;; cin &gt;&gt; age; cout &lt;&lt; &quot;What is your full name? &quot;; cin &gt;&gt; firstname &gt;&gt; lastname ; cout &lt;&lt; &quot;Okay, &quot; &lt;&lt; firstname &lt;&lt; &quot; &quot; &lt;&lt;lastname &lt;&lt; &quot;,&quot; &lt;&lt; endl; if (age &gt;= 18) {cout &lt;&lt; &quot;You can smoke cigarettes.&quot;&lt;&lt; endl;} if (age &gt;= 18 &amp;&amp; age &lt;= 30) {cout&lt;&lt; &quot;You can join the military.&quot;&lt;&lt;endl;} if (age &gt;= 21) {cout &lt;&lt; &quot;You can drink alcohol.&quot;&lt;&lt; endl;} if (age &gt;= 18) {cout &lt;&lt; &quot;You can vote.&quot;&lt;&lt; endl;} if (age &gt;= 62) {cout &lt;&lt; &quot;You can draw Social Security.&quot;&lt;&lt; endl;} { }...
View Full Document

Ask a homework question - tutors are online