Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip> //std::setprecision
- using namespace std;
- int main()
- {
- float a;
- int b;
- float x;
- cout << "Enter the price of item: ";
- cin >> a;
- if (a > 0){
- int c = (int)a;
- cout << "\nEnter the number of items bought: ";
- cin >> b;
- if (b > 0){
- float d = (a - c)*100;
- int y = d;
- cout << "\n\nPrice of item is " << c << " ringgit and ";
- cout << fixed << setprecision(2) << y << " cents "<< endl;
- cout << "Number of items bought is " << b << endl;
- x = a*b;
- cout << "Total amount to be paid is " << x << endl;
- }
- else if (b < 0){
- cout << "Cmon, buy something...\n";
- }
- else
- {
- cout << "Enter a valid number geez\n";
- }
- }
- else {
- cout << "Enter a valid number geez\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement