Ask Question
20 March, 22:30

Write a java program that use multiple arrays This is a simple array program which does not use an "external class & demo program" If you wish, you may break it down into methods, but that is not required. a. Set up 4 arrays which hold data about 6 items you want to sell: [make them up] int[ ] itemnum int[ ] quantity double[ ] price double[ ] sales b. Set up loops to load the itemnum, quantity and price arrays c. Set up another loop to calculate values for the sales array. [ = price * quantity] d. Set up another loop to print the item number and sales amount for each transaction. e. Set up another loop to calculate the total sales of all 6 items f. print the total sales amount

+3
Answers (1)
  1. 20 March, 23:15
    0
    Explanation:

    import java. util. Array;

    public class Items{

    public static void main (String {} args) {

    / / a. Set up 4 arrays which hold data about 6 items you want to sell

    int [] itemnum = new int[] (1,2,3,4,5,6);

    int [] quantity = new int[] (500,200,350,100,270,300);

    double [] price = new double [] (10000, 50000,30000, 22000, 26000,100200);

    double[] sales = new double [6];

    //b. Set up loops to load the itemnum, quantity and price arrays

    for (int I=0; I<6; I++)

    {

    System. out. println ("Item "+itemnum[I]);

    System. out. println ("Item "+quantity[I]);

    System. out. println ("Item "+price[I]);

    }

    //c. Set up another loop to calculate values for the sales array.

    for (int j=0; j<6; j++)

    {

    sales[j] = quantity[j] * price[j];

    }

    //d. Set up another loop to print the item number and sales amount for each transaction

    for (int k=0; k<6; k++)

    {

    System. out. println ("Item Number "+itemnum[k]);

    System. out. println ("Sales Amount "sales[k]);

    }

    //e. Set up another loop to calculate the total sales of all 6 items

    double totalsales = 0;

    for (int l=0; l<6; l++)

    {

    totalsales+=sales[l];

    }

    //f. print the total sales amount

    System. out. print ("Total Sales: "+totalsales);

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a java program that use multiple arrays This is a simple array program which does not use an "external class & demo program" If you ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers