0

PLS CHECK THIS WHETHER THE CODE SNIPPET IS RIGHT AS IT IS ALWAYS SHOWING ERROR

import java.util.*; class program1//class declaration {//opening of class Scanner sc=new Scanner(System.in); System.out.println("Enter a choice between 1 and 2"); int choice=sc.nextInt(); switch(choice) { case 1: int k1=1; int a,b,c; for(a=1;a<=5;a++) { for(b=a;b<5;b++) System.out.print(" "); for(c=1;c<=a;c++) { System.out.print(k1); k1++; if(k1==9) k1=0; } System.out.println(); } break; } }

4th Sep 2021, 7:26 AM
JusCodin'Bro
5 Réponses
+ 2
The main methode is missing. Try this: import java.util.*; class program1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter a choice between 1 and 2"); int choice=sc.nextInt(); switch(choice) { case 1: int k1=1; System.out.print("*"); int a,b,c; for(a=1;a<=5;a++) { for(b=a;b<5;b++) System.out.print(" "); for(c=1;c<=a;c++) { System.out.print(k1); k1++; if(k1==9) k1=0; } System.out.println(); } break; } } }
4th Sep 2021, 10:50 AM
Coding Cat
Coding Cat - avatar
+ 2
That is a lot of nested loops, what are you trying to achieve anyways?
4th Sep 2021, 7:30 AM
Tim
Tim - avatar
0
@Nick it's a java project...if possible pls check the program snippet
4th Sep 2021, 7:35 AM
JusCodin'Bro
0
JusCodin'Bro That's not an answer to his question.
4th Sep 2021, 7:36 AM
Simon Sauter
Simon Sauter - avatar