Im Hoping someone can X a search alstatela ed u/submission/desc on assignment 56
ID: 3572696 • Letter: I
Question
Im Hoping someone can X a search alstatela ed u/submission/desc on assignment 5696182 A company manufactures 5 different devices and each device is built using a varying amount of 7 different components. Each device and its required amount of components is listed in the table below. Components 1 2 3 4 5 6 7 MP3 Player Smart Phone 8 2 12 11 6 15 2 Digital Watch 9 6 7 10 15 8 3 Tablet 12 14 8 15 2 7 8 Portable Gaming System 1210 3 11 8 3 5 Each component has an individual cost which is listed in the table below. Components Cost $10.75 $15.27 $5.98 $9.67 $4.32 $12.50 $1.42 Using the information in the tables, your program will calculate some data about the products. Populating the Data: Your program will have three arrays: o A 2D array to store the data of the first table o A 1D array to store the names of each product a A 1D array to store the costs of each component. Practice getting the data into your program in these ways: o Console input with Scanner o File IO o Using an Initializer List. 750 AM a Ask me anyExplanation / Answer
import java.sql.Array;
import java.util.Arrays;
import java.util.Scanner;
public class DeviceCalc {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String [][] devices = new String [5][7];
float[] price = new float[7];
String[] products = new String[5];
System.out.println("enter number of rows and columns");
int rows = sc.nextInt();
int columns = sc.nextInt();
for(int i=0;i<rows;i++){
for(int j=0;j<columns;j++){
devices[i][j] = sc.next();
}
}
for(int i=0;i<5;i++){
for(int j=0;j<7;j++){
System.out.print("the devices are"+devices[i][j]);
}
}
for(int j=0;j<5;j++){
products[j] = sc.next();
}
for(int k=0;k<7;k++){
price[k] = sc.nextFloat();
}
float[] manufacturecost = manufactureCost(devices,price,products);
for(int i=0;i<5;i++){
for(int j=0;j<5;j++){
System.out.println("The total manufacture cost of all products"+products[i]+manufacturecost[j]);
}
}
float highCost = highDeviceCost(manufacturecost,products);
float lowCost = lowDeviceCost(manufacturecost,products);
System.out.println("The max price is"+highCost);
System.out.println("The min price is"+lowCost);
}
static float[] manufactureCost(String [][] devices1,float[] price1, String[] products){
float totalCost =0;
float[] costAllProducts = new float[5];
for(int i=0;i<5;i++){
for(int j=0;j<7;j++){
for(int k=0;k<=j;k++){
totalCost = totalCost+price1[i]*(Float.valueOf(devices1[j][k]));
}
}
costAllProducts[i]=totalCost;
}
return costAllProducts;
}
static float highDeviceCost(float[] price, String[] products){
Arrays.sort(price);
float maxValue = price[6];
return maxValue;
}
static float lowDeviceCost(float[] price, String[] products){
Arrays.sort(price);
float minValue = price[0];
return minValue;
}
}