-1

How would I call a method on here for each question? I've tried some different things but it won't work for me. Here is what i have so far:

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);
    }
}
user4068770
  • 47
  • 2
  • 12
  • You're trying to call a method after each input? Start [here](http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html). – Celeo Oct 11 '14 at 23:49
  • 1
    I am not sure what you are asking. What method are you trying to call? Where should it be called? What is the problem with your current code? – Pshemo Oct 11 '14 at 23:53
  • Here is what we have to do http://gyazo.com/e4d2af76dbb9704a620f6d65f59b547f – user4068770 Oct 11 '14 at 23:59
  • 1
    There is not really a question here. You have only told us that "it won't work for me" what is not working exactly? and what is your desired results? – chancea Oct 12 '14 at 00:19

1 Answers1

0

I think you might be looking for something like this

import java.util.Scanner;

    public class TaxCalc
    {
        public static void main(String [] args)
        {
          Scanner keyboard = new Scanner(System.in);

          int dependents = inputInt("Enter number of dependents: ", keyboard);

          int pigs = inputInt("Enter number of pigs: ", keyboard);

          double oinks= inputInt("Enter number of oinks: ", keyboard) -(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);
        }

    public int inputInt(String prompt, Scanner keyboard){
        System.out.println(prompt);
        return keyboard.nextInt();
    }

    public double inputDouble(String prompt, Scanner keyboard){
        System.out.println(prompt);
        return keyboard.nextDouble();
    }
}

Although it is very hard to tell what it is that you want to achieve.

SamTebbs33
  • 5,507
  • 3
  • 22
  • 44
  • 1
    If it's "very hard to tell what it is that [the asker] want[s] to achieve", consider flagging off-topic -> _unclear what you're asking_ instead of guessing at an answer. – Jeffrey Bosboom Oct 12 '14 at 01:31