Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import javax.swing.JOptionPane;
- public class SalesCommission
- {
- public static void main( String [] args )
- {
- double commissionRate;
- double item1Commission;
- double item2Commission;
- double item3Commission;
- double item4Commission;
- double totalCommission;
- int item1Quantity;
- int item2Quantity;
- int item3Quantity;
- int item4Quantity;
- int itemSelected;
- commissionRate = 0.09;
- item1Commission = 239.99 * commissionRate;
- item2Commission = 129.75 * commissionRate;
- item3Commission = 99.95 * commissionRate;
- item4Commission = 350.89 * commissionRate;
- item1Quantity = 0;
- item2Quantity = 0;
- item3Quantity = 0;
- item4Quantity = 0;
- itemSelected = 0;
- totalCommission = 200 + (item1Quantity * item1Commission) + (item2Quantity * item2Commission) + (item3Quantity * item3Commission) + (item4Quantity * item4Commission);
- Scanner input = new Scanner( System.in );
- System.out.println( "Enter item number. Enter -1 to quit." );
- itemSelected = input.nextInt();
- while( itemSelected != -1 )
- {
- if( itemSelected == 1 )
- {
- System.out.printf( "How many of item 1 did you sell?\n" );
- item1Quantity = item1Quantity + input.nextInt();
- }
- else if( itemSelected == 2 )
- {
- System.out.printf( "How many of item 2 did you sell?\n" );
- item2Quantity = item2Quantity + input.nextInt();
- }
- else if( itemSelected == 3 )
- {
- System.out.printf( "How many of item 3 did you sell?\n" );
- item3Quantity = item3Quantity + input.nextInt();
- }
- else if( itemSelected == 4 )
- {
- System.out.printf( "How many of item 4 did you sell?\n" );
- item4Quantity = item4Quantity + input.nextInt();
- }
- else
- {
- System.out.println( "Item number does not exist." );
- }
- System.out.println( "Enter item number. Enter -1 to quit." );
- itemSelected = input.nextInt();
- }
- String message = String.format( "Your commission is $%.2d", totalCommission );
- JOptionPane.showMessageDialog( null, message );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement