I'm trying to get the program to print the difference between two sales figures using an array.
I can't figure out what the problem is.
Any help will be greatly appriciated.
Here is the code
public class Earnings
public static void main(String args)
final int salesReps = 2; //Number of sales reps to compare
double sales = new double[salesReps]; //Create array
Scanner keyboard = new Scanner(System.in); //For keyboard input
System.out.println("Enter the total sales amount for "
+salesReps+ " sales representatives to compare. "); //Ask for sales figures
for (int index = 0; index <salesReps; index++)
System.out.print("Sales representative " + (index +1) + " sold ");
sales[index] = keyboard.nextDouble();
System.out.println("Sales representative 1 sold"
+(sales-sales)+ " more than sales representative 2.");
System.out.println("Sales representative 2 sold"
+(sales-sales)+ " more than sales representative 1");
if (sales>sales) ----> if (sales>sales) ?
That's exactly the problem. I can't believe I missed it. Thank you so much!
Originally Posted by Ksharp