You currently manage four stores and have the following data. The first row acro
ID: 3555481 • Letter: Y
Question
You currently manage four stores and have the following data. The first row across list the store numbers, the first column lists the items you carry and the numbers represent the quantity of the item.
Store 101 Store 102 Store 103 Store 104
Tennis Shoes 102 54 20 78
Sweaters 45 25 35 75
Jeans 12 35 45 65
Shorts 54 25 34 45
Jackets 15 35 50 25
Create a 2-dimensional array for the data above. Create a demonstration program that does the following:
Allows the manager to enter a store number and displays the quantity of all the items at the store.
Allows the manager to enter a store number and item and displays the quantity for that store and item.
Allows the manager to enter an item and displays the quantity for each store.
Allows the manager to enter a specific quantity and returns all items whose inventory is below the specified quantity (For example, if the manager enters 25 then the program would display the following: Store 103 Tennis Shoes, Store 101 Jeans and Jackets
Explanation / Answer
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package chegg;
/**
*
* @author Abhi
*/
import java.util.Scanner;
public class Manager {
public static void main(String [] args)
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the number of Stores : ");
int x=s.nextInt();
System.out.println("Enter the number of Items : ");
int y=s.nextInt();
int [][]a=new int[x][y];
String [] store =new String[x];
String [] item =new String[x];
for(int i=0;i<x;i++)
store[i]=s.nextLine();
for(int i=0;i<x;i++)
item[i]=s.nextLine();
for(int i=0;i<x;i++)
{
System.out.print("Enter data for " + item[i]);
for(int j=0;j<y;j++)
{
System.out.print("Enter data for " + store[j]);
a[i][j]=s.nextInt();
}
}
System.out.print("Enter store ");
String q=s.nextLine();
System.out.print("Enter item ");
String w=s.nextLine();
for(int i=0;i<x;i++)
{
if(store[i].contains(q))
{
for(int j=0;j<y;j++)
{
if(item[j].contains(w))
System.out.println("Number of stocks are :"+ a[i][j]);
}
}
}
System.out.print("Enter store ");
String qq=s.nextLine();
for(int i=0;i<x;i++)
{
if(store[i].contains(qq))
{
for(int j=0;j<y;j++)
System.out.println("Number of stocks are :"+ a[i][j]);
}
}
System.out.print("Enter item ");
String ww=s.nextLine();
for(int i=0;i<x;i++)
{
if(item[i].contains(ww))
{
for(int j=0;j<y;j++)
System.out.println("Number of stocks are :"+ a[i][j]);
}
}
System.out.print("Enter quantity ");
int p =s.nextInt();
for(int i=0;i<x;i++)
{
for(int j=0;j<y;j++)
{
if(a[i][j]==p)
{
System.out.println(store[i] +" "+ item[j]);
}
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.