|
-
January 21st, 2009, 06:17 PM
#1
Newbie simple program problem...
Hello everyone,
I am having a simple problem and I was wondering if someone could help me. I am making a simple time calculator program for my class and I am stuck on one part. For some reason in this set of code, it keeps printing like "38228 minutes" no matter what the input for seconds is. This code is not complete.
// time calculator
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
using namespace std;
int main ()
{
string a;
string b;
cout << "Please type the form of time you will be using..." << "\n";
cin >> a;
if (a == "seconds")
{
int seconds;
int minutes = seconds /60;
int hours = minutes / 60;
int days = hours / 24;
int weeks = days / 7;
int months = days / 30;
int years = months / 12;
cout << "How many seconds are there?" << "\n";
cin >> seconds;
cout << "There are..." << "\n";
cout << seconds << " seconds" << "\n";
cout << minutes << " minutes" << "\n";
cout << hours << " hours" << "\n";
cout << days << " days" << "\n";
cout << months << " months" << "\n";
cout << years << " years" << "\n";
}
else
{
cout << "Incorrect form of time... Please enter a correct for of time (seconds, minutes, days, etc.)." << "\n";
}
system("PAUSE");
return 0;
}
Thank you ahead of time for any help...
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|