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; } }
5 ответов
+ 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;
}
}
}
+ 2
That is a lot of nested loops, what are you trying to achieve anyways?
0
@Nick it's a java project...if possible pls check the program snippet
0
JusCodin'Bro That's not an answer to his question.