Question

In Java: A company manufactures 5 different devices and each device is built using a varying...

In Java:

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 9 13 4 7 1 14 10

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 12 10 3 11 8 3 5

Each component has an individual cost which is listed in the table below.

Components
1 2 3 4 5 6 7
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:

A 2D array to store the data of the first table

A 1D array to store the names of each product

A 1D array to store the costs of each component.

Practice getting the data into your program in these ways:

Console input with Scanner

File I/O

Using an Initializer List.

Calculations:

Compute and Display the cost of manufacturing each device.

Compute and Display the Device name with the highest cost.

Compute and Display the Device name with the lowest cost.

Practice other calculations as you see fit, i.e. Average number of components per device, Device with the highest / lowest number of components, etc, etc.

Sample Results:

MP3 Player Cost:             $580.39
Smart Phone Cost:            $510.93
Digital Watch Cost:          $495.99
Tablet Cost:                 $643.17
Portable Gaming System Cost: $485.17

Highest Cost Device:   Tablet
Lowest Cost Device:    Portable Gaming System
0 0
Add a comment Improve this question Transcribed image text
Answer #1

code:

//*******************************************************************
// Dear CompileJava users,
//
// CompileJava has been operating since 2013 completely free. If you
// find this site useful, or would otherwise like to contribute, then
// please consider a donation (link in 'More Info' tab) to support
// development of the new CompileJava website (stay tuned!).
//
// Most sincerely, Z.
//*******************************************************************

import java.lang.Math; // headers MUST be above the first class
import java.util.Scanner; ;
// one class needs to have a main() method
public class HelloWorld
{
// arguments are passed using the text field below this editor
public static void main(String[] args)
{
double[][] comp = new double[5][7] ;
String[] devices = new String[5];
double[] cost = new double[7];
System.out.println("enter componenents info");
int i=0;
int j=7;
Scanner sc=new Scanner(System.in);
for(i=0;i<5;i++)
{
for(j=0;j<7;j++)
{
comp[i][j]=sc.nextDouble();
}
}
System.out.println("enter products info");
for(i=0;i<5;i++)
devices[i]=sc.next();
System.out.println("enter component cost info");
for(i=0;i<7;i++)
cost[i]=sc.nextDouble();
double[] man_cost = new double[5];
int high=0;
int low=0;
for(i=0;i<5;i++)
{
man_cost[i]=0;
for(j=0;j<7;j++)
{
man_cost[i]+=man_cost[i]+(comp[i][j]*cost[j]);
}
if(man_cost[i]>high)
high=i;
if(man_cost[i]<low)
low=i;
}
for(i=0;i<5;i++)
{
System.out.println("device name: "+devices[i]);
System.out.println("cost: "+man_cost[i]);
}
System.out.println("highest cost device: "+ devices[high]);
System.out.println("lowest cost device: "+ devices[low]);
  
}
}

// you can add other public classes to this editor in any order

Add a comment
Know the answer?
Add Answer to:
In Java: A company manufactures 5 different devices and each device is built using a varying...
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
  • Code in Java using ( NetBeans ) Chapter 7 Assignment (Popular Candy) - 15 points Your...

    Code in Java using ( NetBeans ) Chapter 7 Assignment (Popular Candy) - 15 points Your goal is to record the sales for 4 different types of candy and determine the total sales and the names of the highest and lowest selling candies. . . Create a String array that stores four different types of candy. Pick whatever candy you would like. (3 points) Have the program prompt the user to enter the number of candy boxes sold for each...

  • Please use pseudocode for this response, any additional advice for making this as easy to understand...

    Please use pseudocode for this response, any additional advice for making this as easy to understand as possible is greatly appreciated. Problem Statement Assume the Scores array is parallel to the Players array (both arrays are below). Scores array Scores[0] = 198 Scores[1] = 486 Scores[2] = 651 Scores[3] = 185 Scores[4] = 216 Scores[5] = 912 Scores[6] = 173 Scores[7] = 319 Scores[8] = 846 Scores[9] = 989 Players Array Players[0] = "Joe" Players[1] = "Ann" Players[2] = "Marty"...

  • Part I Short Answer (50 points) 1. Write a pseudocode declaration for a String array initialized...

    Part I Short Answer (50 points) 1. Write a pseudocode declaration for a String array initialized with the following strings: “Einstein”, “Newton”, “Copernicus”, and “Kepler”. 2. Assume names in an Integer array with 20 elements. Write a pseudocode algorithm a For Loop that displays each element of the array. 3. Assume the arrays numberArray1 and numberArray2 each have 100 elements. Write a pseudocode algorithm that copies the values in numberArray1 to numberArray2 . 4. Write a pseudocode algorithm for a...

  • C++ Purpose: To practice arrays of records, and stepwise program development. 1. Define a record data...

    C++ Purpose: To practice arrays of records, and stepwise program development. 1. Define a record data type for a single playing card. A playing card has a suit ('H','D','S',or 'C'), and a value (1 through 13). Your record data type should have two fields: a suit field of type char, and a value field of type int. 2. In main(), declare an array with space for 52 records, representing a deck of playing cards. 3. Define a function called initialize()...

  • write this program in Java Problem 5. (30 Points) Write a program that reads employee work...

    write this program in Java Problem 5. (30 Points) Write a program that reads employee work data from a text file employee.txt), and then calculates payroll information based on this file and store them into a new text file called payroll.txt. The employee. txt file contains one line of text for each employee. Each line consists of the following data (delimited by tabs): employee's name, employee's hourly wage rate, hours worked Monday, hours worked Tuesday, hours worked Wednesday, hours worked...

  • JAVA Using the data provided in the attachment, create a program that will display a child's...

    JAVA Using the data provided in the attachment, create a program that will display a child's predicted adult height. This program will need to create an array of objects to search. This program needs to validate the input for valid range and input values. If invalid data is given, the program needs to indicate that data is invalid and suggest appropriate values/ranges. However, you do not need to validate alphabetic data given for numeric input. 1. The program will need...

  • CIS 22A C++ Project Exam Statistics Here is what your program will do: first it welcomes...

    CIS 22A C++ Project Exam Statistics Here is what your program will do: first it welcomes the user and displays the purpose of the program. It then prompts the user to enter the name of an input file (such as scores.txt). Assume the file contains the scores of the final exams; each score is preceded by a 5 characters student id. Create the input file: copy and paste the following data into a new text file named scores.txt DH232 89...

  • using java Program: Please read the complete prompt before going into coding. Write a program that...

    using java Program: Please read the complete prompt before going into coding. Write a program that handles the gradebook for the instructor. You must use a 2D array when storing the gradebook. The student ID as well as all grades should be of type int. To make the test process easy, generate the grade with random numbers. For this purpose, create a method that asks the user to enter how many students there are in the classroom. Then, in each...

  • Qn 1. A gaming company consists of many kind of games and each customer orders online to buy a ga...

    WRITE A C PROGRAM PLEASE WRITE COMMENTS EXPLAINING THE PROGRAM THANKS Qn 1. A gaming company consists of many kind of games and each customer orders online to buy a game. The gaming company will search for the specific game upon customers request in the order of first come first served basis. The gaming company has the following requirements. (10marks) 1. There are many kinds of games available (at least ten). They may have more than one game for each...

  • PROGRAMMING

    Consider the following program that reads students’ test scores into an array and prints the contents of the array.   You will add more functions to the program.  The instructions are given below.For each of the following exercises, write a function and make the appropriate function call in main.Comments are to be added in the program. 1.       Write a void function to find the average test score for each student and store in an array studentAvgs. void AverageScores( const int scores[][MAX_TESTS],                       int...

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