I'm new to coding. I'm practicing by coding a program that gives an actor his/her pay after subtracting his/her agent's cut. Why does it output an incorrect calculation? I can't seem to figure out the problem.
I searched on the web and I'm convinced that my math is right. There should be no reason for it to be outputting anything other than the correct answer.
Let's say the actor's pay is $100.00, and the agent's cut is 15%. The actor should get %85.00, right? Strangely, the console outputs $600.
I know this goes against the site's rules, but I find it's important to copy and paste the entire project, but it's not that long. Here it is:
.
.
import java.util.Scanner;
public class Main {
static int payBefore;
static int percentageTaken;
static int totalAfterCut;
static int percentageDividedBy100 = percentageTaken/100;
static int middleOfCalculation;
static Scanner payBeforeSc = new Scanner(System.in);
static Scanner percentageSc = new Scanner(System.in);
static Scanner middleOfCalculationSc = new Scanner(System.in);
public static void main(String args[]) {
incomeAndPercentageQuestions();
}
private static void incomeAndPercentageQuestions() {
System.out.println("How much did your job pay before any agent cuts?");
payBefore=payBeforeSc.nextInt();
System.out.println("What percentage is your agent taking?");
percentageTaken=percentageSc.nextInt();
calculation();
}
private static void calculation() {
totalAfterCut = payBefore * (100 / percentageTaken);
output();
}
private static void output() {
System.out.println("$" + totalAfterCut + " will be your pay after your agent's cut.");
}
}