Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a MATLAB program code block that can generate a conversion table to conver

ID: 2324628 • Letter: W

Question

Write a MATLAB program code block that can generate a conversion table to convert Pounds to Kilograms. Allow the user to enter the starting value in pounds, the increment between lines in pounds, and the number of lines in the table. Recall that 1 lb = 0.45359 kg. Format the values displayed in the conversion table to display 2 digits after the decimal point.
(Example command window display)
Enter the starting value in pounds: 1
Enter the increment between lines in pounds: 2
Enter the number of lines to display in the table: 3

               lb kg
----------------------------------------------
         1.00 0.45
         3.00 1.36
         5.00 2.27

(Another example command window display)
Enter the starting value in pounds: 0.5
Enter the increment between lines in pounds: 0.1
Enter the number of lines to display in the table: 5

        lb    kg
----------------------------------------------
              0.50 0.23
              0.60 0.27
              0.70 0.32
              0.80 0.36
              0.90 0.41

Explanation / Answer

% Ask the user to input in pounds

pounds = input ('Enter the starting value in pounds :');

increment = input ('Enter the increment between lines in pounds :');

number_lines = input ('Enter the number of lines to display in the table :');

fprintf (' lb Kgs ');

x=0;

while x<number_lines

Kgs = 0.45359*pounds

  fprintf (' %f %f ', pounds, Kgs)

x=x+1

pounds = pounds + increment

end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote