Question

Please Answer Quickly Quantity discount program Write a MATLAB program that takes two inputs from the...

Please Answer Quickly

Quantity discount program Write a MATLAB program that takes two inputs from the user,

Input 1: a decimal number that is a unit price (the price of one item) in dollars and cents

Input 2: an integer that is the quantity of the item to purchase.

The program prints 3 outputs, each on its own line:

output 1: the total cost with no discount (unit price X quantity)

output 2: the amount of discount in dollars and cents

output 3: the total cost after discount

The discount is computed as described below, and is applied to the total before the discount.

Quantity less than 10, no discount.

Quantity 10 or more, but less than 100, 10% discount.

Quantity 100 or more, 20% discount.

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

`Hey,

Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.

clc
clear all
close all
format short
P=input('Enter unit price: $ ');
q=input('Enter quantity: ');
T=P*q;
fprintf('Total cost is $%f\n',T);
D=0;
if(q<10)
D=0;
elseif(q<100)
D=0.1*T;
else
D=0.2*T;
end
fprintf('Total amount of discount: $%f\n',D);
fprintf('Total cost after discount $%f\n',T-D);

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
Please Answer Quickly Quantity discount program Write a MATLAB program that takes two inputs from the...
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
  • Write a C++ program that calculates the discount of the original price of an item and...

    Write a C++ program that calculates the discount of the original price of an item and displays the new price, and the total amount of savings. This program should have a separate header (discount.h), implementation (discount.cpp) and application files (main.cpp). The program must also have user input: the user must be prompted to enter data (the original price, and the percent off as a percentage). There must also be a validation, for example: Output: “Enter the original price of the...

  • write a program in matlab to produce a discrete event simulation of a switching element with...

    write a program in matlab to produce a discrete event simulation of a switching element with 10 inputs and 3 outputs. Time is slotted on all inputs and outputs. Each input packet follows a Bernoulli process. In a given slot, the independent probability that a packet arrives in a slot is p and the probability that a slot is empty is (1– p). One packet fills one slot. For a switching element if 3 or less packets arrives to some...

  • 2. Write an Assembly program using Super Simple CPU Instruction set that takes input 3 numbers...

    2. Write an Assembly program using Super Simple CPU Instruction set that takes input 3 numbers from the user and outputs 1 in the output box if the sum of the first two inputs is greater than the sum of the last two inputs; otherwise it outputs o in the output box. Example1, if user inputs the numbers 10, (2.0), 11, (3.0), and 1,(1,2) then the output should be 1 (since 2.0 + 3., is greater than 3.. +1,). Example...

  • read instructions carefully please matlab only Write a MATLAB function for a BMI calculator that receives the inputs for body weight (lbs)and height (ft) from the user's program, calculates th...

    read instructions carefully please matlab only Write a MATLAB function for a BMI calculator that receives the inputs for body weight (lbs)and height (ft) from the user's program, calculates the BMI using the equation below, displays the BMI category, and outputs the BMI value tothe user's program W (kg) h2 (m2) BMI Display Normal if 18.5 s BMI 25 Display Overweight if 25 s BMI <30 Display Obese if BMI 2 30 Else display underweight So you will create two...

  • Part I Create a Java program that inputs a grade from the user. The grade input...

    Part I Create a Java program that inputs a grade from the user. The grade input from the user will be an integer. Once the input is stored, use an if-else-if block of code to determine the letter grade of the inputted integer grade. Do not use a bunch of if statements by themselves to solve this problem. You will print an error message for inputs greater than 100 and for inputs less than 0. Both errors must be handled...

  • Please write the script for following problem in MATLAB. Write a script with a file name...

    Please write the script for following problem in MATLAB. Write a script with a file name Problem3.m that, when executed, prints 1.99 dollars per unit. How many units will you purchase? [new line] Then control is given back to the user to input a scalar integer quantity. The script then prints out __ units at 1.99 dollars per unit is a total of ___ dollars. [new line] where the first blank is filled with whatever number was inputted by the...

  • Shopping Cart You are to write a program that reads the name of the item, the quantity of each it...

    C++ language Shopping Cart You are to write a program that reads the name of the item, the quantity of each item, and the cost per item from a file. The program will then print out the item and how much is owed for each item. After everything is read in, it will print out the total cost of the cart. Your program should have the following functions main - This function asks the user to enter a filename and...

  • Write a Java application that prompts the user for pairs of inputs of a product number...

    Write a Java application that prompts the user for pairs of inputs of a product number (1-5), and then an integer quantity of units sold (this is two separate prompts for input values). You must use a switch statement and a sentinel-controlled loop (i.e. a loop that stops execution when an out of range value, such as -1, is input). All 15 items below are for a single purchase. There are five sets of inputs as follows: Product 1    1...

  • Please use python to write the simple program. Exercise 2 - Summation Write a program to...

    Please use python to write the simple program. Exercise 2 - Summation Write a program to accept integer inputs until the user inputs a non-integer. Then, the program prints the summation of the inputted numbers. Hint: Use the function input() to get the user input. Use a variable total for calculating the summation. Need to use while loop for the repeated inputs. Use if statement with isdigit() function to check whether the user input is an integer or not. if...

  • USING C LANGUAGE Write a program that computes the total weight of a cargo. Ask the...

    USING C LANGUAGE Write a program that computes the total weight of a cargo. Ask the user to enter multiple inputs. For each input, the user indicate the weight and quantity of the boxes. The program computes and prints the total cargo weight The output should match the sample below. Make sure you print the input number (Input #1, Input #2,) 3 - Input # 1. Weight of the box (lbs): 4 Enter quantity: 2 Input #2. Weight of the...

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
ADVERTISEMENT