Basic programming course: Lesson #6 Functions

in #devjr-s20w6last month
Hello Everyone
I'm AhsanSharif From Pakistan
Greetings you all, hope you all are well and enjoying a happy moment of life with steem. I'm also good Alhamdulillah.


image.png
Design On Canva

Tell us about your experience with programming, was it your first time? Did you find it complicated? What was your favorite part of the course?

I first started the program when I enrolled in university. Because I am a BSCS student, when I went there for the first time I welcomed programming. In the beginning, which were my semesters, I did not understand this programming at all as it was my first time. I had never studied computers or programming before. But when suddenly I had to do this study, it became very difficult for me. However I faced difficulties in two semesters, after that I stabilized myself and developed a bit of interest in programming, because of which we studied different languages each semester like Java, C, and C++. Then we interacted with Python.

So then we stabilized ourselves and learned programming. Which proved to be quite useful for us. And we got good marks in the exams but after I completed my degree some engagements happened that I didn't learn programming again. Which made it a bit late to review things, but as soon as I started taking part in the challenge, all my things got renewed. And I understood everything again, what was the work, how I used to do it. So I have re-learned a lot here in this course so we keep learning till the end of our life. This was also my learning phase which turned out to be very successful.

Any task that we start without learning, we face difficulties in the beginning. But as we develop our interest in that thing, we search, then it comes to our understanding and then we do it easily. This is how programming is, if you read it carefully, understand it, look at the techniques, search it, and look at other people's code, you will understand it more. And only then can you become a good programmer.

In any work, we have one or the other favorite thing in this work. Favorite means that we perform it with great passion and taste. For example, if we talk about web development, I like the CSS part in it, which I do with great passion. Because he designs our website when our website is designed it looks beautiful. She also interacts with the next users so that's why that part is my favorite. Similarly, programming is also my favorite part of this course.

My favorite part of this entire programming course is cycles, also known as normal loops. This is one of my favorite parts which I have enjoyed a lot. Through this, I have performed various programs and my knowledge has increased.

I like them the most because they make our work easier. We use loops where we need to write the code repeatedly. Loops shorten our code when we use them, we don't need to rewrite the code. And so makes our work automatic. And loops continue to execute our work until some of our conditions are approved.

That's their specialty and I love them because it makes our code easier to understand and easier to see.

I would like to make a recommendation to the Steemit team that next time this challenge comes up, you must approve it. So that we can learn more good things as we have learned in this challenge. As we have acquired the knowledge, there are many more things we need to learn in terms of programming. I hope that these heads of ours will teach us very well. Therefore, if they apply again in the next challenge, they must be approved so that we can learn the loop code in a good way again and become good programmers.

Add the functions to multiply and divide to the course calculator. Explain how you did it.

Here is the Input Code in C++:

image.png


image.png


image.png


image.png

What I Change And How?

Multiplication Function:

First of all, I have added Multiplication a function whose simple task is to multiply two numbers together and return the answer. If we multiply two by two, then the answer will be four, I have added such a function.

Division Function:

And then I added a division function whose main purpose is to divide two numbers. As in dividing E1 by E2. Here the function also takes care that e is not zero. Because when the value is zero, it will print an error. When it prints an error, the value of the function will automatically be zeroed.

Now I have updated the show menu option. Multiplication and division have been added to it at numbers three and four. So that they can be used with the rest of your operators.

I have added two new cases in the main algorithm called case three and case four and they will work with the rest of the operators. This update will fix all calculations in the calculator. In which you can do addition, subtraction, multiplication, and division.

Output With Video Explanation:

FINAL PROJECT: Create an ATM simulator. It must initially request an access pin to the user, this pin is 12345678. Once the pin is successfully validated, it must show a menu that allows: 1. view balance, 2. deposit money, 3. withdraw money, 4. exit. The cashier should not allow more balance to be withdrawn than is possessed. Use all the structures you learned and functions.

Here is the Input Code in C++:

image.png

image.png

image.png

image.png

Explanation:

The ATM will work in such a way that first, it will ask us for the PIN code, if the PIN code is wrong, it will not proceed further. If the PIN code is correct then our ATM main menu will open which will have four options. One option is to view balance, the second is to withdraw money, the third is to deposit money and the fourth is to exit the program.

In the first option, whatever our amount is, it will make the show. If there is no deposit, it will show zero. In another option it will deposit money from us eg I deposit 100 dollars. Then when I check the balance again, I will have $100 in my account.

When I withdraw money, I will take care to withdraw as much as is available. If there is 100 dollars I will double it and it won't withdraw it will say insufficient balance.

Then if you withdraw your amount as much as it is, easily will release the money to us. And will also tell us the remaining balance. The fourth option is exit, when we want to exit from our ATM, we have to use this option.

Output With Video Explanation:

Thanks for staying here. I would like to invite @kouba01, @malikusman1, and @abdullahw2 to join this challenge.

Cc:
@alejos7ven

Dated: 14-10-2024 About Me
Sort:  
Loading...

Upvoted! Thank you for supporting witness @jswit.

Thank you so much dear @malikusman1 for your kind support and love.

Coin Marketplace

STEEM 0.23
TRX 0.22
JST 0.036
BTC 98537.12
ETH 3353.21
USDT 1.00
SBD 3.15