-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSalesman.java
More file actions
43 lines (42 loc) · 1.15 KB
/
Salesman.java
File metadata and controls
43 lines (42 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Program: Calculate Total Sales of Each Salesman
// Topic: 2D Arrays
// Description: Reads sales data for 2 salesmen over 3 months, stores it in a 2D array,
// calculates total sales for each salesman, and displays the results using nested loops.
package Array2D;
import java.util.*;
/**
*
* @author Samim
*/
public class Salesman
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int ar[][]=new int[2][3];
int sales[][]=new int[2][1];
int sum=0;
for(int i=0;i<2;i++)
{
System.out.println("Enter Sales Of Salesman "+(i+1));
for(int j=0;j<3;j++)
{
ar[i][j]=sc.nextInt();
sum=sum+ar[i][j];
}
for(int k=0;k<1;k++)
{
sales[i][k]=sum;
}
sum=0;
}
for(int i=0;i<2;i++)
{
System.out.println(" Total Sales Of Salesman "+(i+1));
for(int j=0;j<1;j++)
{
System.out.println(sales[i][j]);
}
}
}
}