Pia tunatoa huduma zifuatazo.

Tunatengeneza blogu, tovuti(website), youtube chaneli n.k.. Mawasiliano:
simu:+255763670000, Barua pepe: khalfanm021@gmail.com

Saturday, September 15, 2018

Question 4: Write c++ program compute amount (expenses) that will be paid by customer


Question 4: While purchasing C++ programming books at the STC Bookstore discount of 12.5% is offered if the number of books purchased is more than 1000.if the number of book and price per book are input through keyboard
Write c++ program compute amount (expenses) that will be paid by customer
HINT: provide your answer in two decimal places

Solution

#include<iostream>
using namespace std;
int main(){
int n,price,the_discount,n_price;
const float DISCOUNT = 0.125; /*This is equal to 12.5%*/
cout<<"Enter the number of books to be sold\n";
cin>>n;
cout<<"Enter the price per book to be sold\n";
cin>>price;
if(n >= 1000){
the_discount = price * DISCOUNT;
n_price = price - the_discount;
cout<<"Total books: "<<n<<endl;
cout<<"Original price per book: "<<price<<endl;
cout<<"Price after discount: "<<n_price<<"\n\n";
cout<<"Total costs: "<<(n_price*n)<<".00"<<endl;
}else{
cout<<"Total books: "<<n<<endl;
cout<<"Original price per book: "<<price<<endl;
cout<<"Price after discount: "<<"No discount"<<"\n\n";
cout<<"Total costs: "<<(price*n)<<".00"<<endl;
}
return 0;
}


PLEASE LEAVE A COMMENT, OR ANY OTHER QUESTIONS INVOLVING ANY OF THE FOLLOWING LANGUAGES, C++, PHP, JAVASCRRIPT, HTML, CSS, MYSQL

No comments:

Post a Comment