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 months 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 the
0 0
Add a comment Improve this question Transcribed image text
Answer #1

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. :)

Add a comment
Know the answer?
Add Answer to:
ho, then print the message "Next flight leaves in 3 hours." 6.22 Total Sales) Use a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use a two-dimensional array to solve the following problem. A company has four salespeople (1 to...

    Use a two-dimensional array to solve the following problem. A company has four salespeople (1 to 4) who sell five different products (1 to 5). Once a day, each salesperson passes in a slip for each different type of product sold. Each slip contains the following a) The salesperson number b) The product number c) 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...

  • Use a two-dimensional array to solve the following problem. A company has four salespeople (0 to...

    Use a two-dimensional array to solve the following problem. A company has four salespeople (0 to 3) who sell five different products (0 to 4). Once a day, each salesperson passes in a slip for each different type of product sold. Each slip contains the following: a) The salesperson number b) The product number c) 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...

  • Assignment3 - Protected View - Saved to this PC ejembi jeremy X File Home Insert DesignLayout Ref...

    please can i get the answer for the 3rd question Assignment3 - Protected View - Saved to this PC ejembi jeremy X File Home Insert DesignLayout References MailingsReview View Help Tell me what you want to do PROTECTED VIEW Be careful-files from the intermet can contain vinuses. Unless you ned to edi, it's safer to stay in Protected View Enable Editing Write a program that will read all this information for last month's sales and summarize the total sales by...

  • In C++. Write another program in file B2.cpp to calculate and print the total sales of...

    In C++. Write another program in file B2.cpp to calculate and print the total sales of each product by each salesperson. Read the sales slips from the file Salesslips.txt (or for partial points, in case your program Bl.cpp does not work correctly, from an array with the same data, initialized in your main program) and calculate the total sales of each product by each salesperson. Accumulate the total sales of each product by each salesperson in a two- dimensional array...

  • C++ Background information: A company has four salespeople who sell five different products. Once a day,...

    C++ Background information: A company has four salespeople who sell five different products. Once a day, each salesperson passes in a slip for each different type of product sold. First on the line is the salesperson name, second is the product number, and third is the sales volume for this product by this salesperson in dollars. For example, the line Tara 2 200.00 means that salesperson Tara reported sales of volume $200.00 for product number 2. Data: Eric 1 200000.00...

  • Need help with this programming please this is the instruction my teacher provided Write a C++...

    Need help with this programming please this is the instruction my teacher provided Write a C++ class called "Sales" and a main( ) function that uses the class. Also, write documentation of your project. Below is a specification of the class. . INTRODUCTION A company has four salespeople (1 to 4) who sell five different products ( to 5)1. Once a day each salesperson passes in a slip for each different type of product sold. Each slip contains: The salesperson...

  • Write a program that stores the weekly (Monday thru Friday) sales totals for three salespersons. Your...

    Write a program that stores the weekly (Monday thru Friday) sales totals for three salespersons. Your program should allow the user to enter the sales amounts and print a sales report with headings, the daily totals for each salesperson (your two-dimensional array), the calculated weekly totals for each sales person and the calculated totals for the day of each salesperson. In addition, create a single-dimensional array of Strings representing the days of the week (Monday-Friday) using an initializer list. Your...

  • Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...

    Use program control statements in the following exercises: Question 1 . Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds. Question 2. The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured...

  • 11-32(Objective 11-3) The following is the description of sales and cash receipts for the Lady’s Fashion Fair, a retail...

    11-32(Objective 11-3) The following is the description of sales and cash receipts for the Lady’s Fashion Fair, a retail store dealing in expensive women’s clothing. Sales are mainly on account using the store’s own billing rather than credit cards; however, some customers prefer to pay cash. Salesclerks assist customers and then direct them to the central desk for payment. The computer used to enter sales is operated by the store supervisor, who has been employed for 10 years by Alice...

  • Lab Objectives Be able to write methods Be able to call methods Be able to declare...

    Lab Objectives Be able to write methods Be able to call methods Be able to declare arrays Be able to fill an array using a loop Be able to access and process data in an array Introduction Methods are commonly used to break a problem down into small manageable pieces. A large task can be broken down into smaller tasks (methods) that contain the details of how to complete that small task. The larger problem is then solved by implementing...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT