Trying to create a little selling simulator program for school

Viewed 33

So the thing is I gotta make a program where the user decides what merch to buy based on a prod.code then he has to decide the quantity of prod to buy and which payment method he goin for. If the payment method decided is by cash then 10% off of the tot price else if the payment method is by installments then the tot prices goes up by 15% Problem is that I got 3 cases (reason why I'm tryna use the switch). Bigger problem is that I don't have the time (as user) to give x input that the program has already finished ...

Part of the code is here:

#include<stdlib.h>
#include<stdio.h>
#include<string.h>

int main(void){
    int codmer,qta,przpz,pagamento,tot,sel;
    char desc[5] = "arma";
    char risp;
    
    printf("Tipologia prodotti disponibili = %c\n",desc);
    printf("\nInserisci il codice merce per il prodotto che si desidera acquistare ");
    printf("\n 100 = 9mm.Parabellum  | 47 = AK-47  | 8 = Revolver Magnum .38\n");
    scanf("%d ",&codmer);
    switch(codmer){
        case 100:
            printf("La Parabellum ha un prezzo di 1215$ ");
            przpz = 1215;
            printf("Desideri acquistare? ");
            scanf("%c",&risp);
            if(risp=='s'||'S'||'y'||'Y'){
                printf("Quante ne desideri comprare? ");
                scanf("%d",&qta);
                tot=przpz*qta;
                printf("Il totale da pagare e' %d",tot);
                printf("Desidera pagare in contanti (1) o a rate(2)? ");
                scanf("%d",&pagamento);
                if(pagamento==1){
                    tot=tot-(przpz/100*10);
                    printf("Il prezzo per il pagamento in contanti e' di %d $",tot);
                    printf("Grazie per il suo acquisto.");
                }else{
                    tot=tot+(przpz/100*15);
                    printf("Il prezzo per il pagamento a rate e' di %d $",tot);
                    printf("Grazie per il suo acquisto.");
                }
            }else{
                system("pause");
                return 0;
            }
           }
 system("pause");
 return 0;
}

Please let me know what I'm doin' wrong... I don't want no easy answers but if you can simply explain me I'd be real grateful since it is an homework and I got a deadline :sad:

0 Answers
Related