Practical-No: 3
Write programs to demonstrate use of: if statements (all forms of if statement
Switch – Case statement Different types of Loops(for,while and do..while)
5. Develop a program to use logical operators in do-while loop.
import [Link];
class Dowhlogi {
public static void main(String args[]) {
Scanner scanner = new Scanner([Link]);
int num;
do {
[Link]("Enter a number between 1 and 10: ");
num = [Link]();
if (num < 1 || num > 10) {
[Link]("Number is out of range! Please try again.");
} else {
[Link]("You entered a valid number: " + num);
} while (num < 1 || num > 10);
[Link]("Program ended successfully.");
[Link]();
Output:\