Answer to Question #307885 in C for Joyce

Question #307885

While purchasing certain items, a discount of 10% is offered if the quantity


purchased is more than 1000. If quantity and price per item are input through the


keyboard, write a program and a flowchart to calculate the total expenses.

1
Expert's answer
2022-03-08T13:07:00-0500
#include <stdio.h>


int main() {
    int quantity;
    double price;
    double total_expense;
    double discount;


    printf("How many items do you want to purchase: ");
    scanf("%d", &quantity);
    printf("Enter a price per item: ");
    scanf("%lf", &price);


    total_expense = quantity * price;
    if (quantity > 1000) {
        discount = 0.1 * total_expense;
        total_expense -= discount;
    }


    printf("The total expense is %.lf\n", total_expense);


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS