0

what is problem?

import java.util.Random; public class Game { public static void main(String[] args) { int k = 2,sum = 0,i; Random ran = new Random(); String[] psh=new String [k]; String[] shekl=new String[6]; shekl[0]="🔺"; shekl[1]="🔵"; shekl[2]="⚫"; shekl[3]="🔴"; shekl[4]="🔶"; shekl[5]="🔷"; int and[]=new int[k]; int msh[]=new int[k]; for(i=0;i<k;i++){ int and[]=ran.nextInt(4); int msh[]=ran.nextInt(8)-4; System.out.print(shekl[and[i]]+"="+msh[i]+ "\t" ); } for(i=0;i<100;i++){ System.out.println(); } for(i=0;i<k;i++){ psh[i]=shekl[and[i]]; } int x=ran.nextInt(k); System.out.print(psh[x]); i--; sum = sum + msh[i]; } }

21st Dec 2019, 11:42 AM
mahdieh
2 odpowiedzi
+ 1
and[i]=ran.nextInt(4); msh[i]=ran.nextInt(8)-4; // Remove that "int" and insert "i" inside the square brackets. I don't know what you are trying to achieve because why do you need that 100 new lines? Anyways see if that is the only problem that I mentioned.
21st Dec 2019, 12:07 PM
Avinesh
Avinesh - avatar
+ 1
then you calculate sum, but you never use it. check for { } brackets, if your program is really what you think it is. because you use non-standard indentation, it is not error but can confuse programmers. in future save your code in sololearn playground and post here link to it, so we can see your progress direct and run/check it.
21st Dec 2019, 3:52 PM
zemiak