66 926
Assignments Done
99,1%
Successfully Done
In October 2018

Answer to Question #28263 in Action Script | Flash | Flex | ColdFusion for alaa

Question #28263
Write a C++ program that asks for the title of the book, the price of the book and the quantity to buy for the book. Print out the title of the book. If a 20% discount is provided for buying the book, calculate and print out the discounted price for the book. Also, calculate and print out the total cost for buying the books at the discounted price.
Expert's answer
#include <iostream>
#include <string>
#include <conio.h>

using namespace std;
//main function
int main()
{
string title;// book title
float price;// book price
int quantity;// book quantity
char ch;//choice
//input
cout<<"Enter the title of the book: ";
cin>>title;
cout<<"Enter the price of the book: ";
cin>>price;
cout<<"Enter the quantity to buy for the book: ";
cin>>quantity;
cout<<"Is 20% discount is provided for buying the book? (y/n)";
cin>>ch;
if(ch=='y'){//Is 20% discount is provided for buying the book
price=price-price*0.2;
double discountedprice=price*quantity;
//show result
cout<<title<<" discounted price for this book is
"<<price<<"
the total cost for buying the books at the
discounted price is $"<<discountedprice;
}else{//not 20% discount is provided for buying the book
//show result
double discountedprice=price*quantity;
cout<<title<<" price for this book is
"<<price<<"
the total cost for buying the books at this
price is $"<<discountedprice;
}

int c;
cin>>c;
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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions