C++ PROGRAMMING HELP?
-
My homework assignment is to convert minutes into hours and minutes. For example, 124 minutes = 2 hour(s) and 4 minute(s) (there will be some if statements for plurals of hours and minutes if possible) I am getting an error and would appreciate any help that you can give. I am still somewhat new to programming and would appreciate step by step details. Thank you in advance. Here is what i have so far: #include <iostream> using namespace std; int Convert(int); int remainder; int main () { int minutes; int convert_to_hours; int remainder; cout << "This program converts minutes to hours and minutes. " << endl; cout << "Please enter a number of minutes (an integer) to be converted:" << endl; cin >> minutes; convert_to_hours = Convert(minutes); if (convert_to_hours > 1) cout << minutes << " mintes equal to " << convert_to_hours << " hours "; else cout << minutes << " mintes equal to " << convert_to_hours << " hour "; if (remainder > 1) cout << "and " << remainder << "minutes." << endl; else cout << "and " << remainder << "minute." << endl; return 0; } int Convert(int minutes) { int convert_to_hours; convert_to_hours = minutes / 60; return convert_to_hours; } int Convert(int remainder) { int remainder; remainder = minutes % 60; return remainder; }
-
Answer:
You are trying too hard #include <iostream> using namespace std; int ConvertMin(int); int ConvertHour(int); int main (void) { int minutes; int convert_to_hours; int hours; cout << "This program converts minutes to hours and minutes. " << endl; cout << "Please enter a number of minutes (an integer) to be converted:" << endl; cin >> minutes; convert_to_hours=minutes/60; minutes=minutes%60; cout <<"\n"<< convert_to_hours << " hour and " << minutes << " minutes." << endl; return 0; } int ConvertMin(int x){ return x %60; } int ConvertHour(int x){ return x/60; }
skywalke... at Yahoo! Answers Visit the source
Other answers
You have two functions that are called Convert(). That will not work. Have like convertHrs() and convertMin()
Jared
Related Q & A:
- What are some basic c++ programming techniques?Best solution by Quora
- What certification can I get for C Programming?Best solution by Yahoo! Answers
- How hard is C++ programming?Best solution by Yahoo! Answers
- Computer Programming help?Best solution by Yahoo! Answers
- Is C a good language to start out learning programming?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.