lundi 14 décembre 2015

breaking out of if-statement

When the user enters Y for Yes The program would break out from the IF statement Then the program will ask for the next food "pick food: " If the user enter N for No The program will print out the total price for all the food chosen

p("[1] Spinach\n");
    p("[2] Romaine\n");
    p("[3] Mustard\n");
    p("[4] Carrots\n");
    p("[5] Potato\n");
    p("[6] Yam\n");
    p("[7] Asparagus\n");
    p("[8] Brocolli\n");
    p("[9] Melon\n");
    p("[10] Strawberry\n");

    do{
    p("Pick food: ");
    s("%d",&choice);
    if(choice == 1){
        p("\n\nHow many grams of Spinach? ");
        s("%f",&spinach);
        spinachT+=spinach*spinachP;
        p("\nPrice: P %.2f",spinachT);

        p("Enter again?");
        s("%s", &yn);
        if(strcmp(yn, "y")==0){
            ??? enter again new food
        }else{
            ??? stop print price
        }
        }
    }while(choice == 11);
}

Aucun commentaire:

Enregistrer un commentaire