Supermarket billing problem

Sep 28, 2011 at 9:36am
hi I am Trying to create a simple Bill format in the console application of visual c++..

I have completed all the code except
My program can take maximum of 50 items
But if I need only for 10 items i need to change the code for 10 items
my doubt is how to control the program to my required number of items without changing the program each time....i.e."how to break the loop only for required number of items.."
practically
customer will come and show the billingPeople what are the items,but not the "number of items..."
Sep 28, 2011 at 9:44am
I'm not sure what you mean. Can you post the code? (Use the code tags if you do.)

In all likeliness, you'll need a conditional loop, as such:

1
2
3
while (item.next() != null) {
// Actions
}


Of course, the implementation of the loop depends on how your items are stored and handled, which we can't help you with without more information.
Sep 28, 2011 at 10:06am
i am not using linked lists and all just simple
1. tabular format first consists of name date and item, its price
2.the cursor will then goes to the name field and then comes to the item field
if u hav doubt just verify it once
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<iostream>
#include<string>
#include<time.h>
#include<iomanip>
#include<windows.h>
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;
void gotoXY(int,int);
//void gotoXY(int,int,string);
using namespace std;
int main()
{
	string name,item;
	cout<<"\t\tReliance Fresh\n\n";
	char sdate[9];
	_strdate_s(sdate);
	cout<<"Name:\t\t\t\t\t\tDate:"<<sdate<<"\n";
	for(int i=0;i<61;i++)
		cout<<"*";
	cout<<"\n";
	cout<<"\tItem\t\t\t\tPrice\n";
	for(int i=0;i<61;i++)
		cout<<"*";
	cout<<"\n";
	gotoXY(5,2);
	cin>>name;
	int n=6;
	float price,tot=0;
	for(int i=0;i<10;i++) 
	{
		gotoXY(0,n);
		cin>>item;
		gotoXY(40,n);
		cin>>price;
		tot+=price;
		n++;
	}
	cout<<"Total:\t\t\t\t"<<tot;	
	return 0;
}
void gotoXY(int x, int y) 
{ 
CursorPosition.X = x; 
CursorPosition.Y = y; 
SetConsoleCursorPosition(console,CursorPosition); 
}

and thanking u for ur response......
Topic archived. No new replies allowed.