while loops beginner. creating a program but stuck on the concept.
Show older comments
im new to while loops and programming in general and im supposed to create a program where the user will enter their starting balance and they can choose to deposit or withdraw a certain amount of money. With every transaction the program will display their new balance. I will also have to write the program so that if their balance is 0 they will see a message saying they dont have money and if its less than 0 to display they have no money and their overdraft. this is the program i have written so far but im still having a little bit of difficulty understanding the concept behind while loops. so when i run my program the while part doesnt run at all and im not sure if the rest of the program is right either.
balance = input('Enter your starting balance: ');
withdraw = input('withdraw amount: ');
deposit = input('deposit amount: ');
while balance < 0
balance = balance - withdraw
fprintf('You have an outstanding balance of %.2f dollars.', balance);
endwhile
disp('end');
3 Comments
Walter Roberson
on 14 Apr 2020
endwhile is not part of MATLAB.
The Octave resources are somewhere else on the Internet.
Reila01
on 14 Apr 2020
Walter Roberson
on 14 Apr 2020
Octave is an Open Source software package from the Free Software Foundation. MATLAB is a commercial product from Mathworks. The purpose of the Free Software Foundation is to transform society to make it effectively impossible for commercial software products to exist, with software companies transformed from "owning" software into becoming service organizations that people hire to modify software (and release the modified software to the public).
Octave aims to be able to run MATLAB code specifically to destroy Mathworks as a software-owning company.
I used to know someone who insisted that their group spend several years writing code in non-proprietary languages, in order to avoid paying even $10 for a commercial software license. It was the principle with them: to them, it was better that their software be years later and do less, rather than pay a nominal license fee for software usage rights to a company that had spent tens of millions of dollars developing software.
Accepted Answer
More Answers (0)
Categories
Find more on Octave in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!