473,706 Members | 6,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I was sent this code and can't figure out why I keep getting "Incomplete Data type Error

1 New Member
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <getopt.h>
  3. #include <string.h>
  4.  
  5. int main() 
  6. {
  7.  
  8.     // Menu dictionary
  9.     int menu_size = 4;
  10.     struct MenuItem menu[4];
  11.     menu[0].description = strdup("Fried Chicken");
  12.     menu[0].price = 200.0;
  13.     menu[1].description = strdup("Baked Chicken");
  14.     menu[1].price = 350.0;
  15.     menu[2].description = strdup("Jerk Chicken");
  16.     menu[2].price = 500.0;
  17.     menu[3].description = strdup("Barbecue Chicken");
  18.     menu[3].price = 750.0;
  19.  
  20.     // Starting balance
  21.     double starting_balance = 100000.0;
  22.     double balance = 100000.0;
  23.     double chicken_remaining = 425250.0 / 70.0;
  24.  
  25.     // Initialize variables
  26.     int total_servings = 0;
  27.     int total_orders = 0;
  28.     double total_fried_chicken_sales = 0.0;
  29.     double total_baked_chicken_sales = 0.0;
  30.     double total_jerk_chicken_sales = 0.0;
  31.     double total_bbq_chicken_sales = 0.0;
  32.     char name[100] = "";
  33.     char order_confirmation[2] = "";
  34.  
  35.     // Loop for taking customer orders
  36.     while (chicken_remaining > 0) {
  37.         // Display menu
  38.         printf("Welcome to Keisha's Delicious Chicken\nToday's Menu\n");
  39.         for (int i = 0; i < menu_size; i++) {
  40.             printf("%d. %s %.2f\n", i + 1, menu[i].description, menu[i].price);
  41.         }
  42.         printf("5. Type in 'close' to exit the program. \n");
  43.  
  44.         // Take order
  45.         while (1) {
  46.             printf("Enter customer name: ");
  47.             fgets(name, sizeof(name), stdin);
  48.             name[strcspn(name, "\n")] = '\0';
  49.             if (strcmp(name, "close") == 0) {
  50.                 printf("\nTotal orders: %d\n", total_orders);
  51.                 printf("Total servings: %d\n", total_servings);
  52.                 printf("Total Fried Chicken sales: %.2f (%d servings)\n", total_fried_chicken_sales, (int)(total_fried_chicken_sales/200.0));
  53.                 printf("Total Baked Chicken sales: %.2f (%d servings)\n", total_baked_chicken_sales, (int)(total_baked_chicken_sales/350.0));
  54.                 printf("Total Jerk Chicken sales: %.2f (%d servings)\n", total_jerk_chicken_sales, (int)(total_jerk_chicken_sales/500.0));
  55.                 printf("Total Barbecue Chicken sales: %.2f (%d servings)\n", total_bbq_chicken_sales, (int)(total_bbq_chicken_sales/750.0));
  56.                 printf("Current balance: %.2f\n", balance);
  57.                 printf("Chicken remaining: %.2f\n", chicken_remaining);
  58.                 printf("Thank you for choosing Keisha's Delicious Chicken!\n");
  59.                 return 0;
  60.             }
  61.             int choice;
  62.             printf("Enter order number (1-4): ");
  63.             scanf("%d", &choice);
  64.             getchar(); // Consume newline character
  65.             if (choice < 1 || choice > menu_size) {
  66.                 printf("Invalid choice. Please try again.\n");
  67.             } else 
  68.             {
  69.                 // Compute cost of the order
  70.                double order_cost = menu[choice - 1].price;
  71.             }
  72.         }
  73.     }
  74. return 0; 
  75. }
Any help would be appreciated
Apr 29 '23 #1
2 18874
donbock
2,426 Recognized Expert Top Contributor
Where is struct MenuItem defined? Perhaps you need to include another header file.
May 1 '23 #2
Oralloy
988 Recognized Expert Contributor
Presumably you were able to sort this out.

Will you take a moment to show the rest of us what the solution was?
May 31 '23 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1190
by: Larry | last post by:
I'm having trouble finding the right method to determine at runtime the data type of the fields in a class. here's what I've got so far: Public Class ImgSubmissionRecord Public fileName As String Public thumbnail As Bitmap
2
3990
by: kellymart87 | last post by:
//remain.cpp #include <iostream.h> #include <conio.h> int main() getline ()
2
4899
by: bloukopkoggelmander | last post by:
Hi all I am getting the following error and it is driving me insane. I just cannot find a fix for it. : You tried to assign the NULL value to a variable that is not a Variant data type. Now I have a main form linked to a as400 table. This has a subform on it, also linked to a AS400 table. Now the foirst control on the subform( also the first field a user needs to complete on the form) is the one I am trying to popullate. The minute I...
2
3633
by: preeti13 | last post by:
i am tring to retrive the value form the data base but getting erorr i tried so many way but i didn't get the value i got the erorr like this: Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query. if any one know something about this then please help me my code is like this: private void Page_Load(object sender, System.EventArgs e) { string employeenominationid;...
3
2499
gregerly
by: gregerly | last post by:
Hello, I think this should be a simple answer, but I haven't found any good resource yet. I have an element that onclick I run a function, passing a reference to the object clicked. I then grab the id of that object which is a number, 1, 2 ,15, 37, whatever Looks like below: <img src='img/src.gif' id='12' onclick='somefunction(this)' /> Here is the somefunction() somefunction(el){ var rowId = el.getAttribute('id');
0
1283
by: PowerWill500 | last post by:
Hi guys, I'm using a simple gdal script to load topography data from a .DEM file to a grid. However, when I do this gdal converts the data into 16 bit unsigned integers, which is no good for reading negative elevation. I though I told it to read the data as 32 bit floats, but it reads as uint16, then converts to float32. Here is my code: import gdal from gdalconst import * import numpy data = gdal.Open(topoFile,GA_ReadOnly)
5
1429
by: README | last post by:
//what i needed to do was to read the file number.txt, and check for frequencies by using arrays. #include<iostream> #include<fstream> #include<ctime> #include<cstdlib> using namespace std; int MAX=20;//Global variable void createDataFile();//Function prototype
44
26681
Seth Schrock
by: Seth Schrock | last post by:
I have the following piece of code for my query. For some reason some of the records showup with the FileCount field having an error. When I click in the field it says "Data type mismatch in criteria expression." I assume that it is talking about the criteria in the DCount() function. The three fields that are referenced in the criteria portion of the DCount() function are as follows: ACHID AutoNumber EffectiveDate Date ...
2
2009
by: irongollem | last post by:
Below is the function I defined. It is supposed to calculate the amount of payment terms between two dates (rounded up) and do this according to a dropdown menu that gives users the option to select monthly, quarterly or yearly payments. Functions first argument is the result of this dropdown, the second argument is the first date and the third argument is the last date or end date for this specific payment plan. The error message I'm getting...
0
1309
by: jirkap | last post by:
Hi, I have a quite complex UserForm and using SQL queries I retrieve from and also save data to another workbook (unfortunately I cannot use Access db in this case). There are three particular textboxes in the form with linked checkboxes. Normally, users enter numbers to the fields and everything saves fine to the external workbook. But when the checkbox is ticked, it changes linked textbox value to "Unknown" and I get an error when...
0
8780
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8695
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9285
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9155
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8989
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6614
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4445
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4708
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2499
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.