Create an program that allows the user to input an age in years and then displays one of the following responses. You program should be able to figure out how many years to display in some of the responses.
My code is here below. What can I do to improve it?
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int main()
{
int userAge;
cout << "Please enter userAge " << endl;
if (0 < age && age < 6);
cout << "You are considered a young minor. In approximately" << 6 - userAge << "year(s) you will be able to attend school!"; endl;
else if (age < 16)
cout << "In approximately" << 16 - userAge << "years you will be able to drive!"; endl;
1
Expert's answer
2013-05-08T09:48:35-0400
#include <iostream> #include <fstream> #include <cmath> using namespace std;
int main() { & & cout << "Please enter userAge " << endl;
int userAge; cin>>userAge;
if (0 < userAge && userAge < 6) { cout << "You are considered a young minor. In approximately " << 6 - userAge << " year(s) you will be able to attend school!"<< endl; } else if (userAge < 16) { cout << "In approximately " << 16 - userAge << " year(s) you will be able to drive!"<< endl; } else { cout<<"You are able to drive!"<<endl; }
Comments
Leave a comment