Thread: Question about the selections

  1. #1
    Registered User
    Join Date
    Jul 2014
    Posts
    7

    Question Question about the selections

    Hi. I am practicing how to write information. However, I don't know why it's not working, when I chose the selection 2,3 and 4. Please help.
    Code:
    #include <stdio.h>
    #define Quit 5
    int get_menu_choice();
    void print_report_1();
    void check_out_your_balance();
    void Talking_with_the_customer_service();
    
    
    unsigned long long b;
    unsigned int a;
    int main()
    {
    	printf("Welcome\n");
    	printf("Please choose the options below.\n");
    	printf("Here are the options you can choose from the list:\n");
    	int choice=0;
    	choice=get_menu_choice();
    	while(choice!=5)
    	{
    		if (choice==1)
    		printf("Please enter your ten digit phone number\n");
    		scanf("%d", &a);
    		printf("How about successful. Thanks for shopping\n");
    	
    	{if (choice==2)
    		 
     		 print_report_1();}
    		
    	{if (choice==3)
    		   check_out_your_balance();}
     
          {if (choice==4)
              Talking_with_the_customer_service();}
    	}
    	printf("You chose to quite. Thanks for shopping. \n");
    	return 0;
    }
    int get_menu_choice()
    {
    	int selection=0;
    	do{
    		printf("\n");
    		printf("1-Renew your phone number\n");
    		printf("2-Pay with your debit or credit card\n");
    		printf("3-Check out your balance\n");
    		printf("4-Talking with the customer service\n");
    		printf("5-Quit\n");
    		printf("\n");
    		printf("Please enter a selection:");
    		scanf("%d", &selection);
    	   }
        	while(selection<1||selection>5);
        	return selection;
    }
    void print_report_1()
    {
    	printf("Please enter your debit card or cedit number");
    	scanf("%d", &b);
    	printf("You entered %d", b);
    	printf("How about successful. Thanks for shopping.");
    	return;
    }
    void check_out_your_balance()
    {
    	printf("\n Account Balance");
    	printf("\nDate\t\tBalance");
    	printf("\n====\t=======");
    	printf("\n06/13/2014\t$52.5");
    	printf("\n07/14/2014\t$38.5");
    	printf("\n08/10/2014\t$56.1");
    	printf("\n09/15/2014\tUNPAID");
    	printf("\n__________\t_______");
    	return;
    }
    void Talking_with_the_customer_service()
    {
    	printf("Our working hour is 8a.m to 6p.m");
    	printf("Please leave your phone number and we will contact you as well");
    	scanf("%d", &a);
    	printf("Thank you.");
    	
    }

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Read this FAQ If Statements in C - Cprogramming.com

    Pay attention to how braces are used!

    Code:
    if ( TRUE ) {
        /* between the braces is the body of the if statement */
        Execute all statements inside the body
    }
    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  3. #3
    Registered User
    Join Date
    Jul 2014
    Posts
    7
    Got it. Thanks for your help.

  4. #4
    Registered User
    Join Date
    Apr 2011
    Location
    dust
    Posts
    70
    Code:
    while(selection<1||selection>5);
    Is it valid as per your requirement?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Counting the number of case selections in a menu
    By ZeroDivision in forum C Programming
    Replies: 2
    Last Post: 09-20-2013, 05:47 PM
  2. Menu Selections in a command prompt
    By Shamino in forum C++ Programming
    Replies: 5
    Last Post: 01-24-2012, 12:45 PM
  3. Replies: 1
    Last Post: 03-23-2011, 09:00 AM
  4. making selections from a struct
    By Npratt23 in forum C++ Programming
    Replies: 10
    Last Post: 05-12-2005, 11:36 AM
  5. Help with menu and integer selections
    By EliasK in forum C Programming
    Replies: 2
    Last Post: 04-03-2003, 09:35 AM