Can't figure out how to write to tell someone who is a certain age what their next decade would be in a certain amount of years. ie. say is someone was 23, how would i write that in 7 years they would be in their 3 decade?
// HowOld.cpp : main project file.
#include "stdafx.h"
#include <iostream>
using namespace std;
int main(array<System::String ^> ^args)
{
// Have the user enter their age
cout << "Please enter your age and prepare to have your mind blown! ";
int age;
cin >> age;
// Tell them how old they will be in a year
int nextYear = age +1;
// Report to the user how many decades old they are Done with the entered age
int decadesAge = age /10;
// Report to the user how many more years until they reach the next decade
// Display results
cout << "In a year you will be " << nextYear << " WOW! YOU'RE OLD!\n"
"Right now you are in decade " << decadesAge << " of you life.\n";
#include "stdafx.h"
#include <iostream>
usingnamespace std;
int main(array<System::String ^> ^args)
{
// Have the user enter their age
cout << "Please enter your age and prepare to have your mind blown! ";
int age;
cin >> age;
// Tell them how old they will be in a year
int nextYear = age +1;
// Report to the user how many decades old they are Done with the entered age
int decadesAge = age /10;
// Report to the user how many more years until they reach the next decade
// Display results
cout << "In a year you will be " << nextYear << " WOW! YOU'RE OLD!\n""Right now you are in decade " << decadesAge << " of you life.\n";
return 0;
}
Now the problems I see are:
* Delete line 1. You don't need #include "stdafx.h" . That is a C header file and you are writing in C++
* Rewrite your main function to look like this int main() and delete array<System::String ^> ^args
*On line 16 you should probably declare decadesage as a float type then divide by 10.0. Adding the .0 to a number tells the compiler to treat the number as a float then you should be able to figure out how to use the decimal places to figure out how many years remain until a person is another decade older.
*on line 23 you need to include a << in front of the "Right now you are in decade"