c++ Division . seemingly simple thing driving me crazy, advice please
<p>Ok i've been programming for about a week now, i started with c++. I'm writing a program that is a kind of an arithmetic trainer, you enter the amount of equations you want, you enter your limit for the random number generator, you specify what kind of equations you want(/*-+), then the program uses a for loop and goes through and generates the equations and their answers in a var and then the users input is checked against this var and if they match another var which is counting the right answers is incremented. After the last equation the program tells the user how many they got right out of how many equations, and by dividing the amount of right answers by the amount of questions then multiplying this value by 100 u should obtain the accuracy percentage for this users arithmetic session. Problem is c++ keeps returning to me a friggin 0 value and i cannot for the life of me work out why in the world c++ is doing this.</p>

<p>entire program:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;ctime&gt;
#include &lt;cstdlib&gt;
using namespace std;
void menu(void);
class session{
public:
session(){
            create_session();
        }
        void create_session(void){
        amount = 0;
        range_limit = 0;
        rights = 0;
        answer = 0;
        input = 0;
        type = "";
        while(amount == 0){
            cout &lt;&lt; "\nHow many equations do you want?: "; cin &gt;&gt; amount;
            if(amount &lt; 1){
                cout &lt;&lt; "\nAmount is too low!";
                amount = 0;
            }
        }
        while(range_limit == 0){
            cout &lt;&lt; "Enter the number range limit: "; cin &gt;&gt; range_limit;
            if(range_limit &lt; 1){
                cout &lt;&lt; "\nRange limit too low!";
                range_limit = 0;
            }
        }
        while(type == ""){
            cout &lt;&lt; "What equation type do you want?: "; cin &gt;&gt; type;
            int strlen = type.size();
            if(strlen &lt; 1){
                cout &lt;&lt; "Invalid type input!";
                type = "";
            }
        }
        if(type == "+"){
            for(int i=0;i&lt;amount;i++){
                int a = random();
                int b = random();
                answer = a + b;
                cout &lt;&lt; "\n" &lt;&lt; a &lt;&lt; " + " &lt;&lt; b &lt;&lt; " = "; cin &gt;&gt; input;
                if(answer == input){
                    rights++;
                }
            }
        }
cout &lt;&lt; "\nYou got " &lt;&lt; rights &lt;&lt; " answers right out of " &lt;&lt; amount &lt;&lt;         " equations." &lt;&lt; endl;
        cout &lt;&lt; "Accuracy percentage: " &lt;&lt; getAccuracy() &lt;&lt; "%" &lt;&lt; endl;
        int post_menu=0;
        while(post_menu == 0){
            cout &lt;&lt; "Enter 1 to create another session or 2 to return to the menu: ";
            cin &gt;&gt; post_menu;
            if(post_menu == 1){
                create_session();
            }else if(post_menu == 2){
                menu();
            }else{
                cout &lt;&lt; "Invalid input: ";
                post_menu = 0;
            }
        }
    }
    float getAccuracy(){
           float x = (rights/amount)*100;
           return x;
    }
    int random(){
        int x = 1+(rand()%range_limit);
        return x;
    }
    void set_amount(int a){
        amount = a;
    }
    void set_range_limit(int r){
        range_limit = r;
    }
    void set_rights(int R){
        rights = R;
    }
    void set_answer(int a){
        answer = a;
    }
    void set_input(int i){
        input = i;
    }
    void set_type(string t){
        type = t;
    }
private:
    int amount;
    int accuracy;
    int range_limit;
    int rights;
    int answer;
    int input;
    string type;

};
int main(){
cout &lt;&lt; "=== WELCOME TO ARITH! === \n=========================\n";
menu();
return 0;
}

void menu(void){
//Set the seed for random number gen.
srand(time(0));

 //Set var for getting menu input, then get the menu input..
 int menu_input;
 cout &lt;&lt; "\n[1]Create a Session. [2]Exit Arith. \nWhat would you like to do?: ";
 cin &gt;&gt; menu_input;

 //Now we check what the user wants and act accordingly..
 if(menu_input &gt; 2){
    cout &lt;&lt; "error";
    menu_input=0;
 }else if(menu_input == 1){
     session start;
 }else if(menu_input == 2){
    cout &lt;&lt; "\nExiting Arith!";
 }else{
    cout &lt;&lt; "error";
    menu_input=0;
 }
}
</code></pre>

<p>Troublesome part:</p>

<pre><code>    float getAccuracy(){
           float x = (rights/amount)*100;
           return x;
</code></pre>

<p>some how the program is returning 0%.</p>

<p>anyone know why this is so and how to get the result im after.</p>
