Question

In: Computer Science

construct flow chart for c program #include <stdio.h> #include <stdlib.h> #include <math.h> void brst(); void thight();...

construct flow chart for c program

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

void brst();
void thight();
void wings();
void back();
void neck();
void menu();
void ex();

float price;
float total;
char choice;
int again;

void main()
{
menu();
}

void menu()
{
char choice = ' ' ;
  
printf("----------------------------------------------------------------------");
printf("\n Welcome to Chicken Chicky Place. \n ");
printf(" && Please select the chicken part that you would like to purchase. && \n\n");
printf(" [A] Breast\n");
printf(" [B] Thigh\n");
printf(" [C] Wings\n");
printf(" [D] Back\n");
printf(" [E] Neck\n");
printf("\n");
printf(" [F] Exit\n\n");
printf("Enter your choice here : ");
scanf("%c", &choice);
printf("----------------------------------------------------------------------");
  
{
if ((choice) == 'A' )
brst();
else
if ((choice) == 'B')
thight();
else
if ((choice) == 'C')
wings();
else
if ((choice) == 'D')
back();
else
if ((choice) == 'E')
neck();
else
if ((choice) == 'F')
ex();
else
if ((choice) != 'A' , 'B' , 'C' , 'D' ,'E', 'F')
{
printf("\n");
system("clear");
menu();
}
}
}
void brst()
{
int choice = 0;
int quantity = 0;
int again = 0;

printf("\n Welcome to Chicken Chicky Place. \n ");
printf(" $ Cooking Style $ \n\n");
printf(" && Please select the cooking that you would like && \n\n");
printf(" [1] ASAM PEDAS - RM 2.50\n");
printf(" [2] SAMBAL - RM 3.00\n");
printf(" [3] ROASTED - RM 5.00\n");
printf(" [4] GRILLED - RM 6.00\n");

printf("Enter your choice here : ");
scanf("%d", &choice);
{
if (choice == 1)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 2.50 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
brst();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 2)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 3.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
//Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
if (again == 1 )
brst();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 3 )
{
printf("Enter quantity (pieces): ");
scanf("%d", &quantity);
total = 5.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
brst();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 4 )
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 6.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
// Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
if (again == 1 )
{
brst();
}
else
if (again == 2 )
{
menu();
}
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if (choice != 1 , 2 , 3 )
{
printf("\n\n\t\t Invalid Choice Entered\n\n");
ex();
}
}
}

void thight()
{
int choice;
int quantity;
int again;

printf(" Welcome to Chicken Chicky Place. \n ");
printf(" $ Cooking style $ \n\n");
printf(" && Please select the cooking style that you would like to purchase. &&\n\n");
printf(" [1] ASAM PEDAS - RM 2.50\n");
printf(" [2] SAMBAL - RM 3.00\n");
printf(" [3] ROASTED - RM 5.00\n");
printf(" [4] GRILLED - RM 6.00\n");
  
printf("Enter your choice here : ");
scanf("%d", &choice);
{
if (choice == 1)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 2.50* quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
thight();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if ( choice == 2)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 3.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
if (again == 1 )
thight();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if ( choice == 3 )
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 5.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No :");
scanf("%d", &again);
system("clear");
if (again == 1 )
thight();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if ( choice == 4 )
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 6.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No :");
scanf("%d", &again);
system("clear");
if (again == 1 )
thight();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if (choice != 1 , 2 , 3)
{
printf("\n\n Invalid Choice Entered\n\n");
thight();
}
}

}

