473,326 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

coding porblem (functions)

The program should show the customer the different items on the menu, and also allow the customer to select more than one item and also calculate and print the bill.

there is going to be three functions im going to call getData which will load data into the array menuList, showMenu which will show the different items on the menu and tell the customer how to select them, and printCheck which will calculate and print the check



this is the menu:

Plain Egg $1.45
Bacon and Egg $2.45
Muffin $0.99
French Toast $1.99
Fruit Basket $2.49
Cereal $0.69
Coffee $0.50
Tea $0.75

how do i use the getData function to load the data into the array menuList and what do i pass the function


#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;



struct menuItemType
{
string menuItem[20];
double menuPrice[5];
int listLength;

};


void showMenu();
void getData();
void printCheck();

int main()
{


cout << "Harry's Breakfast" << endl;
cout << endl;
cout << endl;




system("PAUSE");
return 0;
}

void showMenu()
{

}

void getData()
{

}

void printCheck()
{

}
Oct 11 '06 #1
2 1847
there are spaces in the menu from the item to the price so that it is aligned left for the item and right for the price
Oct 11 '06 #2
D_C
293 100+
You should pass a string, which tells the location of the text file, which has the menu. It also depends how you declare menuList. You can't declare it in getData() because you need to use it elsewhere. I would make it static, for simplicity.

In getData(String filename), you need to open the text file, and parse it line by line. If you leave it as is, you find the last space in each line. Everything to the right is the price, everything to the left is the item name. Then parse those. For each one, create a menu type Item, then put it into you array menuList.

That should be it. Pass the location to the data, parse it line by line, and populate the menu. If it is not static, you will need to return it somehow.
Oct 11 '06 #3

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

Similar topics

1
by: jarit | last post by:
Hi, Found these coding guidelines for C#, HTML, Javascript, Java, HTML, PL/SQL, T-SQL, VB and VBScript. Well written and free to download. www.demachina.com/products/swat Jeroen
144
by: Natt Serrasalmus | last post by:
After years of operating without any coding standards whatsoever, the company that I recently started working for has decided that it might be a good idea to have some. I'm involved in this...
1
by: R Reyes | last post by:
Hello All, I'm always looking for ways to improve my code. Most of the time (whenever I'm working on a project) I write a bunch of functions. Then after the project is finished, I put all the...
2
by: Newbie \(C#,Asp.net\) | last post by:
Hi I have two simple questions that I make sure that I have underestood them 1) what is the main difference between inline coding and code behind besides that code behind is part of DLL and is...
3
by: ct-86 | last post by:
http://www.cdbook.cn/book.asp?id=2393 Organizational and Policy Issues 1 0. Don't sweat the small stuff. (Or: Know what not to standardize.) 2 1. Compile cleanly at high warning levels. 4 2....
7
by: Robert Seacord | last post by:
The CERT/CC has just deployed a new web site dedicated to developing secure coding standards for the C programming language, C++, and eventually other programming language. We have already...
19
by: auratius | last post by:
http://www.auratius.co.za/CSharpCodingStandards.html Complete CSharp Coding Standards 1. Naming Conventions and Styles 2. Coding Practices 3. Project Settings and Project Structure 4....
52
by: burgermeister01 | last post by:
First, let me say that this question is a rather general programming question, but the context is PHP, so I figured this group would have the most relevant insight. Anyways, this is also more of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.