Hey anyone could help me I would be greatly appreciative. I am writing a program that asks me to write a method that accepts arguments the number of shares, the purchase price per share, the purchase commission paid, the sale price per share, and the sales commission paid. The method should return the profit or loss from the sale of stock. Demonstrate the method in a program that asks the user to enter the necessary data and displays the amount of the profit or loss. Here is what I have but it keeps saying I have an "else" without an "if" but I do have an "if". HELP lol
import java.util.Scanner;
public class StockProfit{
public static void main(String[]args){
Scanner keyboard = new Scanner(System.in);
int Ns,Sp,Sc,Pp,Pc;
int profit;
System.out.println("Enter the number of shares");
Ns=keyboard.nextInt();
System.out.println("Enter the purchase price per share");
Pp=keyboard.nextInt();
System.out.println("Enter the purchase commission paid");
Pc=keyboard.nextInt();
System.out.println("Enter the sale price per share");
Sp=keyboard.nextInt();
System.out.println("Enter the sales commission paid");
Sc=keyboard.nextInt();
profit = ((Ns*Sp)-Sc)-((Ns*Pp)+Pc);
if (profit > 0);
{
gain(profit);
}
else
{
loss(profit);
}
}
public static void gain(int green){
System.out.println("Your total profit was" +green);
}
public static void loss(int red){
System.out.println("Your total loss was" +red);
}
}