while loops beginner. creating a program but stuck on the concept.
이전 댓글 표시
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
Walter Roberson
2020년 4월 14일
endwhile is not part of MATLAB.
The Octave resources are somewhere else on the Internet.
Reila01
2020년 4월 14일
Walter Roberson
2020년 4월 14일
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.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Cepstral Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!