Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

ATM C++ Keep getting wrong answer

$
0
0

I keep getting the wrong answer and I don't know why.

include <iostream>

using namespace std; int main(int argc, const char * argv[]) {

const float fee = 0.50;
unsigned int widthdrawl = 0.00;
float balance = 0.00;

cout << "Enter widthdrawl amount and bank balance ex[30 120]" << endl;
cout.precision(4);
cin >> widthdrawl;
cin >> balance;

while(balance > 0){
    if((widthdrawl + fee) > balance) {
        cout << balance << endl;
        cout << "Not enough money in account" << endl;
        break;
    }

    else if(widthdrawl % 5 != 0) {
        cout << balance << endl;
        cout << "Did not enter a multiple of 5" << endl;
        break;
    }

    else if((widthdrawl % 5 == 0)) {
        balance = balance - widthdrawl - fee;
        cout << balance << endl;
        break;
    }

}

return 0;

}

Blockquote


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>