#include <iostream>
#include <iomanip> //std::setprecision
using namespace std;
int main()
{
float price;
int item;
int temp;
float total;
cout << "Enter the price of item: ";
cin >> price;
if (price > 0){
temp = price;
cout << "\nEnter the number of items bought: ";
cin >> item;
if (item > 0){
float total = price - temp;
cout << "\n\nPrice of item is " << temp << " and ";
cout << fixed << setprecision(2) << total << endl;
cout << "Number of items bought is " << item << endl;
total = price*item;
cout << "Total amount to be paid is " << total << endl;
}
else if (item < 0){
cout << "Buy something dude \n";
}
else
{
cout << "Enter a valid number \n";
}
}
else {
cout << "Enter a valid number \n";
}
return 0;
}
Comments