if else statement problems?

I am new to programming. The problem I am having is at the part of withdrawal. When I input the amount to be the exact for example I have total of 2.45. When I inputted 2.45. The programs just wont do anything. It should said I took out cents according to my total. I dont understand whyy its not working. Any help would be appreciated. I'll just post parts of it.

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
else if (x == "W" || x == "w"){
			do{
				validinput = true;
				cout << " Please enter the amount (in RM) => ";
				cin >> amount;
				if (cin.fail()  || amount < 0) { 
                        cout << " ERROR: Invalid Coin Amount!"<< endl;
                        std::cin.clear();
                        std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
                        validinput = false;
                }
			}while(validinput == false);
			int tmp = amount*100;
			if(tmp%5 != 0 || amount > total){
				cout << " ERROR: Invalid Withdrawal Amount!";
				std::cin.clear();
                std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
			} else {
				while(amount > 0){
					if(fifty > 0 && amount >= 0.5){
						fifty -= 1;
						c50 += 1;
						amount -= 0.5;
					} else if (twenty > 0 && amount >= 0.2){
						twenty -= 1;
						c20 += 1;
						amount -= 0.2;
					} else if (ten > 0 && amount >= 0.1){
						ten -= 1;
						c10 += 1;
						amount -= 0.1;
					} else if (five > 0 && amount >= 0.05){
						five -= 1;
						c05 += 1;
						amount -= 0.05;
					}
				}
				cout << " Yes, Please collect your coins: "; 
				
					cout << "\n 50c x " << c50 << endl;
				
				
					cout << " 20c x " << c20 << endl;
				
					
					cout << " 10c x " << c10 << endl;
				
				 	
					cout << " 5c x " << c05 << endl;
				
				
			}
Sorry forgot my variables. Here are they

1
2
3
4
5
6
7
8
9
10
11
12
13
14
        string x, exit = "p";
	srand (time(NULL));
	int max = 10;
	int five = rand() % max;
	max -= five;
	int ten = rand() % max;
	max -= ten;
	int twenty = rand() % max;
	max -= twenty;
	int fifty = max;
	int j, a, k, q;
	double total = five*0.05 + ten*0.1 + twenty*0.2 + fifty*0.5, amount;
	double c05 = 0, c10 = 0, c20 = 0, c50 = 0;
	bool validinput = true;
Hi,

Please don't start a new topic about the same subject. Ultimately it's a time waster for those who reply: the same things will be said for both topics.

Could you quit this topic and carry on with the other one? Write a message here to that effect :+)

Cheers!
ohh sorry how do I delete this?
You can't, hence the idea of writing a message here, and providing a link to the other topic :+)
Topic archived. No new replies allowed.