What's new

IF ELSE STATEMENT PA HELP

Yukihiro Rubio

Forum Veteran
Joined
Sep 17, 2018
Posts
780
Solutions
4
Reaction
5,015
Points
889
Age
21
[1] Shirt
[2] Shoes

Enter Your Choice: 1

Enter Color of the Shirt: White (w) = 150 , Black (b) = 200: w

Your Choose White!!
Enter Quantity: 5

add to cart or buy (c/b)?: c

Order is added to cart

==========================

[1] Shirt
[2] Shoes
Enter Your Choice: 1

Enter Color of the Shirt: White (w) = 150 , Black (b) = 200: b

Your Choose Black!!
Enter Quantity: 5

add to cart or buy (c/b)?: b

Quantity is: 5
Color: Black
The Total is: 1000
Congrats! You'll get 10% discount on total Shopping amount
You've to Pay Only: 900

Note: color should be fix to w and b. if enter other character tell the user that he input invalid color code.

Note: if the total is greater than equal to 1000 give him a discount of 10% if the total is less than 1000 give him 5% discount

formula:

Variable = (variable*10)/100;
variable = variable-variable;



*****************************************************

choice number 2 shoes

[1] Shirt
[2] Shoes..... 300
Enter Your Choice: 2

We have only 1 pair of shoes, Proceed (y/n)? y

Enter Shoe Details...
Enter Color ( white , Black , Purple, Pink): white ( JUST INPUT. NO ELS)
Enter Size (S, M, L, XL): s ( JUST INPUT. NO ELSE)

Price is: 300
Quantity: 15
The total is: 4500
Enter your Money: 4500
Change is: 0

Your are eligible in our discount 10%, avail (y/n)?: y
Total amount to be ρáíd is: 4050

Note: money should have a feature that tells the money is insufficient.

Note: discount should be apply only when the amount is greater than or equal to 1500, otherwise they cant avail it.


NOTE: ALL THE OPTIONS THAT ASK FOR THE USER SHOULD HAVE AN ELSE STATEMENT THAT TELLS THE USER INVALID.


Formula:

variable = (variable *10 )/100;
variable = variable - variable;
 
C++:
#include <iostream>
using namespace std;

int main() {
    int s_white = 150;
    int s_black = 200;
    cout << "[1] Shirt\n[2] Shoes\n\n";
    int item;
    cout << "Enter your choice: ";
    cin >> item;
    if(item == 1){
        string color;
        cout << "\nEnter color of the shirt [White (w) = 150; Black (b) = 200]: ";
        cin >> color;
        if(color == "w"){
            cout << "\nYou Choose White!!";
            int quantity;
            cout << "\nEnter Quantity: ";
            cin >> quantity;
            string choice;
            cout << "Add to cart or buy (c/b)?: ";
            cin >> choice;
            if(choice == "c"){
                cout << "Order is added to cart.";
            } else if(choice == "b"){
                //ikaw na magtuloy, kaya mo yan
            } else {
                cout << "Invalid Choice! Exiting..";
            }
        } else if(color == "b") {
            cout << "\nYou Choose Black!!";
            int quantity;
            cout << "\nEnter Quantity: ";
            cin >> quantity;
            string choice;
            cout << "Add to cart or buy (c/b)?: ";
            cin >> choice;
            if(choice == "c"){
                cout << "Order is added to cart.";
            } else if(choice == "b"){
                //ikaw na magtuloy, kaya mo yan
            } else {
                cout << "Invalid Choice! Exiting..";
            }
        } else {
            cout << "Invalid Choice! Exiting..";
        }
    } //else if() .... kaw na magtuloy kaya mo na yan
    return 0;
   
}

kaw na magtuloy lodi kaya mo na yan hahahahaha
 
Back
Top