I am having trouble with an assignment, the requirements being I have to make a madlib containing every single bit of info we have learned, but I am struggling with getting Boolean and character to work correctly
These are the errors that pop up when I try to compile:
--------------------------------------------------------------------------------------------------------------------------------------------
C:\Users\jnhv6\Desktop\I wasn't paying attention\MadLib.java:44: error: variable rank is already defined in method main(String[])
char rank = 'A';
^
C:\Users\jnhv6\Desktop\I wasn't paying attention\MadLib.java:47: error: cannot find symbol
rank = rank.nextChar();
^
symbol: method nextChar()
location: variable rank of type Scanner
2 errors
Tool completed with exit code 1
--------------------------------------------------------------------------------------------------------------------------------------------
And this is the actual code:
--------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------import java.util.Scanner; public class MadLib { public static void main(String[]args) { //declare and initialize variables Scanner keyboard = new Scanner(System.in); String name = ""; //Prompt the user for information System.out.println("What is your first name?"); name = keyboard.next(); keyboard.nextLine(); //Print out MadLib System.out.println(name + " was walking through school one day" + " minding your own business"); Scanner girl = new Scanner(System.in); int number = 0; System.out.println("When all of a sudden, (Choose a number)"); number = girl.nextInt(); girl.nextLine(); System.out.println(number + " girls randomly swarmed you asking for your autograph and number"); Scanner love = new Scanner (System.in); double meter = 0; System.out.println("They're love meters seem to be off the charts, clocking in at a whopping (Choose a number)"); meter = love.nextDouble(); love.nextLine(); System.out.println(meter + " love-ometers per millisecond!"); //---------------------------------------------------------------------------------------------------------------------- Scanner rank = new Scanner(System.in); char rank = 'A'; System.out.println("Turns out, you had involuntarily taken a compatibility test, and you scored a (Choose a Letter)"); rank = rank.nextChar(); rank.nextLine(); System.out.println(rank + " on the test, which was suprising to a lot of them!"); //----------------------------------------------------------------------------------------------------------------------- Scanner great = new Scanner(System.in); System.out.println("Turns out, the actual results of the test were"); boolean goof = false; goof = great.nextBoolean(); great.nextLine(); System.out.println(great +" so, that was nice to know"); great.nextLine(); System.out.println("GAME OVER"); } }
Please help, and thank you