Can some one help me?

Here is my new code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int ms (int minutes)
{
    int sec;
    sec = (minutes * 60);
    return sec;
}

int shutdn ()
{
    unsigned int sec;
    string c;
    unsigned int minutes;
    cout<< "Give then number of minutes until shutdown:  "<< endl; cin>> minutes;
    sec = ms (minutes);
    cout<< "Seconds until Shutdown: "<< sec<< endl;
    cout<< "Press enter to continue: ";
    cin.get();
    cin.get();
    return 0;
}

int mh (float min, float hour)
{
    min = (min / 60);
    hour = (hour + min);
    return hour;
}

int diftim ()
{
    //declares all of the variables used in this function
    unsigned int hours;
    unsigned int minutes;
    unsigned int h;
    unsigned int m;
    float tot1;
    float tot2;
    float tot3;
    string ap;
    string ap2;
    unsigned int h2;
    unsigned int m2;
    //gets input from the user
    cout<< "Hour: "<< endl;
    cin>> h;
    cout<< "Minute: "<< endl;
    cin>> m;
    cout<< "AM/PM?"<< endl;
    cin>> ap;
    cout<< "Second hour:  "<< endl;
    cin>> h2;
    cout<< "Second minute:  "<< endl;
    cin>> m2;
    cout<< "AM/PM?"<< endl;
    cin>> ap2;
    if (ap == "pm")
    {
        h = (h + 12);
    }
    if (ap2 == "pm")
    {
        h2 = (h2 + 12);
    }
    tot1 = mh (m, h);
    tot2 = mh (m2, h2);
    tot3 = (tot1 - tot2);
    hours = int(tot3);
    minutes = (60 * (tot3 - int(tot3)));
    cout<< hours<< " hours and "<< minutes<< " minutes."<< endl;
    cout<< "press enter to continue...";
    cin.get ();
    cin.get ();
    return 0;
}

int main ()
{
    unsigned int x;x = 0;
    while (x == 0)
    {
        cout<< "                    MENU"<< endl;
        cout<< ""<< endl;
        cout<< " 1- Delayed Shutdown"<< endl;
        cout<< " 2- Find the difference between two times"<< endl;
        cout<< "_____________________________________________________________"<< endl;
        unsigned int strt;
        cin>> strt;
        //this gets and analyzes input from the user
        if (strt == 1)
        {
            int shutdn ();
            x = 0;
        }
        if (strt == 2)
        {
            int diftim ();
            x = 0;
        }
    }
}



look at this thread for further information: http://www.cplusplus.com/forum/general/53166/#msg287863
Last edited on
... why didn't you just post in that other thread?
I got the menu to work, but i dont know whats wrong with the math...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int ms (int minutes)
{
    int sec;
    sec = (minutes * 60);
    return sec;
}

int shutdn ()
{
    unsigned int sec;
    string c;
    unsigned int minutes;
    cout<< "Give then number of minutes until shutdown:  "<< endl; cin>> minutes;
    sec = ms (minutes);
    cout<< "Seconds until Shutdown: "<< sec<< endl;
    cout<< "Press enter to continue: ";
    cin.get();
    cin.get();
    return 0;
}

int diftim ()
{
    //declares all of the variables used in this function
    unsigned int hourss, h, h2, m, m2, minutess;
    float tot1;
    string ap, ap2;
    float min, min2, ho, ho2;
    //gets input from the user
    cout<< "Hour: "<< endl;
    cin>> h;
    cout<< "Minute: "<< endl;
    cin>> m;
    cout<< "AM/PM?"<< endl;
    cin>> ap;
    cout<< "Second hour:  "<< endl;
    cin>> h2;
    cout<< "Second minute:  "<< endl;
    cin>> m2;
    cout<< "AM/PM?"<< endl;
    cin>> ap2;
    if (ap == "pm")
    {
        h = (h + 12);
    }
    if (ap2 == "pm")
    {
        h2 = (h2 + 12);
    }
    min = (m / 60);
    min2 = (m2 / 60);
    ho = (min + h);
    ho2 = (min2 + h2);
    tot1 = (ho - ho2);
    hourss = ((int) tot1);
    minutess = ((tot1 - ((int) tot1)) * 60);
    cout<< hourss<< " hours and "<< minutess<< " minutes."<< endl;
    cout<< ""<< endl;
    cout<< min<< endl;
    cout<< min2<< endl;
    cout<< ho<< endl;
    cout<< ho2<< endl;
    cout<< tot1<< endl;
    cout<< "press enter to continue...";
    cin.get ();
    cin.get ();
    return 0;
}

int main ()
{
    unsigned int x, strt;
    x = 0;
    do
    {
        cout<< "                    MENU"<< endl;
        cout<< ""<< endl;
        cout<< " 1- Delayed Shutdown"<< endl;
        cout<< " 2- Find the difference between two times"<< endl;
        cout<< " 3- Quit"<< endl;
        cout<< "_____________________________________________________________"<< endl;
        cin>> strt;
        //this gets and analyzes input from the user
        if (strt == 1)
        {
            shutdn ();
        }
        if (strt == 2)
        {
            diftim ();
        }
        if (strt == 3)
        {
            return 0;
        }
    }
    while (x == 0);
}
hey guys, no sweat! I got this ALL BY MYSELF... :(

seriously though, i did. Now i need help opening a baqtch file to write to it... Can someone show me the proper syntax to write it as? Im not wuite sure how to use it. I also need to run the batch file..
Last edited on
...
Topic archived. No new replies allowed.