mercredi 8 novembre 2017

Weird Error... What Do I Do?

So i have this code im trying to make. It consists of having to find the absolute difference of 2 numbers, and if the AD is above 21, the program has to double it. Iv'e created what i believe should work, but it wont compile. The error im getting is: >1 error found: File: C:\Users\ralph\Desktop\twenny.java [line: 6] Error: Duplicate local variable n

Any help or ideas would be greatly appreciated! Code is below :)

class twenny
{
public static int v (int n) 
{
  int x=17;
  int n=21-x;
  int w= +n;
 
 if(w<=21)
 {
   return w;
}
 if(w>=21)
 {
   return w*2;
 }
}
}

Aucun commentaire:

Enregistrer un commentaire