Ajuddy 0 Newbie Poster

here is the question. i have done half of it.

a company has 4 sales persons, who sell 5 different products, once a day each salesperson passes a slip for each product sold.
the slip contains: sales person no., product no., total cash value for the products sold that day. the salespersons passes between (0 and 5) slips per day. Assume htat the information from the last slips for last month (30) is available. write a program that will read all the information f and summarize ie., total sales by sales person by product. all total sales should be stored in 2-dimensional sales.

after processing all the information on last month, displaying the result in tabular with each column representing a particular salesperson and each row representing a particular product.

gross total each row to get the total sales of each product for last month. gross total each column to get the total sales per salesperson for last month.

(the part i cant do is getting the gross total and tabulating them).

here is the code so far.

import java.io.*;
public class SalesPerson {
int number;
Slip slips[];
Slip current;
InputStreamReader isr;
BufferedReader stdin;


public SalesPerson(int number_in){
number = number_in;
slips = new Slip[30];
isr = new InputStreamReader(System.in);
stdin = new BufferedReader(isr);
}



public void read(){
System.out.println("Information for person no. "+number);
System.out.println();
for(int i = 0; i < 3; i++){
System.out.println("Day "+(i+1));
current = new Slip(number);
for(int j = 0; j < 2; j++){
if(j == 0)
System.out.println("Enter product numbers");
else
System.out.println("Enter product cash values");
for(int k = 0; k < 5; k++){
try {
current.products[j][k] = Double.parseDouble(stdin.readLine());
}
catch(NumberFormatException ex) {
System.out.println(ex.getMessage());
}
catch(IOException ex) {
System.out.println(ex.getMessage());
}
}
}
slips = current;
}
}


public void print(){
System.out.println("Information for person no. "+number);
System.out.println();
for(int i = 0; i < 3; i++){
current = slips;
System.out.println("Day "+(i+1));
for(int j = 0; j < 2; j++){
if(j == 0)
System.out.println("Product numbers");
else
System.out.println("Product cash values");
for(int k = 0; k < 5; k++){
System.out.print(current.products[j][k]+"  ");


}
System.out.println();
}
System.out.println();
}
}


}



>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
import java.io.*;
public class Slip {
int personNum;
double products[][];


public Slip(int pn) {
personNum = pn;
products = new double[2][5];
}
}


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


import java.io.*;
public class Test1 {
public static SalesPerson person1, person2, person3, person4;


public Test1(){
person1 = new SalesPerson(1);
person2 = new SalesPerson(2);
}
public static void main(String[] args){
Test1 test1 = new Test1();
person1.read();
person1.print();
}


}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.