Write your question here.
I am making a program that that determines if someone has exceeded their credit limit. I have made a loop but when i execute i am in an infinite loop. Im looking in my book and can't find anything that looks similar to what i'm doing please help.
Welcome to the forums! Please remember to use code-tags when posting:) You aren't changing the variables (newBalance and creditLimit) inside your loops, so of course they will never exit. Make sure you understand how while-loops work, from reading this code I'm guessing that you actually want to use if-statements rather than while-loops.
thanks for that tip! Now im trying to think of what to change my variables to so that they won't loop but if i did something like newbalnce++ wouldnt it loop and display "Credit limit exeeded" like 1000 times?
The program should use a while loop to read the input, calculate the new balances, determine
whether the new balance exceeds the credit limit, display a message “Credit Limit Exceeded” in
case the limit is exceed or “There is an available balance” otherwise.
First you declare all the variables, like you've already done. Then get all the input from the user which will only be entered once. Then you enter a while-loop which checks if newBalance is less than creditLimit (like your second while-loop). In that loop you get input from the user about new credits and charges and calculate the new balance. After the loop you print the message saying that the credit limit has been exceeded :)