Question

I need help solving problem 9.16 from matlab for engineers holly moore 4th edition % 9.16...

I need help solving problem 9.16 from matlab for engineers holly moore 4th edition

% 9.16 A store owner asks you to write a program for use in the checkout process.
% The program should:
% • Prompt the user to enter the cost of the first item.
% • Continue to prompt for additional items, until the user enters 0.
% • Display the total.
% • Prompt for the dollar amount the customer submits as payment.
% • Display the change due.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

prompt = 'Enter the cost of the item : '; %asking the use to enter the cost of the item
x = input(prompt); % taking the cost of the item as input and assigning it to x
TotalAmount=x;%initializing the total cost with value x
while x != 0 % condition till the items cost is not zero
prompt = 'Enter the cost of the item : '; %asking for the cost of the item
x = input(prompt); %taking the item cost as input fromt the user
TotalAmount=TotalAmount+x; % adding the cost value to the total sum
end
fprintf('Total Amount is $%.2f\n',TotalAmount);%displaying the total amount of all the items
prompt = 'Enter dollar amount customer submitted as payment : '; %asking the user to enter the dollor amount customer submitted for the paymet
camount = input(prompt);%taking the dollar amount customer submitted as input
change = camount - TotalAmount; % calcultaing the change
fprintf('Total change is $%.2f\n',change);%displaying the change value

Input

Output :

Please let me know if anything is required.

Add a comment
Know the answer?
Add Answer to:
I need help solving problem 9.16 from matlab for engineers holly moore 4th edition % 9.16...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Looking for code in MATLAB: A store owner asks you to write a program for use...

    Looking for code in MATLAB: A store owner asks you to write a program for use in the checkout process. The program should: Prompt the user to enter the cost of the first item Continue to prompt for additional items, until the user enters 0 Display the total. Prompt for the dollar amount the customer submits as payment. Display the change due.

  • Need help creating a program from C++ for engineers 4th edition. Pg 200 #8 (Fluid Mechanics)...

    Need help creating a program from C++ for engineers 4th edition. Pg 200 #8 (Fluid Mechanics) A fluid particles following through a pipe can flow in a smooth, constant manner, called laminar flow; in a chaotic manner, called turbulent flow; or in an intermediate transitional stage between smooth and turbulent flow. As a practical design parametter, the Reyolds number can be used to determined the type of flow. For reynolds number below 2000, the flow is laminar and for reynolds...

  • I need help solving these questions,please don’t know how to solve it by using matlab.!

    i need help solving these questions,please don’t know how to solve it by using matlab.! Solve the following questions Ol: You are required to develop a script to calculate the volume of a pyramid, which is 1/3 *base *height, where the base is length *width. Prompt the user to enter values for the length, width, and height, and then calculate the volume of the pyramid. When the user enters each value, he or she will then also be prompted to...

  • This is a matlab HW that I need the code for, if someone could help me figure this out it would b...

    This is a matlab HW that I need the code for, if someone could help me figure this out it would be appreciated. The value of t can be estimated from the following equation: in your script file, estimate the value of π for any number of terms. You must ask the user for the desired number of terms and calculate the absolute error/difference between your calculation and the built-in MATLAB value ofpi. Display your results with the following message...

  • I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7:...

    I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7: Customer Accounts Write a program that uses a structure to store the following data about a customer account:      Customer name      Customer address      City      State      ZIP code      Telephone      Account balance      Date of last payment The program should use an array of at least 20 structures. It should let the user enter data into the array, change the contents of any element, and display all the...

  • Help Please on JAVA Project: Validating the input is where I need help. Thank you Requirements...

    Help Please on JAVA Project: Validating the input is where I need help. Thank you Requirements description: Assume you work part-time at a sandwich store. As the only employee who knows java programming, you help to write a sandwich ordering application for the store. The following is a brief requirement description with some sample output. 1. Selecting bread When the program starts, it first shows a list/menu of sandwich breads and their prices, then asks a user to select a...

  • Overview JAVA LANGUAGE PROBLEM: The owner of a restaurant wants a program to manage online orders...

    Overview JAVA LANGUAGE PROBLEM: The owner of a restaurant wants a program to manage online orders that come in. This program will require multiple classes. Summary class, customer class, order class and the driver class. Summary class This class will keep track of the cost of the order and output a summary, which includes the total for the order. The methods in this class are static. There are no instance variables, and instead uses an Order object that is passed...

  • I need help with this assignment, can someone HELP ? This is the assignment: Online shopping...

    I need help with this assignment, can someone HELP ? This is the assignment: Online shopping cart (continued) (C++) This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class per the following specifications: Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt) Public member functions SetDescription() mutator & GetDescription() accessor (2 pts) PrintItemCost() - Outputs the item name followed by...

  • Need three seperate files. ShoppingCartManager.java ShoppingCart.java ItemsToPurchase.java These are from part 1 what do you mean...

    Need three seperate files. ShoppingCartManager.java ShoppingCart.java ItemsToPurchase.java These are from part 1 what do you mean by deep study 7.25 LAB*: Program: Online shopping cart (Part 2) Note: Creating multiple Scanner objects for the same input stream yields unexpected behavior. Thus, good practice is to use a single Scanner object for reading input from System.in. That Scanner object can be passed as an argument to any methods that read input This program extends the earlier Online shopping cart program (Consider...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT