私は完全に困惑しています。私はJavaプログラミングの初心者です。私は次のコードを持っていますが、public static void 行で「タイプの不正な開始」エラーが発生する理由を理解できません。助けてください。
また、この成長するプログラムを複数のクラスに分割するにはどうすればよいですか?
`package annual.salary;
/*Annual Salary Calculator
* Version 1.1
*/
import java.util.Scanner; //Program uses Scanner
import java.text.DecimalFormat; //Configures output for dollar amounts
import java.util.InputMismatchException; //Checks for invalid user input
public class AnnualSalary
{
public void displayMessage()
{
//display intro message to calculator
System.out.println("Annual Compensation Calculator");
}
public static void main (String[] args,)
{
double salary; //This is the annual sales value
double rate; //Commission rate once minimum sales reached
double commission; //This is the amount of commision made
double pay; //Salesperson's total pay
double sales; //annual sales, prompted user input
double incentive; //bonus rate once sales target is exceeded
double max; //sets maximum sales amount to calculate for potential earnings table
boolean isValidNumber=false; //default flag for numeric sales input
Scanner input = new Scanner( System.in ); //allows user input from command window
DecimalFormat dollar = new DecimalFormat("#,##0.00");
salary = 50000.00;
rate = 0.05;
incentive = 0.0625;
sales = 0;
max = sales * 1.5;
System.out.println(" Enter The Annual Sales "); //prompt for input from user
while(!isValidNumber) //Continue to prompt user until a valid number is entered
{
try //try/catch block to handle invalid characters.
{
sales = input.nextDouble(); //Read number from user, if alpha character is keyed then an exception is thrown
isValidNumber = true; //Set our flag so we can exit the loop
}
catch(InputMismatchException ioe) //Catch input not matching excpected type.
{
System.out.println("Please enter a numeric value."); //re-prompt user
input.next(); //If Scanner translates successfully it advances, however if it fails it must be manually advanced.
}
}
while (sales < 96000.00) //conditional statement for sales below 80% of goal
{
pay = salary ;
System.out.println("Total Annual Compensation is $"+dollar.format(pay));
}
while (sales >= 96000.00 && sales <= 120000.00) //conditional statement for sales 80%-100% of goal
{
commission = sales * rate;
pay = commission + salary;
System.out.println("Total Annual Compensation is $"+dollar.format(pay));
}
while (sales > 120000.00) //conditional statement for sales exceeding goal
{
commission = sales * incentive;
pay = commission + salary;
System.out.println("For: $" + sales + " The Total Compensation is: $" +dollar.format(pay));
}
while(sales < max) //This sets the while loop to start at minimum & end at the max
{
sales = sales + 5000;
if (sales < 96000.00) //conditional statement for sales below 80% of goal
{
pay = salary;
}
else if (sales >= 96000.00 && sales <= 120000.00)
{
commission = sales * rate;
pay = commission + salary;
}
while (sales > 120000.00) //conditional statement for sales exceeding goal
{
commission = sales * incentive;
pay = commission + salary;
System.out.println("For: $" + sales + " The Total Compensation is: $" +dollar.format(pay));
}
} //Ends the body of the while loop.
}
} //end calculator'