//program calculates military time to standard time
#include <iostream>
//function declarations
double input(int& hour, int& minute);
//function to gather the military time
double calculation(int hour_calc, int minute_calc, char& merid);
//function to calculate the military time
void output(int hour_out, int minute_out);
//function to output the results
void initialize();
//function to initialize the screen
//main program
int main()
{
char loop;
using namespace std;
do
{
int hours, minutes;
char meridi;
[COLOR="red"]double input(hours, minutes);
double calculation(hours, minutes, meridi);
double output(hours, minutes);[/COLOR]
}while (loop == 'Y' || loop == 'y');
cout << "Good bye";
void initialize();
return 0;
}
//function initializes screen
void initialize()
{
using namespace std;
cout << endl;
return;
}
//function gathers nessasary input from user
double input(int& hour, int& minute)
{
using namespace std;
cout << "Please enter the military time, the two first digits: ";
cin >> hour;
cout << "Please enter the last two digits of the military time: ";
cin >> minute;
}
//function calculates the data gathered from input and monitors weather its AM or PM with "char merid"
double calculation(int hour_calc, int minute_calc, char& merid)
{
using namespace std;
[COLOR="red"]char daytime = (char)merid;[/COLOR]
if(hour_calc > 11)
{
hour_calc = hour_calc - 12;
[COLOR="red"]daytime = "PM"[/COLOR];
}
else
{
[COLOR="red"]daytime = "AM";[/COLOR]
}
}
//function outputs results of the calculation
void output(int hour_out, int minute_out)
{
using namespace std;
cout << "Your time in standard is: " << hour_out << ":" << minute_out << endl;
}
I had quiet a few more errors but I have limited it to five:||In function 'int main()':| [COLOR="red"]|25|error: initializer expression list treated as compound expression| |26|error: initializer expression list treated as compound expression| |27|error: initializer expression list treated as compound expression[/COLOR]| ||In function 'double calculation(int, int, char&)':| [COLOR="red"]|66|error: invalid conversion from 'const char*' to 'char'| |71|error: invalid conversion from 'const char*' to 'char'|[/COLOR] ||=== Build finished: 5 errors, 0 warnings ===|
I never made merid a constant, and I tried to use (char) to change it from a constant to a variable with no luck. And I am not sure what "initializer expression list treated as a compound expression" means.


Sign In
Create Account


Back to top









