entry · 28nmqw
sample java program
by Vinay Bmlang javaposted 2026-05-28lines 41
1import java.util.Scanner;23public class Flowchart {4 public static void main(String[] args) {5 Scanner scanner = new Scanner(System.in);6 int x;78 // Start9 // Input x10 System.out.println("Enter value for x:");11 x = scanner.nextInt();1213 // Diamond shape for condition14 while (x != 1 && x != 2) {15 // Box A16 // This represents a block of code or a process.17 // Since no specific operations are defined in box A,18 // we will simply loop back to input.19 System.out.println("Enter value for x:");20 x = scanner.nextInt();21 }2223 if (x == 1) {24 // Box B25 // This represents a block of code or a process.26 // Since no specific operations are defined in box B,27 // we will loop back to input.28 System.out.println("Enter value for x:");29 x = scanner.nextInt();30 } else if (x == 2) {31 // Box C32 // This represents a block of code or a process.33 // Since no specific operations are defined in box C,34 // we will proceed to the end.35 }3637 // End38 scanner.close();39 }40}41complete