23.6k views
0 votes
The 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.

User Feskr
by
5.1k points

1 Answer

2 votes

Answer:

Check the explanation

Step-by-step explanation:

Cube.m:

mass = input("Enter the mass of cube [kilograms]: ");

if(mass<=0)

disp("Error: Mass must be greater than zero grams")

else

fprintf("The length of one side of cube is %.2f inches",2.7*mass);

end

Output1

octave:2> source ( Cube.m Enter the mass of cube [kilograms]: octave:2>-3 Error: Mass must be greater than zero grams

User Hamster Ham
by
5.1k points