So, I am trying to test my if else with two Character.toUpperCase answers and I keep getting this error: 1 error found
Error: bad operand types for binary operator '^'
first type: char
second type: boolean

I tried && and & and it won't work. If I don't use anything except an else, when the user inputs yes for the first if, it skips everything and goes straight for this else, but not for my second if statement. Second if statement works perfectectly even when I have just the else statement instead of an if else. So, I don't know exactly what to do.

This is the portion of the program that it's giving me that error:

else
if(Character.toUpperCase(onlineTrade) & Character.toUpperCase(brokerAssisted) != 'Y')
{
    System.out.printf("\nInvalid Entry! Exiting program.");
   anotherStock = 'N';
   invalidTrade = true;
   stockPurchases = "";
  }
  if(anotherStock != 'N')
  {
    System.out.printf("\nDo you want to process another Trade? Enter 'Y' or 'N': ");
  anotherStock = input.nextLine().charAt(0);
  }
  if(invalidTrade = true)
  {
    anotherPerson = 'N';
    }

Sorry the error code should read '&' not '^', that was result from when I tried ^ just to see if it would take that.

does Character.toUpperCase(onlineTrade)
return a boolean? if not, which I find the most likely answer, that's your problem.
something tells me you meant:
if(Character.toUpperCase(onlineTrade) != 'Y' & Character.toUpperCase(brokerAssisted) != 'Y')

yeah I figured out that I need to put both != 'Y'

however I am having another issue with the boolean invalidTrade, it's not catching the 'n' and keeps processing the next two prompts, I don't understand how it's not catching it and this teacher is picky and likes things done her way.

 else
    if(Character.toUpperCase(onlineTrade) != 'Y' && Character.toUpperCase(brokerAssisted) != 'Y')

  {
    System.out.printf("\nInvalid Entry! Exiting program.");
   anotherStock = 'n';
   invalidTrade = true;
   stockPurchases = "";
  }
  if(anotherStock != 'N')
  {
    System.out.printf("\nDo you want to process another Trade? Enter 'Y' or 'N': ");
  anotherStock = input.nextLine().charAt(0);
  }
  if(invalidTrade)
  {
    anotherPerson = 'N';

  }
    System.out.printf("\nWill trades continue for another person? Enter 'Y' or 'N': ");
  anotherPerson = input.nextLine().charAt(0);

Nevermind I got it!

Please mark this thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.