0

okay so ive been working on this for like ever and new errors just keep popping up and i honestly just want this to work like rn its a problem with onlineTrade = input.nextLine().toUpperCase.charAt(); and like i did the exact thing with char another and it worked so im confused - ive kept in most of the lines that include input.nextLine and idk if brokerAssisted is wrong as well because my program will compile and run but it.wont.work. also im a beginner and this stuff just makes my head spin. i took 2 naps today from this stressing me OUT

char another = ' ';
char brokerAssisted = ' '; 
char onlineTrade = ' ';



System.out.printf("Do you want to calculate your stock purchases?  "
                    +"Enter 'Y' or 'N' to exit:  "); //PROMPT 2
another = input.nextLine().toUpperCase().charAt(0);

while (Character.toUpperCase(another) == 'Y')
{
  noOfStocks = noOfStocks + 1; // CALCULATION 1

  System.out.printf("How many shares did you purchase?  "); // PROMPT 3
  shares = input.nextInt();

  System.out.printf("What is the price per share?  "); //PROMPT 4
  sharePrice = input.nextDouble();


  System.out.printf("Is this an online trade?  Enter 'Y' or 'N':  ");//PROMPT 5
  onlineTrade = input.nextLine().toUpperCase().charAt(0);

  if (Character.toUpperCase(onlineTrade) == 'Y')


  else if (Character.toUpperCase(onlineTrade) != 'Y')
  {
    System.out.printf("%nIs this a broker assisted trade?  Enter 'Y' or 'N':  "); //PROMPT 6
    brokerAssisted = input.nextLine().toUpperCase().charAt(0);

  System.out.printf("%nEnter ‘Y’ to calculate the cost of another stock purchase or ‘N’ to exit:  "); //PROMPT 7
  another = input.nextLine().toUpperCase().charAt(0);
}//END WHILE

if (noOfStocks > 0);
  {
    System.out.printf("%nYEE-TRADE, INC.%nTOTAL COST OF STOCK PURCHASES%n");
    System.out.printf("FOR %s%n", customerName);
    System.out.printf("AS OF %1$Tb, %1TY\n%n", dateTime);
    totalStockCost = 0.0;
    System.out.printf("%n%nTotal Stock Cost:  $%.02f%n", totalStockCost);
    totalOnlineFees = 0.0;
    System.out.printf("Total Online Fees:  $%.02f%n", totalOnlineFees);
    totalCommissions = 0.0;
    System.out.printf("Total Commissions:  $%.02f%n", totalCommissions);
    totalCost = 0.0;
    System.out.printf("%nTOTAL COST:  $%.02f%n", totalCost); //PRINT 2
  }//END IF

    System.out.printf("Thank you for using Yee-Trade's stock purchase calculator!%n");//PRINT 4 

    noOfStocks = 0;
System.exit(0);

}//end main()

0 Answers0