DO WHILE PROGRAM || PRINT SYNTAX
import java.util.Scanner;
class JAVASyntax
{
public static void main (String[] args)
{
Scanner sc=new Scanner(System.in);
char choice;
do{
System.out.println("1. Syntax of 'simple if' ");
System.out.println("2. Syntax of 'if else if' ");
System.out.println("3. Syntax of 'do while' ");
System.out.println("Enter your choice ");
choice=sc.next().charAt(0);
}while(choice <'1'||choice>'3');
switch (choice)
{
case '1':
System.out.println("if(condition){ ");
System.out.println("System.out.println(Ststement)");
System.out.println("}");
break;
case '2':
System.out.println("if(condition){ ");
System.out.println("System.out.println(Ststement)");
System.out.println("}");
System.out.println("else {");
System.out.println("Statement }");
break;
case '3':
System.out.println("do{ ");
System.out.println("System.out.println(Statement)");
System.out.println("}");
System.out.println("while(condition)");
break;
case '4':
System.exit(0);
break;
default:
System.out.println("Enter a correct choice");
}
}
}
class JAVASyntax
{
public static void main (String[] args)
{
Scanner sc=new Scanner(System.in);
char choice;
do{
System.out.println("1. Syntax of 'simple if' ");
System.out.println("2. Syntax of 'if else if' ");
System.out.println("3. Syntax of 'do while' ");
System.out.println("Enter your choice ");
choice=sc.next().charAt(0);
}while(choice <'1'||choice>'3');
switch (choice)
{
case '1':
System.out.println("if(condition){ ");
System.out.println("System.out.println(Ststement)");
System.out.println("}");
break;
case '2':
System.out.println("if(condition){ ");
System.out.println("System.out.println(Ststement)");
System.out.println("}");
System.out.println("else {");
System.out.println("Statement }");
break;
case '3':
System.out.println("do{ ");
System.out.println("System.out.println(Statement)");
System.out.println("}");
System.out.println("while(condition)");
break;
case '4':
System.exit(0);
break;
default:
System.out.println("Enter a correct choice");
}
}
}
0 Comments