Results 1 to 3 of 3
  1. #1
    Innocent is offline Member
    Join Date
    Apr 2011
    Rep Power

    Smile Questions about the idea of the code

    I have homework in java, I just want to ask you some questions ( I don't want the whole code ).
    A company has four salespeople (numbered from 1 to 4), who sell five different products (numbered from 1 to 5). Once a day, each salesperson passes in a slip for each type of product sold. Each slip contains the following:
     The salesperson number,
     The product number,
     The total value of that product sold that day.
    1. Propose a class Slip to store the data of sales slips.
    2. Each salesperson passes in between 0 and 5 sales slips per days. Propose an array, slips, to store the data of sales slips for a whole month (31 days). Assume that the total value of each product never exceeds 99$. Write a method, collectSlips, to collect the sales information for a month by randomly filling the slips array.
    3. Write a method, summarizeSalesSlips, that will read all this information for one month’s sales and summarize the total sales by salesperson and by product. All the totals should be stored in sales, a two dimensional array.

    About Q2:
    I did 3 for - loops.
    1) start from 1 ---> 31 ( number of days )
    ........ 2) start from 1 ---> 4 ( number of Employees )
    ............... 3) start from 0 ---> 5 ( number of products )
    set the values (salesperson number, product number, total) randomly

    My questions are:
    1) what is the appropriate size of the array as the numbers are creating randomly ( included zero in number of products)
    2) Is my idea in Question 2 correct?
    3) How to do the methode of summarizeSalesSlip - I mean the idea - ?

    Thank you :D

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Richmond, Virginia
    Blog Entries
    Rep Power


    Try coding and testing one step at a time, first build and test the slip class and move on from there. Are you sure sales people should be turning in slips for items they didn't sell?

    As for question 3 of the assignment that can be done fairly easily with loops on the 2d array and if else clauses.

  3. #3
    UJJAL DHAR is offline Senior Member
    Join Date
    Apr 2010
    Rep Power


    Are you familiar with OOP.then OOp can make this problem easier.

    Do something like this...

    Java Code:
    class slip{
    int productnmbr;
    double totalvalueofthatproducr 
    class salesman{
    slip slipobj[5];
    public class MAIN{
    public static void main(String a[]){
    salesman salesperson[4];
    Don't Forget to try yourself before asking others help.....
    Press REP, if you find their advices/solutions effective.

Similar Threads

  1. Replies: 0
    Last Post: 03-21-2011, 10:46 AM
  2. No idea why my code won't work...
    By hopelessnoob in forum New To Java
    Replies: 11
    Last Post: 03-21-2011, 04:41 AM
  3. Questions on my code!
    By socboy6579 in forum New To Java
    Replies: 8
    Last Post: 11-03-2010, 03:30 AM
  4. Memory Leak questions, code review
    By mensaFool in forum Advanced Java
    Replies: 9
    Last Post: 03-08-2010, 05:27 PM
  5. UML, robust code, structure questions
    By mac in forum New To Java
    Replies: 2
    Last Post: 12-23-2009, 12:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts