Name: Anonymous 2012-10-12 16:03
Hey /prog/
I work in java and it's supposed to be lottery program. I need desperate help with my code. Sorry the coding is in norwegian and yes i'm a newbie. Here it is:
import java.util.Scanner;
public class lotteri2
{
public static void main(String[]args)
{
Scanner input = new Scanner(System.in);
int[]tabell = new int[7];
LesInn(tabell);
Trekk(tabell);
SkrivUt(tabell);
int rader;
int valg;
System.out.println("Vil du spille Lotto eller Vikinglotto?");
System.out.println("Press 1 for Lotto eller 2 for Vikinglotto");
System.out.print(": ");
valg = input.nextInt();
}
static int LesInn(int[]tabell)
{
Scanner input = new Scanner(System.in);
int rader;
System.out.println("Hvor mange rader ønsker du?");
rader = input.nextInt();
return rader;
}
static void Trekk(int[]tabell)
{
//Lotto
if(valg==1)
for(int t=0; t<=5; t++)
{
int trekk;
trekk = (int) (Math.random() *34) +1;
tabell [trekk] = tabell [trekk] +1;
}
//Vikinglotto
else
for(int t=0; t<=6; t++)
{
int trekk;
trekk = (int) (Math.random() *48) +1;
tabell [trekk] = tabell [trekk] +1;
}
}
static void SkrivUt(int[]tabell)
{
System.out.println(" "+tabell);
}
}
error: cannot find symbol
if(valg==1)
^
symbol: variable valg
location: class lotteri2
1 error
I work in java and it's supposed to be lottery program. I need desperate help with my code. Sorry the coding is in norwegian and yes i'm a newbie. Here it is:
import java.util.Scanner;
public class lotteri2
{
public static void main(String[]args)
{
Scanner input = new Scanner(System.in);
int[]tabell = new int[7];
LesInn(tabell);
Trekk(tabell);
SkrivUt(tabell);
int rader;
int valg;
System.out.println("Vil du spille Lotto eller Vikinglotto?");
System.out.println("Press 1 for Lotto eller 2 for Vikinglotto");
System.out.print(": ");
valg = input.nextInt();
}
static int LesInn(int[]tabell)
{
Scanner input = new Scanner(System.in);
int rader;
System.out.println("Hvor mange rader ønsker du?");
rader = input.nextInt();
return rader;
}
static void Trekk(int[]tabell)
{
//Lotto
if(valg==1)
for(int t=0; t<=5; t++)
{
int trekk;
trekk = (int) (Math.random() *34) +1;
tabell [trekk] = tabell [trekk] +1;
}
//Vikinglotto
else
for(int t=0; t<=6; t++)
{
int trekk;
trekk = (int) (Math.random() *48) +1;
tabell [trekk] = tabell [trekk] +1;
}
}
static void SkrivUt(int[]tabell)
{
System.out.println(" "+tabell);
}
}
error: cannot find symbol
if(valg==1)
^
symbol: variable valg
location: class lotteri2
1 error