Need Help (Noob)

Thank you for your help!! I finally got it.
Last edited on
OKay okay im on it, im gonna sit down and read this, just gonna make some tea...

K cin >> someInteger...and then it goes in you switch statement, switch statements are just like multiple else if statements, the internet will tell you that, true story.

Your program is fine for this stage, actually I would be happy with it if i was a noob.
Last edited on
My version but probably this is not the best way to help
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include <iostream>
#include <cmath>

using namespace std;

void print_menu()
{
    cout<<"\n\t\t         M E  N  U    "   <<endl;

    cout<<"\t\t 1 - Calculate Square Root " <<endl;
    cout<<"\t\t 2 - Calculate Cube " <<endl;
    cout<<"\t\t 3 - Calculate Natural Logarithm "<<endl;
    cout<<"\t\t 4 - Calculate Inverse "<<endl;
    cout<<"\t\t 5 - Calculate Absolute Value )"<<endl;
    cout<<"\t\t 0 - Exit Program "<<endl;
    cout<<"\t\t _______________________________________ "<<endl;
    cout<<"\t\t     Enter Menu Option =  ";
}

void Sroot();
void cube();
void Natlog();
void inverse();
void abvalue();

int main()
{
    bool done{false};

    while(!done)
    {
        //printing menu
        print_menu();

        int menuOptions;
        cin >> menuOptions;

        switch(menuOptions){
            case 0:
                cout <<"Good bye"<<endl;
                done = true;
                break;
            case 1:
                Sroot();
                break;
            case 2:
                cube();
                break;
            case 3:
                Natlog();
                break;
            case 4:
                inverse();
                break;
            case 5:
                abvalue();
                break;
        }
     }
    
    return 0;
}

void Sroot()
{
    cout << "\nEnter a decimal number : ";

    double num;
    cin >> num;

    if(num < 0)
    {
        cout << "Negtive number entered!\n";
        return;
    }
    else
        cout << "sqrt(" << num << ") = "
             << sqrt(num) << endl;
}

void cube(){
    cout << "\nEnter a decimal number : ";

    double num;
    cin >> num;

    cout << "pow(" << num << ", 2) = "
             << pow(num,2) << endl; //same as num * num
}

void Natlog()
{
    cout << "\nEnter a decimal number : ";

    double num;
    cin >> num;

    if(num <= 0)
    {
        cout << "Can't calculate natural log from negative num or 0!\n";
    }
    else
        cout << "log(" << num << ") = "
             << log(num) << endl;
}

void inverse()
{
    cout << "\nEnter a decimal number : ";

    double num;
    cin >> num;

    if(num == 0) cout << "Can't calculate inverse from 0!\n";

    cout << "pow(" << num << ", -1) = "
             << pow(num,-1) << endl; //same as num^(-1)
}
void abvalue()
{
    cout << "\nEnter a decimal number : ";

    double num;
    cin >> num;

    cout << "abs(" << num << ") = "
             << abs(num) << endl;
}
Last edited on
WoW! That is exactly what i needed. I will go thorough and look at what i did wrong. I cannot thank you enough. You saved my life. I really appreciate you for spending your time to look at my stupid codes and reply back. Thank you once again.
Last edited on
Topic archived. No new replies allowed.