ho, then print the message \"Next flight leaves in 3 hours.\" 6.22 Total Sales)
ID: 3730579 • Letter: H
Question
ho, then print the message "Next flight leaves in 3 hours." 6.22 Total Sales) Use a two-dimensional array to solve the following problem. A company has four salespeople (I to 4) who sell five diferent products (I to 5). Once a day, each salesperson pases in a slip for each different type of product sold. Each slip contains: a) b) c) The salesperson numbor The product number The total dollar value of that product sold that day Thus, each salesperson passes in between 0 and 5 sales slips per day. Assume that the information uld be the two-dimensional array sales. After processing all the information for last mont from all of the si for last month is available. Write a program that will read all this information for last month's sales and summarize the total sales by salesperson by product. All totals sho print the results in tabular format with each column representing a particular salesperson a row representing a particular product. Cross total each row to get the total sales of each product lo last month; cross total each column to get the total sales by salesperson for last month. Your ta printout should include these cross totals to the right of the totaled rows and to the bottomo totaled columns. and each f theExplanation / Answer
Solution:
The stated problem is implemented using java, if you need it in any other language please let me knoe. thanks :)
code:
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);
}
}
I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.