Answer to Question #254583 in C++ for mela

Question #254583

input price & quantity.if net price is greater than 10000 the discount is 10%.if we enter -1 as the price then the code must stop and calculate the net price


1
Expert's answer
2021-10-21T16:06:50-0400
#include <iostream>
using namespace std;
int main(){
    float price = 0, net_price, p;
    int quantity = 1;
    do{
        cout<<"Input price: \n";
        cin>>p;
        if(p != -1) price = p;
        else break;
        if(price > 10000) price *= 0.9;
        cout<<"Input quantity: \n";
        cin>>quantity;
        net_price = price / quantity;
    }while(p != -1);
    cout<<"Net price = "<<net_price<<endl;
    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