HELP ME PLEASE

Write a program that requests the user to input their first and last name as well as their current age in years, age in months, weeks, days, hours, minutes, seconds and nano seconds where a nanoseconds = 1000000000 seconds.
Put all identifiers in integers except for string. Show constant as well.
Could anyone please help me out on this problem. Thank You very much. I really appreciate your help
I tried to work on this but i keep getting error when i compile.
Here is what I did:
And I really need help on this. Please help me out. Thanks a ton

//compiler directives

#include<iostream>
#include<string>

using namespace std;

//contant declarations
const int MONTHS in YEAR=12;
const int WEEKS in YEAR=52;
const int DAYS in YEAR=365;
const int HOURS in DAY=24;
const int MINUTES in HOUR=60;
const int SECONDS in MINUTE=60;
const int NANO=1000000000;

//main program

int main()
{
//local identifiers

string FirstName, LastName, FullName;
int Age, AgeInMonths, AgeInWeeks, AgeInDays, AgeInHours;
int AgeInMinutes, AgeInSeconds, AgeInNano;

//input module

cout<<"Please enter your first name:\t";
cin>>FirstName;
cout<<FirstName<<", please enter your last name:\t";
cin>>LastName;
cout<<" Please enter your current age:\t";
cin>>Age;

//processing module
FullName = FirstName +" "+ LastName;
//example of operator overloading
//+ is the concatenation operator

AgeInMonths = Age*MONTHS in YEAR;
AgeInWeeks = Age*WEEKS in YEAR;
AgeInDays = Age*DAYS in YEAR;
AgeInHours = AgeInDays*HOURS in DAY;
AgeInMinutes = AgeInHours*MINUTES in HOUR;
AgeInSeconds = AgeInMinutes*SECONDS in MINUTE;
AgeInNano = AgeInSeconds*NANO;

//output module

cout<<"Full Name:\t\t"<<FullName<<endl;
cout<<"Age in Year:\t\t"<<Age<<"\n";
cout<<"Age in Months:\t\t"<<AgeInMonths<<endl;
cout<<"Age in Days:\t\t"<<AgeInDays<<endl;
cout<<"Age in Hours:\t\t"<<AgeInHours<<endl;
cout<<"Age in Minutes:\t\t"<<AgeInMinutes<<endl;
cout<<"Age in Seconds:\t\t"<<AgeInSeconds<<endl;
cout<<"Age in Nanoseconds:\t"<<AgeInNano<<endl;

return/;
}
//end main program
Last edited on
closed account (jwkNwA7f)
I realize that you have solved the problem, but for next time, we can't do your homework for you. We can help you when you run into a problem, but you need to show effort.
Last edited on
retsgorf297.
Sorry about earlier. I was trying to put my work on that but couldn't get it done because of network problem. Thanks any ways
closed account (jwkNwA7f)
Variable names can't have spaces. You can use underscores(_).:
1
2
3
4
5
6
const int MONTHS in YEAR=12;
const int WEEKS in YEAR=52;
const int DAYS in YEAR=365;
const int HOURS in DAY=24;
const int MINUTES in HOUR=60;
const int SECONDS in MINUTE=60;

Here you put a slash:
return/;
It should be:
return;

EDIT:
Sorry about earlier. I was trying to put my work on that but couldn't get it done because of network problem. Thanks any ways

No problem. It looked like you just wanted us to do your homework for you. There has been from at least 5-10 people wanting us to do there homework for them with out giving any effort.
Last edited on
Thank a Lot. Have a lovely evening
what happens every 4 year? right, Olimpic games!
const int DAYS in YEAR=365; wrong
#define DAYS_in_YEAR(year) ((year%4==0)?366:365) try this. and then AgeInDays = Age*DAYS_in_YEAR(Age);

return/; to return 0;
Last edited on
Thank @Toshen
On nano I got my time as 630720000000000000 as an anser but its wrong. negative or positive values are wrong. Is there any ways to fix this error. I mean it doesn't shows the error but logically, its wrong so is there any change in programme that i can do to fix this error??
Anybody??
form Internet:

signed char: -127 to 127 (note, not -128 to 127; this accommodates 1's-complement platforms)
unsigned char: 0 to 255
"plain" char: -127 to 127 or 0 to 255 (depends on default char signedness)
signed short: -32767 to 32767
unsigned short: 0 to 65535
signed int: -32767 to 32767
unsigned int: 0 to 65535
signed long: -2147483647 to 2147483647
unsigned long: 0 to 4294967295
signed long long: -9223372036854775807 to 9223372036854775807
unsigned long long: 0 to 18446744073709551615


const int NANO=1000000000; max size for int is 32767
the same for AgeInNano
Last edited on
Where do I put all those @Toshen.
I am not trying to make you work on my assignment but i don't understand where to put all those in my program???
Would you be more clear and really appreciate your help in making me understand the concepts of programming. Thanks again
That is not a code, just information about variable types.

const int NANO=1000000000; max size for int is 32767

NANO is an integer thats why max digit what you can keep in it is 32767. But you try to keep 1000000000 in it. This is mistake.

In that information you can find correct type.

Dont forget about check other variables.
Toshen wrote:
form Internet

Not true for everyone.

See http://www.cplusplus.com/reference/limits/numeric_limits/
Use the example program on your system to see what the actual limits are on your system.
Thank you very much Toshen.
It really helped me understand :)
Have a wonderful night.
Topic archived. No new replies allowed.