Noob needing help making first program a netbeans GUI
Hi folks, Im using Netbeans IDE. Is that JavaEE?
Not long started teaching myself Java you see.
This is my first completely self made program.
Code:
Scanner scanner = new Scanner(System.in);
int diff = 0;
System.out.println("Please choose a difficulty:\nA 1-10 \nB 1-20 \nC 1-100");
char ch = scanner.next().charAt(0);
switch (ch) {
case 'A':
case 'a':
{
diff = 10;
System.out.println("Difficulty chosen: 1 - " + diff);
break;
}
case 'B':
case 'b':
{
diff = 20;
System.out.println("Difficulty chosen: 1 - " + diff);
break;
}
default:
{
diff = 100;
System.out.println("Difficulty chosen: 1 - " + diff);
break;
}
}
System.out.println("Please think of a number.\nPress enter when ready.");
scanner.nextLine();
scanner.nextLine();
Random generator = new Random();
int y = generator.nextInt(diff)+1;
System.out.println("\nPlease add " + y);
scanner.nextLine();
System.out.println("Please double the number you now have");
scanner.nextLine();
int x = generator.nextInt(diff/2)*2;
System.out.println("Please add " +x);
scanner.nextLine();
System.out.println("Please now devide the number you have by two");
scanner.nextLine();
System.out.println("Please now subtract " + (x/2));
scanner.nextLine();
System.out.println("Please now subtract the \nnumber you originaly thought of");
scanner.nextLine();
System.out.println("The number you are now thinking of is " + y);
It asks the user to think of a number. No input just to think of a number. Then it tries to cancel out and replace that number hopefully without the user realising. A magic numbers mind trick i guess.
I'm looking to add a gui and have already watched some youtube vids about it but i'm stuck on how to make my program and the new jframe i've been mucking about in work together?
Total noob, been 3 weeks so far.
Any help appreciated
Martin.
Re: Noob needing help making first program a netbeans GUI
Quote:
how to make my program and the new jframe i've been mucking about in work together?
Can you post the code you are having problems with?
Do you have any specific java programming questions?
Re: Noob needing help making first program a netbeans GUI
Hi Norm,
The first thing is probably something obvious im missing. Do i just copy the generated code from the Jframe tab into my program code tab?
Re: Noob needing help making first program a netbeans GUI
Sorry, I don't know anything about the generated code you are talking about.
I have never used netbeans
Re: Noob needing help making first program a netbeans GUI
Probably out of my depth Norm but thanks anyway.
Re: Noob needing help making first program a netbeans GUI
Re: Noob needing help making first program a netbeans GUI
No, will check that out right now. Thanks.