Can someone change this code from C to JavaScript. I
wanna make an Android app.
#include<stdio.h>
#include<string.h>
void DisplayOrder(struct PizzaTypes pizzaCart[100],struct PizzaCost
costOnSize[12],char itemNames[12][100],int sidesCost[4]);
struct PizzaTypes
{
int
smallQuantity,mediumQuantity,largeQuantity,others,freshPan,cheeseBurst,wheatThinCrust;
}
;
struct PizzaCost
{
int
smallCost,mediumCost,largeCost,freshPanCost,cheeseBurstCost,wheatThinCrustCost;
}
;
main()
{
int i=0,c=1,j=0,mainChoice,cost[24]=
{
99,195,395,155,295,445,155,295,445,195,365,545,155,295,445,225,425,635,235,455,685,235,455,685
}
,totalCost=0,a[10];
char name[20];
char itemNames[12][100]=
{
"Margherita(Veg)", "Spicy Triple Tango(Veg)", "Double Cheese
Margherita(Veg)", "Farm House(Veg)", "Cheese and Barbeque
Chicken(Non Veg)", "Chicken Fiesta(Non Veg)", "Chicken Mexican(Non
Veg)", "Chicken Golden Delight(Non Veg)", "Zingy Parcel Veg",
"Zingy Parcel Non Veg", "Taco Mexicana Veg", "Taco Mexicana Non
Veg"
}
;
int sidesCost[4]=
{
29,35,119,129
}
;
// int
zingyParcelVeg=29,zingyParcelNonVeg=35,tacoMexicanaVeg=119,tacoMexicanaNonVeg=129;
struct PizzaTypes pizzaCart[100];
struct PizzaCost costOnSize[12];
for(i=0;i<12;i++)
{
pizzaCart[i].smallQuantity=0;
pizzaCart[i].mediumQuantity=0;
pizzaCart[i].largeQuantity=0;
pizzaCart[i].freshPan=0;
pizzaCart[i].wheatThinCrust=0;
pizzaCart[i].cheeseBurst=0;
pizzaCart[i].others=0;
}
i=0;
while(i<24)
{
costOnSize[j].smallCost=cost[i++];
costOnSize[j].mediumCost=cost[i++];
costOnSize[j].largeCost=cost[i++];
costOnSize[j].freshPanCost=30;
costOnSize[j].cheeseBurstCost=95;
costOnSize[j].wheatThinCrustCost=40;
j++;
}
do
{
if(c==1)
{
printf("Enter\n1 - Veg Pizzas\n2 - Chicken Pizzas\n3 - Sides\n4 -
Exit\n");
scanf("%d",&mainChoice);
switch(mainChoice)
{
case 1:
{
int subChoice;
printf("Enter\n1 - Margherita\n2 - Spicy Triple Tango\n3 - Double
Cheese Margherita\n4 - Farm House\n5 - Exit\n");
scanf("%d",&subChoice);
if(subChoice!=5)
{
int sizeChoice;
printf("Enter\n1 - Small\n2 - Medium\n3 - Large\n");
scanf("%d",&sizeChoice);
if(sizeChoice==1) pizzaCart[subChoice-1].smallQuantity++;
if(sizeChoice==2) pizzaCart[subChoice-1].mediumQuantity++;
if(sizeChoice==3) pizzaCart[subChoice-1].largeQuantity++;
printf("Need Special Crusts\n1 - Fresh Pan\n2 - Cheese Burst\n3 -
Wheat thin Crust\n4 - No Need\n");
int extraCrust;
scanf("%d",&extraCrust);
if(extraCrust==1) pizzaCart[subChoice-1].freshPan++;
else if(extraCrust==2) pizzaCart[subChoice-1].cheeseBurst++;
else if(extraCrust==3)
pizzaCart[subChoice-1].wheatThinCrust++;
if(subChoice!=5) printf("Pizza Added to Cart
Successfully\n");
}
break;
}
case 2:
{
int subChoice;
printf("Enter\n1 - Cheese and Barbeque Chicken\n2 - Chicken
Fiesta\n3 - Chicken Mexican\n4 - Chicken Golden Delight\n5 -
Exit\n");
scanf("%d",&subChoice);
if(subChoice!=5)
{
int sizeChoice;
printf("Enter\n1 - Small\n2 - Medium\n3 - Large\n");
scanf("%d",&sizeChoice);
if(sizeChoice==1) pizzaCart[subChoice+4-1].smallQuantity++;
if(sizeChoice==2) pizzaCart[subChoice+4-1].mediumQuantity++;
if(sizeChoice==3) pizzaCart[subChoice+4-1].largeQuantity++;
printf("Need Special Crusts\n1 - Fresh Pan\n2 - Cheese Burst\n3 -
Wheat thin Crust\n4 - No Need\n");
int extraCrust;
scanf("%d",&extraCrust);
if(extraCrust==1) pizzaCart[subChoice+4-1].freshPan++;
else if(extraCrust==2)
pizzaCart[subChoice+4-1].cheeseBurst++;
else if(extraCrust==3)
pizzaCart[subChoice+4-1].wheatThinCrust++;
if(subChoice!=5) printf("Pizza Added to Cart
Successfully\n");
}
break;
}
case 3:
{
int subChoice;
printf("Enter\n1 - Zingy Parcel Veg\n2 - Zingy Parcel Non Veg\n3 -
Taco Mexican Veg\n4 - Taco Mexican Non Veg\n5 - Exit\n");
scanf("%d",&subChoice);
if(subChoice<5 && subChoice>0)
pizzaCart[subChoice+8-1].others++;
if(subChoice!=5) printf("Added to Cart Successfully\n");
break;
}
default:
{
printf("Invalid Choice\n");
break;
}
}
}
if(c==2)
{
int id,quantityPizza,quantityCrust,quantity,wrongIdFlag=1;
printf("Enter Id to change Quantity\n");
scanf("%d",&id);
if(id>=0 && id<=11)
{
if(id>=0&&id<=7)
{
if(pizzaCart[i].smallQuantity>0||pizzaCart[i].mediumQuantity>0||pizzaCart[i].largeQuantity||pizzaCart[i].others>0||pizzaCart[i].freshPan>0||pizzaCart[i].cheeseBurst||pizzaCart[i].wheatThinCrust>0)
{
printf("Enter\n1 - To Change Small Pizza Quantity\n2 -Change
Quantity for Medium Pizza\n3 -Change Quantity for Large Pizza\n4
-Change Quantity for Crust\n5 - Exit\n");
scanf("%d",&quantityPizza);
printf("Enter quantity to change and to delete Enter 0\n");
scanf("%d",&quantity);
if(quantity>=0)
{
if(quantityPizza==1) pizzaCart[id].smallQuantity=quantity;
if(quantityPizza==2) pizzaCart[id].mediumQuantity=quantity;
if(quantityPizza==3) pizzaCart[id].largeQuantity=quantity;
if(quantityPizza==4)
{
printf("Enter\n1 - To Change Fresh Pan\n2 - Cheese Burst\n3 - Wheat
Thin Crust\n4 - Exit\n");
scanf("%d",&quantityCrust);
if(quantityCrust==1) pizzaCart[id].freshPan=quantity;
if(quantityCrust==2) pizzaCart[id].cheeseBurst=quantity;
if(quantityCrust==3) pizzaCart[id].wheatThinCrust=quantity;
}
}
else
{
printf("Enter Quantity greater than or equal to zero\n");
}
}
else
{
printf("Id Not Found\n");
wrongIdFlag=0;
}
}
else
{
printf("Enter\n1 - To Change Quantity of Zingy Parcel(Veg)\n2 - To
Change Quantity of Zingy Parcel(Non Veg)\n3 - To Change Quantity of
Taco Mexicana(Veg)\n4 - To Change Quantity of Taco Mexicana(Non
Veg)\n5 - To Change Quantity of - Exit\n");
scanf("%d",&quantityPizza);
if(quantityPizza>=1 && quantityPizza<=4)
{
printf("Enter quantity\n");
scanf("%d",&quantity);
pizzaCart[id].others=quantity;
}
}
if(wrongIdFlag==1)
{
printf("Quantity Changed Successfully\nRearranged Order
is\n");
DisplayOrder(pizzaCart,costOnSize,itemNames,sidesCost);
}
}
else
{
printf("Please Enter Valid Id\n");
}
}
if(c==4)
{
int id;
printf("Enter Id to delete from Cart\n");
scanf("%d",&id);
pizzaCart[id].smallQuantity=0;
pizzaCart[id].mediumQuantity=0;
pizzaCart[id].largeQuantity=0;
pizzaCart[id].others=0;
pizzaCart[id].freshPan=0;
pizzaCart[id].cheeseBurst=0;
pizzaCart[id].wheatThinCrust=0;
printf("Item Deleted Successfully\nRearranged Order is\n");
DisplayOrder(pizzaCart,costOnSize,itemNames,sidesCost);
}
if(c==3)
{
DisplayOrder(pizzaCart,costOnSize,itemNames,sidesCost);
}
printf("Enter\n1 - Add Item\n2 - Change Quantity\n3 - View Cart\n4
- Delete from Cart\n Else any number to Calculate Cost\n");
scanf("%d",&c);
}
while(c==1 || c==2 || c==3 || c==4);
printf("Final Order \n");
DisplayOrder(pizzaCart,costOnSize,itemNames,sidesCost);
printf("Thanks for Shopping with us\n");
}
void DisplayOrder(struct PizzaTypes pizzaCart[100],struct PizzaCost
costOnSize[12],char itemNames[12][100],int sidesCost[4])
{
int totalCost=0,i;
printf("---------------------List in
Cart-------------------------\n");
for(i=0;i<11;i++)
{
if(pizzaCart[i].smallQuantity>0||pizzaCart[i].mediumQuantity>0||pizzaCart[i].largeQuantity||pizzaCart[i].others>0||pizzaCart[i].freshPan>0||pizzaCart[i].cheeseBurst||pizzaCart[i].wheatThinCrust>0)
{
if(i>=0&&i<=7)
{
printf("Id : %d\n",i);
printf("Item Name : %s\n",itemNames[i]);
if(pizzaCart[i].smallQuantity>0) printf("Small Size Quantity: %d
-> Cost :
%d\n",pizzaCart[i].smallQuantity,costOnSize[i].smallCost*pizzaCart[i].smallQuantity);
if(pizzaCart[i].mediumQuantity>0) printf("Medium Size Quantity:
%d -> Cost :
%d\n",pizzaCart[i].mediumQuantity,costOnSize[i].mediumCost*pizzaCart[i].mediumQuantity);
if(pizzaCart[i].largeQuantity>0) printf("Large Size Quantity: %d
-> Cost :
%d\n",pizzaCart[i].largeQuantity,costOnSize[i].largeCost*pizzaCart[i].largeQuantity);
if(pizzaCart[i].freshPan>0) printf("Fresh Pan Quantity: %d ->
Cost :
%d\n",pizzaCart[i].freshPan,costOnSize[i].freshPanCost*pizzaCart[i].freshPan);
if(pizzaCart[i].wheatThinCrust>0) printf("Wheat Thin Crust
Quantity: %d -> Cost :
%d\n",pizzaCart[i].wheatThinCrust,costOnSize[i].wheatThinCrustCost*pizzaCart[i].wheatThinCrust);
if(pizzaCart[i].cheeseBurst>0) printf("Cheese Burst Quantity: %d
-> Cost :
%d\n",pizzaCart[i].cheeseBurst,costOnSize[i].cheeseBurstCost*pizzaCart[i].cheeseBurst);
totalCost+=pizzaCart[i].smallQuantity*costOnSize[i].smallCost;
totalCost+=pizzaCart[i].mediumQuantity*costOnSize[i].mediumCost;
totalCost+=pizzaCart[i].largeQuantity*costOnSize[i].largeCost;
totalCost+=pizzaCart[i].freshPan*costOnSize[i].freshPanCost;
totalCost+=pizzaCart[i].cheeseBurst*costOnSize[i].cheeseBurstCost;
totalCost+=pizzaCart[i].wheatThinCrust*costOnSize[i].wheatThinCrustCost;
}
else
{
printf("Id : %d\n",i);
printf("Item Name : %s\n",itemNames[i]);
printf("Quantity : %d\n",pizzaCart[i].others);
printf("Cost : %d\n",pizzaCart[i].others*sidesCost[i-8]);
totalCost+=(pizzaCart[i].others)*sidesCost[i-8];
}
}
}
printf("-------------------Total Cost :
%d-----------------------\n",totalCost);
}
The Comment has been mentioned in Code for readability.
Code in Java ----
import java.util.Scanner;
//Importing Scanner from Util Pacakge
/**
* @author yjoshi
*
*/
public class MainPizzaHouse {
/**
* @param args
*
*/
// Scanner Class to scan input from console
// Passing Input stream object in Scanner Class as
arguments
// scanner class has different method to red from
console
static Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
// initializing some local
variable
// as initialized by you in C
code
int i = 0;
int c = 1;
int j = 0;
//Note here ---- Syntax of defining
Character array
int cost[] = new
int[]{99,195,395,155,295,445,155,295,445,195,365,545,155,295,445,225,425,635,235,455,685,235,455,685};
int totalCose = 0;
//Note here ---- Syntax of defining
int array
int a[] = new int[10];
char name[] = new char[20];
// 2D array has been defined and
initialized
String itemNames[][]=
{{"Margherita(Veg)", "Spicy Triple Tango(Veg)", "Double Cheese
Margherita(Veg)", "Farm House(Veg)"},
{"Cheese and Barbeque Chicken(Non Veg)",
"Chicken Fiesta(Non Veg)", "Chicken Mexican(Non Veg)"},
{"Chicken Golden Delight(Non Veg)", "Zingy
Parcel Veg", "Zingy Parcel Non Veg"},
{ "Taco Mexicana Veg", "Taco Mexicana Non
Veg"}};
int
sidesCost[]={29,35,119,129};
// removed unused value from your C
code
// Creating Object of PizzaTypes
and PizzaCost
PizzaTypes pizzaCart[] = new
PizzaTypes[100];
PizzaCost costOnSize[] = new
PizzaCost[12];
// Initializing the value of
class level variable of PizzaCart Class
// Note -- this can be done by
constructor
// That would be good option and
neat and clean
// since you have used this way
that's why doing in this way so that no confusion takes place
for(i=0;i<12;i++)
{
pizzaCart[i].smallQuantity=0;
pizzaCart[i].mediumQuantity=0;
pizzaCart[i].largeQuantity=0;
pizzaCart[i].freshPan=0;
pizzaCart[i].wheatThinCrust=0;
pizzaCart[i].cheeseBurst=0;
pizzaCart[i].others=0;
}
i=0;
// Initializing the value of
class level variable of PizzaCost Class
// Note -- this can be done by
constructor
// That would be good option and
neat and clean
// since you have used this way
that's why doing in this way so that no confusion takes place
while(i<24)
{
costOnSize[j].smallCost=cost[i++];
costOnSize[j].mediumCost=cost[i++];
costOnSize[j].largeCost=cost[i++];
costOnSize[j].freshPanCost=30;
costOnSize[j].cheeseBurstCost=95;
costOnSize[j].wheatThinCrustCost=40;
j++;
}
do
{
if(c==1)
{
System.out.println("Welcome to DJ's House of
Pizza\n\nPlease choose an option\n1 - Veg Pizzas\n2 - Chicken
Pizzas\n3 - Sides\n4 - Exit\n");
// creating local variable to store the
choices
// Using nextInt() method of scan class to read
from the console
int mainChoice = scan.nextInt();
//Switch case has been used , same logic with if
can also be used
switch(mainChoice)
{
case 1:
{
int subChoice;
//Providing Option In Console
to Choose from It.
System.out.println("Enter\n1
- Margherita\n2 - Spicy Triple Tango\n3 - Double Cheese
Margherita\n4 - Farm House\n5 - Exit\n");
// Using nextInt() method of
scan class to read from the console
subChoice =
scan.nextInt();
if(subChoice!=5)
{
// No
change in Logic written By you ... so that output won't
differ
int
sizeChoice;
System.out.println("Enter\n1 - Small\n2 - Medium\n3 -
Large\n");
// Using
nextInt() method of scan class to read from the console
sizeChoice
= scan.nextInt();
if(sizeChoice==1) pizzaCart[subChoice-1].smallQuantity++;
if(sizeChoice==2) pizzaCart[subChoice-1].mediumQuantity++;
if(sizeChoice==3) pizzaCart[subChoice-1].largeQuantity++;
System.out.println("Need Special Crusts\n1 - Fresh Pan\n2 - Cheese
Burst\n3 - Wheat thin Crust\n4 - No Need\n");
int
extraCrust;
// Using
nextInt() method of scan class to read from the console
extraCrust
= scan.nextInt();
if(extraCrust==1) pizzaCart[subChoice-1].freshPan++;
else
if(extraCrust==2) pizzaCart[subChoice-1].cheeseBurst++;
else
if(extraCrust==3) pizzaCart[subChoice-1].wheatThinCrust++;
if(subChoice!=5) System.out.println("Pizza Added to Cart
Successfully\n");
}
break;
}
case 2:
{
int subChoice;
System.out.println("Enter\n1
- Cheese and Barbeque Chicken\n2 - Chicken Fiesta\n3 - Chicken
Mexican\n4 - Chicken Golden Delight\n5 - Exit\n");
// Using nextInt() method of
scan class to read from the console
subChoice =
scan.nextInt();
if(subChoice!=5)
{
// No
change in Logic written By you ... so that output won't
differ
int
sizeChoice;
System.out.println("Enter\n1 - Small\n2 - Medium\n3 -
Large\n");
// Using
nextInt() method of scan class to read from the console
sizeChoice
= scan.nextInt();
if(sizeChoice==1) pizzaCart[subChoice+4-1].smallQuantity++;
if(sizeChoice==2) pizzaCart[subChoice+4-1].mediumQuantity++;
if(sizeChoice==3) pizzaCart[subChoice+4-1].largeQuantity++;
System.out.println("Need Special Crusts\n1 - Fresh Pan\n2 - Cheese
Burst\n3 - Wheat thin Crust\n4 - No Need\n");
int
extraCrust;
// Using
nextInt() method of scan class to read from the console
extraCrust
= scan.nextInt();
if(extraCrust==1) pizzaCart[subChoice+4-1].freshPan++;
else
if(extraCrust==2) pizzaCart[subChoice+4-1].cheeseBurst++;
else
if(extraCrust==3) pizzaCart[subChoice+4-1].wheatThinCrust++;
if(subChoice!=5) System.out.println("Pizza Added to Cart
Successfully\n");
}
break;
}
case 3:
{
int subChoice;
System.out.println("Enter\n1
- Zingy Parcel Veg\n2 - Zingy Parcel Non Veg\n3 - Taco Mexican
Veg\n4 - Taco Mexican Non Veg\n5 - Exit\n");
// Using nextInt() method of
scan class to read from the console
subChoice =
scan.nextInt();
if(subChoice<5 &&
subChoice>0) pizzaCart[subChoice+8-1].others++;
if(subChoice!=5)
System.out.println("Added to Cart Successfully\n");
break;
}
default:
{
System.out.println("Invalid
Choice\n");
break;
}
}
}
if(c==2)
{
int
id,quantityPizza,quantityCrust,quantity,wrongIdFlag=1;
System.out.println("Enter Id to change
Quantity\n");
id = scan.nextInt();
// Using nextInt() method of scan class to read
from the console
if(id>=0 && id<=11)
{
if(id>=0&&id<=7)
{
// since
if except all value should be boolean to check the
conditional
// Hence
converting int to boolean ,,,, by
//pizzaCart[i].cheeseBurst != 0
if(pizzaCart[i].smallQuantity>0||pizzaCart[i].mediumQuantity>0||pizzaCart[i].largeQuantity
!=
0||pizzaCart[i].others>0||pizzaCart[i].freshPan>0||pizzaCart[i].cheeseBurst
!= 0||pizzaCart[i].wheatThinCrust>0)
{
System.out.println("Enter\n1 - To Change Small
Pizza Quantity\n2 -Change Quantity for Medium Pizza\n3 -Change
Quantity for Large Pizza\n4 -Change Quantity for Crust\n5 -
Exit\n");
// Using nextInt() method of scan class to read
from the console
quantityPizza = scan.nextInt();
System.out.println("Enter quantity to change and
to delete Enter 0\n");
// Using nextInt() method of scan class to read
from the console
quantity= scan.nextInt();
if(quantity>=0)
{
// No change in Logic written
By you ... so that output won't differ
if(quantityPizza==1)
pizzaCart[id].smallQuantity=quantity;
if(quantityPizza==2)
pizzaCart[id].mediumQuantity=quantity;
if(quantityPizza==3)
pizzaCart[id].largeQuantity=quantity;
if(quantityPizza==4)
{
System.out.println("Enter\n1 - To Change Fresh Pan\n2 - Cheese
Burst\n3 - Wheat Thin Crust\n4 - Exit\n");
// Using
nextInt() method of scan class to read from the console
quantityCrust = scan.nextInt();
if(quantityCrust==1) pizzaCart[id].freshPan=quantity;
if(quantityCrust==2) pizzaCart[id].cheeseBurst=quantity;
if(quantityCrust==3)
pizzaCart[id].wheatThinCrust=quantity;
}
}
else
{
System.out.println("Enter
Quantity greater than or equal to zero\n");
}
}
else
{
System.out.println("Id Not Found\n");
wrongIdFlag=0;
}
}
else
{
System.out.println("Enter\n1 - To Change Quantity of Zingy
Parcel(Veg)\n2 - To Change Quantity of Zingy Parcel(Non Veg)\n3 -
To Change Quantity of Taco Mexicana(Veg)\n4 - To Change Quantity of
Taco Mexicana(Non Veg)\n5 - To Change Quantity of - Exit\n");
// Using
nextInt() method of scan class to read from the console
quantityPizza = scan.nextInt();
if(quantityPizza>=1 && quantityPizza<=4)
{
System.out.println("Enter quantity\n");
// Using nextInt() method of scan class to read
from the console
quantity = scan.nextInt();
pizzaCart[id].others=quantity;
}
}
if(wrongIdFlag==1)
{
System.out.println("Quantity Changed Successfully\nRearranged Order
is\n");
DisplayOrder(pizzaCart,costOnSize,itemNames,sidesCost);
}
}
else
{
System.out.println("Please
Enter Valid Id\n");
}
}
if(c==4)
{
// No change in Logic written By you ... so that
output won't differ
int id;
System.out.println("Enter Id to delete from
Cart\n");
// Using nextInt() method of scan class to read
from the console
id = scan.nextInt();
pizzaCart[id].smallQuantity=0;
pizzaCart[id].mediumQuantity=0;
pizzaCart[id].largeQuantity=0;
pizzaCart[id].others=0;
pizzaCart[id].freshPan=0;
pizzaCart[id].cheeseBurst=0;
pizzaCart[id].wheatThinCrust=0;
System.out.println("Item Deleted
Successfully\nRearranged Order is\n");
DisplayOrder(pizzaCart,costOnSize,itemNames,sidesCost);
}
if(c==3)
{
DisplayOrder(pizzaCart,costOnSize,itemNames,sidesCost);
}
System.out.println("Enter\n1 - Add Item\n2 - Change Quantity\n3 -
View Cart\n4 - Delete from Cart\n Else any number to Calculate
Cost\n");
// Using
nextInt() method of scan class to read from the console
c =
scan.nextInt();
}
while(c==1 || c==2 || c==3 ||
c==4);
System.out.println("Final Order
\n");
DisplayOrder(pizzaCart,costOnSize,itemNames,sidesCost);
System.out.println("Thanks for
Shopping with us\n");
}
// DisplayOrder Is private method
to Display the PizzaTyeas and CartValue
private static void DisplayOrder(PizzaTypes[]
pizzaCart,
PizzaCost[]
costOnSize, String[][] itemNames, int[] sidesCost) {
// No change in Logic written By
you ... so that output won't differ
int totalCost=0,i;
//Setting Formating
System.out.println("---------------------List in
Cart-------------------------\n");
//Displaying the Cart Item
for(i=0;i<11;i++)
{
// since if
except all value should be boolean to check the conditional
// Hence
converting int to boolean ,,,, by
//pizzaCart[i].cheeseBurst != 0
if(pizzaCart[i].smallQuantity>0 ||
pizzaCart[i].mediumQuantity>0 || pizzaCart[i].largeQuantity !=
0||pizzaCart[i].others>0||pizzaCart[i].freshPan>0||pizzaCart[i].cheeseBurst
!= 0||pizzaCart[i].wheatThinCrust>0)
{
if(i>=0&&i<=7)
{
System.out.println("Id : \n"+
" "+ i);
System.out.println("Item Name
: %s\n"+" "+itemNames[i]);
if(pizzaCart[i].smallQuantity>0) System.out.println("Small Size
Quantity: %d -> Cost : %d\n"+"
"+pizzaCart[i].smallQuantity+costOnSize[i].smallCost*pizzaCart[i].smallQuantity);
if(pizzaCart[i].mediumQuantity>0) System.out.println("Medium
Size Quantity: %d -> Cost : %d\n"+"
"+pizzaCart[i].mediumQuantity+costOnSize[i].mediumCost*pizzaCart[i].mediumQuantity);
if(pizzaCart[i].largeQuantity>0) System.out.println("Large Size
Quantity: %d -> Cost : %d\n"+ "
"+pizzaCart[i].largeQuantity+costOnSize[i].largeCost*pizzaCart[i].largeQuantity);
if(pizzaCart[i].freshPan>0) System.out.println("Fresh Pan
Quantity: %d -> Cost :
%d\n"+pizzaCart[i].freshPan+costOnSize[i].freshPanCost*pizzaCart[i].freshPan);
if(pizzaCart[i].wheatThinCrust>0) System.out.println("Wheat Thin
Crust Quantity: %d -> Cost : %d\n"+pizzaCart[i].wheatThinCrust+"
"+costOnSize[i].wheatThinCrustCost*pizzaCart[i].wheatThinCrust);
if(pizzaCart[i].cheeseBurst>0) System.out.println("Cheese Burst
Quantity: %d -> Cost : %d\n"+pizzaCart[i].cheeseBurst+"
"+costOnSize[i].cheeseBurstCost*pizzaCart[i].cheeseBurst);
totalCost+=pizzaCart[i].smallQuantity*costOnSize[i].smallCost;
totalCost+=pizzaCart[i].mediumQuantity*costOnSize[i].mediumCost;
totalCost+=pizzaCart[i].largeQuantity*costOnSize[i].largeCost;
totalCost+=pizzaCart[i].freshPan*costOnSize[i].freshPanCost;
totalCost+=pizzaCart[i].cheeseBurst*costOnSize[i].cheeseBurstCost;
totalCost+=pizzaCart[i].wheatThinCrust*costOnSize[i].wheatThinCrustCost;
}
else
{
//Displaying the Order and
Cost related to it
System.out.println("Id :
%d\n"+i);
System.out.println("Item Name
: %s\n"+itemNames[i]);
System.out.println("Quantity
: %d\n"+pizzaCart[i].others);
System.out.println("Cost :
%d\n"+pizzaCart[i].others*sidesCost[i-8]);
totalCost+=(pizzaCart[i].others)*sidesCost[i-8];
}
}
}
//Displaying the Order and
Cost related to it
System.out.println("-------------------Total Cost :
%d-----------------------\n"+totalCost);
}
}
// Plain class of PizzaTypes to work as struct in C
class PizzaTypes{
// Class Level Variable
int
smallQuantity,mediumQuantity,largeQuantity,others,freshPan,cheeseBurst,wheatThinCrust;
}
//Plain class of PizzaCost to work as struct in C
class PizzaCost{
//Class level Variable
int
smallCost,mediumCost,largeCost,freshPanCost,cheeseBurstCost,wheatThinCrustCost;
}
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Can someone change this code from C to JavaScript. I wanna make an Android app. #include<stdio.h>...
Fix the errors in C code #include <stdio.h> #include <stdlib.h> void insertAt(int *, int); void Delete(int *); void replaceAt(int *, int, int); int isEmpty(int *, int); int isFull(int *, int); void removeAt(int *, int); void printList(int *, int); int main() { int *a; int arraySize=0,l=0,loc=0; int choice; while(1) { printf("\n Main Menu"); printf("\n 1.Create list\n 2.Insert element at particular position\n 3.Delete list.\n4. Remove an element at given position \n 5.Replace an element at given position\n 6. Check the size of...
I am trying to write C programming code and output will be as
below
but I donno how to get the result analysis part.
help me to add the 2nd part with my code:
here is my code below:
#include <stdio.h>
#define MAX 100
struct studentMarkVariable{
int id;
float marks;
};
void getData(struct studentMarkVariable arrs[]);
void show(struct studentMarkVariable arrs[]);
int main()
{
printf ("####### Marks Analyzer V3.0 ####### \n");
struct studentMarkVariable
arrs[MAX];
getData(arrs);
show(arrs);
return 0;
}...
make a code for the additions of fractions. use the attached code
to find LCM.
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> int Icm(int, int); int main() int n1, n2, min Multiple; printf("Enter two positive integers: "); scanf("%d %d", &n1, &n2); // maximum number between n1 and n2 is stored in min Multiple int result = Icm(n1, n2); printf("The LCM of %d and %d is %d.\n", n1, n2, result); return 0; int Icm(int n1, int n2){ int min Multiple = (n1 > n2)...
i need flowchart for the following c code #include <stdio.h> int main() { int n, i, sum = 0; printf("Enter an integer: "); scanf("%d",&n); i = 1; while ( i <=n ) { sum += i; ++i; } printf("Sum = %d",sum); return 0; }
i need help converting this code to java please
#include<stdio.h>
typedef struct{
int pid,at,bt,ct,tat,wt,f;
}process;
int main()
{
int n,i,j,st=0,c,tot=0,pno=0,swi=0;
float atat=0,awt=0;
printf("enter no of processes : ");
scanf("%d",&n);
process a[n],temp;
for (i=0;i<n;i++){
a[i].pid=i+1;
a[i].f=0;
printf("enter at : ");
scanf("%d",&a[i].at);
printf("enter the bt : ");
scanf("%d",&a[i].bt);
printf("--------------------------- ");
}
while(1){
int min=999,c=n;
if (tot==n)
break;
for (i=0;i<n;i++){
if
((a[i].at<=st)&&(a[i].f==0)&&(a[i].at<min)){
min=a[i].at;
c=i;
}
}
if(pno!=a[c].pid)
swi++;
if (c==n)
st++;
else{
a[c].ct=st+a[c].bt;
st=st+a[c].bt;
a[c].tat=a[c].ct-a[c].at;
atat=atat+a[c].tat;
a[c].wt=a[c].tat-a[c].bt;
awt=awt+a[c].wt;
a[c].f=1;
tot++;
}
}
printf("...
what's
wrong with my code??????
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXBINS 99
#define MAXCORS 26
#define MAXCUS 100
#define MAXPUR 10
/* datatype for a list of orders ----------------- */
typedef struct {
int bin_order_number;
char bin_order_char;
}bin_order;
typedef struct {
int orderNo;
bin_order orderbin;
}order;
typedef struct {
int cusnumber;
int n; /* number of the orders what the txt include
*/
order oo[MAXPUR+1];
}customer;
typedef struct{
int n; /*number of the customers */
customer cc[MAXCUS+1];...
Do you have a flowgorithim flow chart for this code? #include <stdio.h> int main() { int num,i=0,sum=0; float average; int customerNumbers[num]; int customerSales[num]; printf("How many customers do you want to track?\n"); scanf("%d",&num); while(i<num) { printf("Enter the customer number. "); scanf("%d",&customerNumbers[i]); printf("Enter the sales for the customer "); scanf("%d",&customerSales[i]); i++; } printf("Sales for the Customer"); printf("\nCustomer Customer"); printf("\nNumber Sales"); for(i=0;i<num;i++) { printf("\n %d \t %d",customerNumbers[i], customerSales[i]); sum=sum+customerSales[i]; } average=(int)sum/num; printf("\n Total sales are $%d",sum); printf("\n Average sales are $%.2f",average); printf("\n --------------------------------------------");...
I made this C program to count change and make a slip saying the exact dollar and change amount given. every time I run the program it says the change given is 477256577 and i'm not sure what I have done wrong? #include<stdio.h> int main(void) { char first, last; int pennies; int nickels; int dimes; int quarters; int loonies; int change; int t_dollars; int t_cents; printf("Type in your 2 initials and press return> "); scanf("%c%c",&first,&last); printf("%c%c please enter in your...
C Programming I have this cost estimation program, but I want to add to it more functions to be more accurate and more useful. I want to add to the program an array and a loop that can help me with the materials that can be use to the building, as ceramic, wood and concrete and extra functions. ########## #include <stdio.h> int main(void) { float wid,len,yrs; int metersq = 2000; int floors,rooms,win,doors,restrooms,umet; char floortype[20]; char ti[20]; int woodfloor = 25;...
Can anyone help me to make this program work in C language, this is a blackjack game #include #include #include void deal(int, int&) void deal(int, int&, int&) int getbet(int); int main() { int totdealer, totplayer; int money, bet, aces; char yesno = 'Y'; _Bool again; srand(time(0)); printf("How much money do you have? "); scanf("%d" , money); while (money>0 && toupper(yesno) == 'Y') { bet = getbet(money); totdealer...