When to Use do-while or while or for Loop ? do-while Loop Example in JAVA | Class#35

Опубликовано: 22 Ноябрь 2022
на канале: AKH Coding Class
59
3

B-Tech Student Next 3 Months Journey Blueprint | Must Watch and Understand:
   • B-Tech Student to Software Developer | You...  

Download your Java Programming Finisher Blueprint Document - Free ONLY for Limited Periods Only:
https://docs.google.com/spreadsheets/...


Details:
There are 3 types of loops in java,
1. for
2. while
3. do while

When to use for loop ?
If you know the exact count of iteration in advance then use for loop.

When to use while loop ?
If you don't know the exact count of iteration in advance then use for while loop.

When to use do while loop ?
If you don't know the exact count of iteration in advance and also you need that your loop body should execute at least once without checking your condition true or false value, then use for do while loop.

Assignment:
Create a Program to Print the total bill of a resturent, ordered by customer.
1. Give a Print Message for Base line Thali = Rs. 100
2. To add extra items Print the following statement,
Enter 1 if you need Egg. Cost Rs. 50
Enter 2 if you need Chicken. Cost Rs. 100
Enter 3 if you need Mutton. Cost Rs. 150
Enter 4 if you need Water Bottle. Cost Rs. 20
Enter 5 if your Order Complete and want to check the Total Amount.

Note: Use do while and switch statement.


На этой странице сайта вы можете посмотреть видео онлайн When to Use do-while or while or for Loop ? do-while Loop Example in JAVA | Class#35 длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь AKH Coding Class 22 Ноябрь 2022, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 59 раз и оно понравилось 3 зрителям. Приятного просмотра!