-1
如何爲每個問題調用此處的方法?我嘗試了一些不同的東西,但它不適合我。以下是我迄今爲止:如何多次調用方法
import java.util.Scanner;
public class TaxCalc
{
public static void main(String [] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter number of dependents: ");
int dependents=keyboard.nextInt();
System.out.print("Enter number of pigs: ");
int pigs= keyboard.nextInt();
System.out.print("Enter number of oinks: ");
double oinks=keyboard.nextDouble()-(pigs*500)+(200*dependents);
System.out.println("Oinks after rewards: " + oinks);
if(oinks<10000) oinks -= oinks*0.02; //2% tax
else if(oinks<5000) oinks -= oinks*0.1; //10% tax
else oinks -= oinks*0.2; //20% tax
System.out.println("Oinks after penalties: " + oinks);
}
}
你想在每次輸入後調用一個方法嗎?開始[這裏](http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html)。 – Celeo 2014-10-11 23:49:24
我不確定你在問什麼。你打算用什麼方法打電話?它應該在哪裏被調用?你現在的代碼有什麼問題? – Pshemo 2014-10-11 23:53:29
這是我們必須做的http://gyazo.com/e4d2af76dbb9704a620f6d65f59b547f – user4068770 2014-10-11 23:59:20