我收到方法名稱下的紅線,爲什麼發生這種情況?方法未運行
Scanner input=new Scanner(System.in);
System.out.println("enter your account number");
int account_num= input.nextInt();
System.out.println("enter your name");
String account_owner=input.nextLine();
System.out.println("enter your account balance");
double current_balance=input.nextDouble();
System.out.println("enter 1 to deposit \nenter 2 to withdraw"
+"\nenter 3 to add interest value"
+"\nenter 4 to print all the information");
int option= input.nextInt();
if (option==1){
System.out.println("enter the amount of money to be depsit");
double Damount=input.nextDouble();
double a =Deposit(Damount,current_balance);
System.out.print(a);
public static double Deposit(double amount, double balance){
balance+=amount;
System.out.println("transction successful");
}}
哪個方法命名? –
如果你有紅線,這表明你有一個編譯時錯誤。請在你的文章中加入。閱讀http://tinyurl.com/stack-hints關於爲Stack Overflow寫一個好問題的建議。 –
你在你的代碼中有幾個問題..方法'公共靜態double Deposit()'需要在你的* current *方法之外。你還需要在'String account_owner = input.nextLine();' – TheLostMind