Intro To Programming...need Advice Plz

This is a discussion on Intro To Programming...need Advice Plz within the C++ Programming forums, part of the General Programming Boards category; i have to write a code that gives total cost of movie tickets and here is what i did..and i ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    1

    Intro To Programming...need Advice Plz

    i have to write a code that gives total cost of movie tickets
    and here is what i did..and i dont get what to do..it just don't work..keep giving wrong answer..could somebody please solve this screwed code..
    ===================================
    #include <stdio.h>

    void main()
    {
    int x;
    int numberOfTicketA,numberOfTicketC,numberOfTicketS;
    int adult=12.50;
    int child=8.00;
    int senior=6.00;
    int calcTotal = (numberOfTicketA*adult)+(numberOfTicket*child)+(nu mberOfTicketS*senior);

    printf("Select the tickets you want to buy: \n1 adult\n2 child\n3 senior \n4 get total amount);
    scanf("%d",&x);

    do
    {
    if (x==1)
    {
    printf("Enter the number of tickets you wish to buy");
    scanf("%d",&numberofTicketA);
    }

    else if(x==2)
    {
    printf("Enter the number of tickets you wish to buy");
    scanf("%d",&numberOfTicketC);
    }
    else if(x==3)
    {
    printf("Enter the number of tickets you wish to buy");
    scanf("%d",numberOfTicketS);
    }
    while(x==1||x==2||x==3);
    }
    if(x==4)
    {
    Printf("The total cost is $%d",&calcTotal);
    }
    else
    {
    printf("Error");
    }
    }

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    221
    change the Printf("The total cost is $%d",&calcTotal);
    to
    printf("The total cost is %d",calcTotal);

    and try it out
    i didnt go through ur entire code, but i KNOW u dont wanna display the memory address of the variable

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    223

    c instead of c++

    It appears that this post should be posted in the c programming section and not the c++ programming section.
    zMan

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can any1 plz make this assignment
    By jean in forum C Programming
    Replies: 17
    Last Post: 05-13-2009, 10:19 PM
  2. Advice on C Programming with MSVC++ 2008
    By IT_Guy in forum Windows Programming
    Replies: 1
    Last Post: 03-06-2009, 04:23 AM
  3. [Request] Need Help Plz
    By TylerD in forum Tech Board
    Replies: 4
    Last Post: 01-03-2009, 09:54 AM
  4. girl friend advice (prob. the wrong place)
    By B0bDole in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 10-22-2004, 07:38 PM
  5. laptop specs, plz advice
    By GanglyLamb in forum Tech Board
    Replies: 5
    Last Post: 04-29-2003, 05:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21