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

Topics: Input and Output in MATLAB; Script .m files An online retailer has hired

ID: 670320 • Letter: T

Question

Topics: Input and Output in MATLAB; Script .m files An online retailer has hired you to write a MATLAB script to calculate the total cost of a customer's order. The customer may order notebooks or pencils. A notebook is sold for $1.33 and a pencil is sold for $0.25 cents. The shipping cost for the order is simply 8 percent of the total dollar amount of the order, as defined above. Outline: Display a short welcome message to the user Prompt the user to input the number of notebooks being ordered Prompt the user to input the number of pencils being ordered Compute the cost of all of the notebooks ordered Compute the cost of all of the pencils ordered Compute the subtotal of the order, the cost of all the notebooks and all the pencils Compute the shipping cost of the order Compute the total of the order, the subtotal plus the shipping cost Display a billing report, including all of the above indicated amounts, which is formatted in a logical and readable fashion Note(s): Your program should produce output identical (when given the same input(s) to the sample run(s) below, values and format.

Explanation / Answer

fprintf('Welcome to my shop ')

num_books = input('Enter the number of Notebooks: ');

num_pencils = input('Enter the number of Pencils: ');

cost_books = num_books * 1.33;

cost_pencils = num_pencils * 0.25;

sub_cost = cost_books + cost_pencils;

shipping_cost = sub_cost * 0.08;

total_cost = sub_cost + shipping_cost;

fprintf('Report ')

fprintf('----------------------------------------------- ')

fprintf('Number of Note books: %d ', num_books)

fprintf('Number of Pencils: %d ', num_pencils)

fprintf('Cost of note books: %d * 1.33 = %.2f ', num_books, cost_books)

fprintf('Cost of pencils: %d * 0.25 = %.2f ', num_pencils, cost_pencils)

fprintf('SubCost = %.2f ', sub_cost)

fprintf('Shipping Cost: 0.08 * %.2f = %.2f ', sub_cost, shipping_cost)

fprintf('Total cost: %.2f + %.2f = %.2f ', sub_cost, shipping_cost, total_cost)

fprintf('----------------------------------------------- ')

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