0

I know I am missing a big part of this program but for some reason my mind is not working at all tonight.

I need to:

Write a program that asks the user to enter the duration of a baseball game
by first asking for the number of hours and then asking for the number of minutes. The program should display the total number of minutes that the game lasted.

//prb01-1.cpp
//This program calculates the total number of minutes in a baseball game



#include <iostream.h>
#include <iomanip.h>


//using namespace std:


int main()
{
const int innings per baseball game;
int hours,     //#of hours
minutes,   //# of minutes


//obtain the input data
cout<<"\nEnter the number of hours of the game:";
cin>> hours;
cout<<"\nEnter the number of minutes:";
cin>> minutes;


//Do the calculations
hours = hours;
minutes = hours / 60;


//Display the results
cout<<"\n hours"
cout<<"\n"


return 0;
}

Edited by happygeek: fixed formatting

2
Contributors
1
Reply
2
Views
12 Years
Discussion Span
Last Post by jasweb2002
0

Just a handful of errors.

First it probably was not compiling because of this area

int hours,     //#of hours
minutes,   //# of minutes

should be

int hours, minutes;

Also this area has logic problems..

//Do the calculations
hours = hours;
minutes = hours / 60;


//Display the results
cout<<"\n hours"
cout<<"\n"

..make it look like this...

//Do the calculations
minutes += hours * 60;


//Display the results
cout<< minutes << endl;

That will work fine.

Edited by happygeek: fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.