I fixed the whole program. :twisted: . I compiled it after each step to make sure there were no errors, if so I corrected them. :mrgreen: . I do, however, have 2 questions. :?: .
How do I get the highlighted lines below to center above the **************** :?: And why won't the program give me the total seconds after I entered the formula :?:
#include <string>
#include <iostream>
#include <conio.h>
#include <cstdlib>
using namespace std;
int main(){
string Time;
string Hours;
string Mins; // declare indentifiers and strings
string Secs;
int Pos;
int Pos1;
int HH;
int MM;
int SS;
int Product1;
int Product2;
int TotalSeconds;
cout << " " << endl;
cout << "Enter the number of hours: ";
cin >> Hours;
cout << " " << endl;
cout << "Enter the number of minutes: "; // Prompt the user
cin >> Mins;
cout << " " << endl;
cout << "Enter the number of seconds: ";
cin >> Secs;
//display time in H:M:S
cout << " " << endl;
cout << Hours << ":" << Mins << ":" << Secs; cout << " " << endl;
cout << "*******************************";
cout << " " << endl;
// string the given time
Pos = Time.find(":",0);
Hours = Time.substr(0,Pos);
Pos1 = Time.find(":",Pos+1);
Mins = Time.substr(Pos+1,Pos1 - Pos+1);
Secs = Time.substr(Pos1+1,Time.size() - Pos1+1);
// Change time to numbers
HH = atoi(Hours.c_str());
MM = atoi(Mins.c_str());
SS = atoi(Secs.c_str());
// Formulate time into seconds
Product1 = HH * 60;
Product2 = (MM * 60) + Product1;
TotalSeconds = Product2 + SS;
cout << " " << endl;
cout << "There are " << TotalSeconds <<
" total seconds in the given time.";
getch(); // Wrap-up and exit
return (0);
}