Thread: market program please help

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    64

    market program please help

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    
    int main(){
    char choice,shopping=1;
    int x,sugar=350,jam=250,shampoo=199,bread=50 ,eggs=90,subtotal1=0,subtotal2=0,subtotal3=0,subtotal4=0,subtotal5=0,total;
    
    while(shopping)
    {printf("WELCOME TO NUST DHABBA\n");
    printf("World's biggest Departmental store\n");
    printf("Enter choice\n");
    printf("[1] for 1 kg sugar bag\n");
    printf("[2] for Jam\n");
    printf("[3] for XYZ Shampoo\n");
    printf("[4] for Bread\n");
    printf("[5] for 1 dozen eggs\n");
    printf("[q] to quit shoping\n");
    total=subtotal1+subtotal2+subtotal3+subtotal4+subtotal5;
    choice=getch();
    
    if((choice=='q')||(choice=='Q'))
    exit(0);
    
    if(choice=='1') {
    printf("shopped:1 kg sugar bag=350 rupees\n",sugar);
    printf("how many?\n",x);
    scanf("%d",&x);
    subtotal1=sugar*x;
    printf("Sub total:sugar=%d\n",subtotal1);
    getch();
    }
    if(choice=='2'){
    printf("Shopped:Jam=250\n",jam);
    printf("How many?\n",x);
    scanf("%d",&x);
    subtotal2=jam*x;
    printf("Sub total:Jam=%d\n",subtotal2);
    getch ();
    }
    if(choice=='3') {
    
    printf("shopped:XYZ shampoo\n",shampoo);
    printf("How many?\n",x);
    scanf("%d",&x);
    subtotal3=shampoo*x;
    printf("Sub total:shampoo=%d\n",subtotal3);
    getch ();
    }
    if(choice=='4'){
    printf("Shopped:Bread\n",bread);
    printf("How many?\n",x);
    scanf("%d",&x);
    subtotal4=bread*x;
    printf("Sub total:Bread=%d\n",subtotal4);
    
    }
    if(choice=='5') {
    
    printf("shopped:dozen eggs\n",shampoo);
    printf("How many dozens you want?\n",x);
    scanf("%d",&x);
    subtotal5=eggs*x;
    printf("Sub total:eggs=%d\n",subtotal5);
    getch();}
    printf("Do you want to shop more Y/N?\n");
    if ((choice!='y'))
    shopping=1;
    total=subtotal1+subtotal2+subtotal3+subtotal4+subtotal5;
    printf("Total is %d\n",total);
    getch ();
    }
    }
    when the user press 'q' this program prints "do you want to shop more?" but i want that the program always ask itself about shopping more.how to do it?
    moreover,any suggestions to make it more simple and it uses lesser space.
    Last edited by danishzaidi; 11-09-2011 at 03:29 AM.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Moved to C board

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. a program for a super market!
    By danishzaidi in forum C Programming
    Replies: 5
    Last Post: 11-09-2011, 12:51 PM
  2. Market Needs
    By Smeagol in forum C++ Programming
    Replies: 14
    Last Post: 05-29-2006, 03:06 PM
  3. All Kind Articles on Job Market (FYI)
    By alphaoide in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 02-02-2005, 01:23 PM
  4. Items with a HOT market
    By holden in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 09-06-2004, 10:27 PM
  5. Stock market
    By Liger86 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 05-20-2003, 05:12 PM