好吧,我一直像以前一样致力于此工作,并且不断出现新的错误,老实说,我只是想让它工作 就像是onlineTrade = input.nextLine()。toUpperCase.charAt();的问题一样就像我用char另一个做确切的事情一样,它的工作是如此混乱-我将其保留在包括input.nextLine和idk的大多数行中,如果brokerAssisted也出错了,因为我的程序可以编译并运行,但是it.wont.work 。也是我的初学者,这些东西只会让我旋转。我今天从这个小睡中抽了两小睡
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()