Use a twodimensional array to solve the following problem A
Solution
Below is the full code, The code has been tested for the few inputs as stated in the question.
***************************************************************************
import java.util.*;
 import java.lang.*;
 import java.io.*;
 class TestClass // test class
 {
    
    static int [][]salesReport=new int[4][7];
    
     public static void SalesPersonTotals() //total the Sales
     {
         int i,j,sum;
         for(i=0;i<4;i++)
         {
             sum=0;
             for(j=1;j<6;j++)
             {
                 sum=sum+salesReport[i][j];
             }
             salesReport[i][6]=sum;
         }
        
     }
    
 public static void main (String[] args) throws java.lang.Exception // main function
 {
   
   int i,j;
   Scanner userInput = new Scanner(System.in);
         int salesPerson,productno,dollarval;
   for(i=0;i<4;i++)
   {
       salesReport[i][0]=i+1;
       for (j=1;j<7;j++)
       {
           salesReport[i][j]=0;
       }
   }
   
   do
   {
       System.out.println(\"Enter Sales Person Number (1-4) or -1 to quit and view data:\");
       salesPerson=userInput.nextInt();
       if (salesPerson==-1)
       {
           SalesPersonTotals();
           System.out.println(\"SalesPerson   | Product1   |    Product2   |    Product3   |    Product4   |    Product5   |    SalesPersonTotals\");
           for(i=0;i<4;i++)
           {
               for(j=0;j<7;j++)
               {
                   System.out.print(\"      \"+salesReport[i][j]+\"        \");
               }
               System.out.println();
           }
           System.exit(0);
       }
       else if ((salesPerson>=1)||(salesPerson<=4))
       {
           System.out.println(\"Enter the Product Number (1-5):\");
           productno=userInput.nextInt();
           if ((productno>=1)||(productno<=5))
           {
               System.out.println(\"Enter the dollar value:\");
               dollarval=userInput.nextInt();
               salesReport[salesPerson-1][productno]=dollarval;
           }
           else
           {
                System.out.println(\"Invalid Product Number entered\");
           }
          
       }
      
       else
       {
            System.out.println(\"Invalid Sales Person Number entered\");
       }
      
   }while(salesPerson!=-1);
   
 }
 }


