It is supposed calculate the sales commission based on input variables and list them after the loop is done.
I am unsure how to go about listing the values of totalEarned after because they change when the loop is done.
import java.util.Scanner;
public class SalesCommissionCalc
{
public static void main( String [] args )
{
final int SENTINEL = -1;
double grossSales;
double totalEarned;
Scanner scan = new Scanner( System.in );
System.out.print( "Enter gross sales for the last week, or -1 to stop > " );
grossSales = scan.nextDouble( );
while ( grossSales != SENTINEL )
{
totalEarned =(500 + (grossSales * .08));
System.out.println( "Earned last week: $" + totalEarned );
System.out.print( "Enter gross sales for the last week, or -1 to stop > " );
grossSales = scan.nextDouble( );
System.out.println( "Total Earned: $" + totalEarned );
}
}
}
Also if I added names to the program would I have to introduce another loop or would I be able to squeeze it into the same loop and keep the inputted names attached to the inputted values for when I list them after the loop?