void wings()
{
int choice;
int quantity;
int again;


printf(" Welcome to Chicken Chicky Place. \n ");
printf(" $ Cooking style $ \n\n");
printf(" && Please select the cooking style that you would like to purchase. &&\n\n");
printf(" [1] ASAM PEDAS - RM 2.50\n");
printf(" [2] SAMBAL - RM 3.00\n");
printf(" [3] ROASTED - RM 5.00\n");
printf(" [4] GRILLED - RM 6.00\n");

printf("Enter your choice here : ");
scanf("%d", &choice);
{
if (choice == 1)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 2.50 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n ", total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
wings();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if ( choice == 2)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 3.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n ", total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
wings();
else
if (again == 2 )
menu();
else
if (again != 1 , 2 )
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
}
else
if ( choice == 3 )
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 5.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No :");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
wings();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
  
}
}
else
if ( choice == 4 )
{
printf("Enter quantity (pieces): ");
scanf("%d", &quantity);
total = 6.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
{
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No :");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
wings();
else
if (again == 2 )
menu();
else
if (again != 1 , 2 )
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
  
}
}
else
if (choice != 1 , 2 )
{
printf("\n\n Invalid Choice Entered\n\n");
wings();
}
}
}

void back()
{
int choice = 0;
int quantity = 0;
int again = 0;

printf("\n Welcome to Chicken Chicky Place. \n ");
printf(" $ Cooking Style $ \n\n");
printf(" && Please select the cooking that you would like && \n\n");
printf(" [1] ASAM PEDAS - RM 2.50\n");
printf(" [2] SAMBAL - RM 3.00\n");
printf(" [3] ROASTED - RM 5.00\n");
printf(" [4] GRILLED - RM 6.00\n");

printf("Enter your choice here : ");
scanf("%d", &choice);
{
if (choice == 1)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 2.50 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
  
if (again == 1 )
back();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 2)
{
printf("Enter quantity (pieces) : ");
scanf("%d", &quantity);
total = 3.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
//Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
if (again == 1 )
back();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 3 )
{
printf("Enter quantity (KG): ");
scanf("%d", &quantity);
total = 5.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
back();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 4 )
{
printf("Enter quantity (KG) : ");
scanf("%d", &quantity);
total = 6.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
// Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
if (again == 1 )
{
back();
}
  
else
if (again == 2 )
{
menu();
}
  
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if (choice != 1 , 2 , 3 )
  
printf("\n\n\t\t Invalid Choice Entered\n\n");
ex();
}
}

