A tank contains 400 liters of brine holding 100 kg of salt in solution [Solved]

Question 1


Question 2

A tank contains 400 liters of brine holding 100 kg of salt in solution. Water containing 125g of salt per liter flows into the tank at the rate of 12 liters per minute, and the mixture, kept uniform by stirring, flows out at the same rate. Find the amount of salt at the end of 90 minutes.
Question 3

Write a complete Java program called Scorer that declares and initializes a 2-dimensional array of doubles, 3 rows and 3 columns (remember: this is a table, not a list). Populate the array with input from the user at the command line. Compute the average of the values in each of the three rows and output the three averages to the command line, each on a separate line. Java Arrays and the java.util.Scanner class: Java arrays is a simple way to store a collection of data in rows and columns. The most common way to access the elements of a two dimensional Java array is to use two variables to index rows and columns. The java.util.Scanner class is a convenient way to read user input and convert them automatically to a wide variety of supported data types. We will use this class in this example to read user input from command line.


Answer to question 1


Answer to question 2


Answer to question 3

  1. import java.util.Scanner;
  2. public class Scorer
  3. {
  4. public static void main(String args[])
  5. {
  6. double arr[][] = new double[3][3]; // initialize the array
  7. Scanner input = new Scanner(System.in);
  8. int row, col;
  9. System.out.println(“Enter nine doubles:”);
  10. for (row=0; row<3; ++row)
  11. {
  12. for (col=0; col<3; ++col)
  13. {
  14. if (input.hasNextDouble())
  15. arr[row][col] = input.nextDouble();
  16. }
  17. }
  18. System.out.println(“Averages of each rows:”);
  19. for (row=0; row<3; ++row)
  20. {
  21. double sum = 0;
  22. for (col=0; col<3; ++col)
  23. {
  24. sum += arr[row][col];
  25. }
  26. System.out.println(sum / 3); // output the average
  27. }
  28. }
  29. }


Enter nine doubles:

1 2 3

4 5 6

7 8 9

Averages of each rows:

2.0

5.0

8.0

Leave a Comment