1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Novay_Z [31]
2 years ago
15

he specific gravity of gold is 19.3. Write a MATLAB program that will ask the user to input the mass of a cube of solid gold in

units of kilograms and display the length of a single side of the cube in units of inches. The output should display a sentence like the following one, with the length formatted to two decimal places.

Computers and Technology
1 answer:
Rama09 [41]2 years ago
4 0

Explanation:

Specific gravity of gold = G = 19.3

We know that the specific gravity of gold is given by

G = ρg/ρw

Where ρg is the density of gold and ρw is density of water which is 1000 kg/m³

Now we can find out the density of gold

ρg = G*ρw

ρg = 19.3*1000

ρg = 19300 kg/m³

We also know that density and mass are related as

density = mass/volume

ρg = m/V

where volume of cube is given by

V = s³

Where s is the length of each side

ρg = m/s³

s³ = m/ρg

s = ∛(m/ρg) meters

To convert from meters to inches multiply by 39.37

s = ∛(m/ρg)*39.37 inches

Finally we get the relation of mass and length of side of a gold cube.

Matlab Code:

density = 19300;

% get input from the user that is mass of gold in kg

mass= input('Please input mass of gold in kg\n');

% check if the user has entered valid mass if it is less than or equal to zero then display error

if (mass<=0)

fprintf('Error: Wrong input! please try again');

else

% If the mass is valid then calculate the length of side of the cube

s = (mass/density);

% nthroot() is used to calculate the cube root

s = nthroot(s,3);

% to convert from meters to inches

s = s*39.37;

% finally display the length with 2 decimal points accuracy

fprintf('The length of side of the gold cube is: %.2f inches\n', s);

end

Output:

Please input mass of gold in kg

-2

Error: Wrong input! please try again

Please input mass of gold in kg

0.4

The length of side of the gold cube is: 1.08 inches

You might be interested in
What should be done if a system cannot boot from the hard drive?
White raven [17]
If the system cannot boot from the hard drive, then you should boot from the windows set-up dvd

I hope this helps! :)
3 0
3 years ago
What does it mean to have liability for a company?
astraxan [27]

you can get tax identification number, open a bank account and do business all under its own name


3 0
2 years ago
Which shortcut keys can be used to duplicate a slide?
Leya [2.2K]

Answer:

Ctrl + D used to duplicate a slide

8 0
3 years ago
Assume that word is a variable of type String that has been assigned a value. Assume furthermore that this value always contains
Valentin [98]

Answer:

   String word = "George slew the dragon";

   

   int pos = word.indexOf("dr");    

   String drWord = word.substring(pos, pos+4);

   

   System.out.println(drWord);

Explanation:

Assuming dr is always there, we don't have to check the validity of 'pos'. Normally, you would!

5 0
3 years ago
Read 2 more answers
When working in Excel Online, what is it called when you drag the fill handle down to copy data?
SVEN [57.7K]
It’s called drag fill
5 0
3 years ago
Read 2 more answers
Other questions:
  • What is an example of asynchronous communication
    7·1 answer
  • If you delete a sent message on gmail does the person still get it
    14·1 answer
  • e do loop differs from the while loop in that a. the while loop will always execute the body of the loop at least once b. the do
    9·1 answer
  • Please Help!
    14·2 answers
  • Who found the first computer bug in 1947, and invented the concept of a compiler in 1952
    6·1 answer
  • Coral Given three floating-point numbers x, y, and z, output x to the power of y, x to the power of (y to the power of z), the a
    6·1 answer
  • Generalized goals are more likely to be achieved than specific goals. True or False
    7·1 answer
  • Which storage device is not recommended as a permanent storage solution?
    6·1 answer
  • Retype the below code. Fix the indentation as necessary to make the program work.
    13·1 answer
  • What is referential integrity
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!