void neck()
{
int choice = 0;
int quantity = 0;
int again = 0;
  
printf("\n Welcome to Chicken Chicky Place. \n ");
printf(" $ Cooking Style $ \n\n");
printf(" && Please select the cooking that you would like && \n\n");
printf(" [1] ASAM PEDAS - RM 2.50\n");
printf(" [2] SAMBAL - RM 3.00\n");
printf(" [3] ROASTED - RM 5.00\n");
printf(" [4] GRILLED - RM 6.00\n");

printf("Enter your choice here : ");
scanf("%d", &choice);
{
if (choice == 1)
{
printf("Enter quantity (KG) : ");
scanf("%d", &quantity);
total = 2.50 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
  
if (again == 1 )
neck();
else
if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 2)
{
printf("Enter quantity (KG) : ");
scanf("%d", &quantity);
total = 3.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
//Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
  
if (again == 1 )
neck();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 3 )
{
printf("Enter quantity (KG): ");
scanf("%d", &quantity);
total = 5.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ", total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
scanf("%d", &again);
system("clear");
  
if (again == 1 )
neck();
else if (again == 2 )
menu();
else
if (again != 1 , 2)
{
printf("\n\nSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if ( choice == 4 )
{
printf("Enter quantity (KG) : ");
scanf("%d", &quantity);
total = 6.00 * quantity ;
printf("Your total amount is RM%.2f , Please pay at the counter\n\n\n ",total);
printf("\nWould you like to buy anything else?\n[1] Yes , [2] No : ");
// Allows user to choose whether to check-out or buy anything else.
scanf("%d", &again);
system("clear");
  
if (again == 1 )
{
neck();
}
else
if (again == 2 )
{
menu();
}
  
else
if (again != 1 , 2)
{
printf("\n\n\t\tSorry Invalid Decision Entered\n\n\n\n");
ex();
}
}
else
if (choice != 1 , 2 , 3 )
{
printf("\n\n\t\t Invalid Choice Entered\n\n");
ex();
}
}
}

void ex() // Exit Screen
{
printf("\n");
printf(" Thank You Very Much \n ");
printf(" && Please come again. && \n\n");
}

Solutions

Expert Solution

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ANSWER :-

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

- > Since the program was too big for a single file i split it in multiple files which is in sequence 1, 2, .., 6 and can be easily joined with the help of little intuition.

- > All the parts from 1 to 6 will join at "ex()".

____________________________________________________________________

1.

____________________________________________________________________

2.

Choice 4 -

____________________________________________________________________

3.

Choice != 1,2,3 -

____________________________________________________________________

4.

Choice 4 -

____________________________________________________________________

5.

Choice 4 -

____________________________________________________________________

6.

Choice 4 -

____________________________________________________________________


Related Solutions

construct c program flow chart #include <stdio.h> #include <math.h> #include <string.h> #define num 6 #define b...
construct c program flow chart #include <stdio.h> #include <math.h> #include <string.h> #define num 6 #define b 6 #define t 6 double bmical(double w, double h){ double o; double bmi; o = pow(h,2); bmi = w/o; return bmi; } double maxheartrate(int num1, int age){ double mhr; mhr = num1 - age; return mhr; } double heartratereserve(double mhr, double rhr){ double hrr; hrr = mhr - rhr; return hrr; } double minrange(int hrr, int rhr){ double mirt; mirt = (hrr * 0.7)...
Can you translate this C code into MIPS assembly? #include <stdio.h> #include <math.h> #include <stdlib.h> double...
Can you translate this C code into MIPS assembly? #include <stdio.h> #include <math.h> #include <stdlib.h> double fact (double); void main () { int angle_in_D; double term, angle_in_R; float sine = 0; unsigned int i = 1; double sign = 1; int n = 1000; printf ("Please enter an angle (Unit: Degree): "); scanf ("%d", &angle_in_D); angle_in_R = angle_in_D * M_PI / 180.0; do { term = pow(-1,(i-1)) * pow (angle_in_R, (2*i - 1)) / fact (2*i - 1); sine =...
C program. librarys that are in use; stdio.h, stdlib.h, time.h, stddef.h, ctype.h, math.h, string.h. Need to...
C program. librarys that are in use; stdio.h, stdlib.h, time.h, stddef.h, ctype.h, math.h, string.h. Need to rewrite the functions linked in the code: "return add_move_lib ( board, col, colour ) ;" "return board_full_lib ( board ) ;" "return display_board_lib ( board ) ; // TASKS // board_full() display_board() add_move() // adds a token of the given value (1 or 2) to the board at the // given column (col between 1 and COLS inclusive) // Returns 0 if successful, -1...
#include <stdio.h> #include <stdlib.h> #include <math.h> #include "../include/cis1057.h" /* * Programmer: << MA >> * Class:...
#include <stdio.h> #include <stdlib.h> #include <math.h> #include "../include/cis1057.h" /* * Programmer: << MA >> * Class: Introduction to C Programming 1057 Spring 2019 Section 004 * Assignment: Number 5 “estimate the value of a factorial using Gosper's algorithm." * Date: << 02-19-2019 >> * Version: 1 * Description: Program will prompt for some data, read in the values, perform the calculation using library math functions, and display the result. * File: lab5.c */ # define M_PI 3.14159265358979323846 /* pi */...
Please implement the 5 questions in source code: #include <stdio.h> #include <stdlib.h> #include <math.h> int main(...
Please implement the 5 questions in source code: #include <stdio.h> #include <stdlib.h> #include <math.h> int main( int argc, char* argv[] ) { // Size of vectors int n = 10000; // Input vectors double *restrict a; double *restrict b; // Output vector double *restrict c; // Size, in bytes, of each vector size_t bytes = n*sizeof(double); /* Q1: Allocate memory for vector a (10 points)*/ /* Q2: Allocate memory for vector b (10 points)*/ /* Q3: Allocate memory for vector...
*Answer in C program* Given a program as shown below: #include <stdio.h> void function1(void); void function2...
*Answer in C program* Given a program as shown below: #include <stdio.h> void function1(void); void function2 (int, double x); void main (void) { int m; double y; m=15; y=308.24; printf ("The value of m in main is m=%d\n\n",m); function1(); function2(m,y); printf ("The value of m is main still m = %d\n",m); } void function1(void) { printf("function1 is a void function that does not receive\n\\r values from main.\n\n"); } void function2(int n, double x) { int k,m; double z; k=2*n+2; m=5*n+37;...
Please paraphrase this c code #include <stdio.h> #include <stdlib.h> #include <string.h> void sortGrades(int arr[], int size,...
Please paraphrase this c code #include <stdio.h> #include <stdlib.h> #include <string.h> void sortGrades(int arr[], int size, int status, char names[][20]); void printer(int grades[], int size, char names[][20]); void sortNames(char arr[][20], int size, int status, int grades[]); void nameSearch(int grades[], int size, char names[][20]); void numSearch(int grades[], int size, char names[][20]); int main() { int i; int size; int option; do { printf("\n\nInput Number of Students or 0 to exit : "); scanf("%d", &size); if (size == 0) { break; }...
example_thread.c #include <stdio.h> #include <stdlib.h> #include <pthread.h> int shared= 0; void race(void); int main(){     pthread_t...
example_thread.c #include <stdio.h> #include <stdlib.h> #include <pthread.h> int shared= 0; void race(void); int main(){     pthread_t player1, player2, player3;     pthread_create(&player1, NULL, (void *)race, NULL);     pthread_create(&player2, NULL, (void *)race, NULL);     pthread_create(&player3, NULL, (void *)race, NULL);     pthread_join(player1, NULL);     pthread_join(player2, NULL);     pthread_join(player3, NULL);     printf("Total Number = %d\n", shared);     return 0; } void race(void) {     long i,tmp;     for(i=1; i<=200000; i++) {         tmp = shared;         tmp = tmp + 1;         shared =...
#include <stdio.h> #include <stdlib.h> #include <time.h> void sort(int a[], int size); void printArray(int a[], int size);...
#include <stdio.h> #include <stdlib.h> #include <time.h> void sort(int a[], int size); void printArray(int a[], int size); int main(){ int arraySize, limit, count, srand(time(0)); print f("Enter the size of array\n"); scanf("%d", arraySize); int array[arraySize]; printf("Enter the upper limit\n"); scanf("%d", &limit); count = 0; while(count <= arraySize){ array[count] = (rand() % (limit + 1)); count++; } printArray(array, &arraySize); sort(array, arraySize); printArray(array, arraySize); Return 0; } void printArray(int a[], int size){ int i = 0; printf("Array: ["); while(i < size){ if(i != size...
#include <stdlib.h> #include <stdio.h> #include <string.h> void clrScreen(int lines){     int i = 0;     for( i =...
#include <stdlib.h> #include <stdio.h> #include <string.h> void clrScreen(int lines){     int i = 0;     for( i = 0; i < lines; ++i ){         printf("\n");     }     return; } void printRules(void){     printf("\t|*~*~*~*~*~*~*~*~*~ How to Play ~*~*~*~*~*~*~*~*~*~|\n");     printf("\t|   This is a 2 player game. Player 1 enters the   |\n");     printf("\t|   word player 2 has to guess. Player 2 gets a    |\n");     printf("\t|   number of guesses equal to twice the number    |\n");     printf("\t|   of characters. EX: If the word is 'example'    |\n");     printf("\t|   player 2 gets 14 guesses.                      |\n");     printf("\t|*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~|\n");     clrScreen(10);     return; } //------------------------------------------------------------------------------------------------------------ /*...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT