change the code to C language

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

change the code to C language

 

#include<stdio.h>
#include<conio.h>
void menu();
void getInput( char &, int & );
float getprice( char ch , int n);

int main()
{
char name[20], order[3][20];
int table, quantity[3];

char ch1,ch2,ch3;
int n1,n2,n3;
float price=0;
float total=0;
float pay=0;
float change=0;
int q1;
int q2;
int q3;

printf ("\t -----------SUNNY CAFE ORDER FORM-----------\n");
printf("\t Customer Name :");
scanf("\n%s",&name);
printf("\t Table Number :");
scanf("\n%d", &table);
menu();

printf("\n\t Order 1: ");
getInput(ch1, n1);
printf("\t Order 1 quantity: ");
scanf("%d", &q1);
printf("\n");

printf("\t Order 2: ");
getInput(ch2, n2);
printf("\t Order 2 quantity: ");
scanf("%d", &q2);
printf("\n");

printf("\t Order 3: ");
getInput(ch3, n3);
printf("\t Order 3 quantity: ");
scanf("%d", &q3);
printf("\n");

printf ("\t\t **********************************************\n");
printf(" ~SUNNY CAFE~ \n");
printf ("\t\t ***********************************************\n");
printf("\t\t Customer Name: %s\n", name);
printf("\t\t Table Number: %d\n", table);
price = getprice(ch1, n1);
printf("\t %c%d x %d = %.2f\n", ch1, n1, q1, q1*price);
total=total+ q1*price;
price = getprice(ch2, n2);
printf("\t %c%d x %d = %.2f\n", ch2, n2, q2, q2*price);
total=total+ q2*price;
price = getprice(ch3, n3);
printf("\t %c%d x %d = %.2f\n", ch3, n3, q3, q3*price);
total=total+ q3*price ,"\n";
printf("\t Total bill: RM %.2f\n", total);
printf("\t Customer paid:");
scanf("%f", &pay);
change= pay-total;
printf("\t Balance: RM %.2f \n\n", change);
printf("\t Please Come Again!\n");

getch();
return 0;
}
float getprice( char ch , int n)
{
const float F1=13.50;
const float F2=10.50;
const float F3=10.00;
const float F4=12.50;
const float F5=8.90;

const float D1=5.90;
const float D2=4.90;
const float D3=6.50;
const float D4=0.50;
const float D5=2.00;

if(ch=='f')
{
switch(n)
{
case 1:
return F1;
case 2:
return F2;
case 3:
return F3;
case 4:
return F4;
case 5:
return F5;
}
}
else if(ch=='d')
{
switch(n)
{
case 1:
return D1;
case 2:
return D2;
case 3:
return D3;
case 4:
return D4;
case 5:
return D5;
}
}
}
void getInput( char &ch, int &n )
{
scanf("\t %c%d", &ch, &n);
}

void menu()
{

printf("\t\t ~~~~~~~~~~~~SUNNY CAFE MENU~~~~~~~~~~~~\n");
printf("\t Food Menu:\n");
printf("\t f1 - Burger (RM13.50)\n");
printf("\t f2 - Sandwich (RM10.50)\n");
printf("\t f3 - Hotdog (RM10.00)\n");
printf("\t f4 - Pasta (RM12.50)\n");
printf("\t f5 - Mushroom Soup (RM8.90)\n");

printf("\t Drinks Menu:\n");
printf("\t d1 - Coffee (RM5.90)\n");
printf("\t d2 - Tea (RM4.90)\n");
printf("\t d3 - Juice (RM6.50)\n");
printf("\t d4 - Sky Juice (RM0.50)\n");
printf("\t d5 - Fizy (RM2.00)\n");

}

Expert Solution
steps

Step by step

Solved in 3 steps with 7 images

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education