program rerun loop skips while loop

okay, i have a program that does the following:

has a user input amount of items purchased
asks for input of all prices of items (all this in a while loop)
then sales tax
then figures out the total and outputs it.

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
#include <iostream>
using namespace std;

int main()
{
float items = 0, count = 0, price = 0, total = 0, percent, g_t, tax;//a lot of variables but all neseccary for this, some are place holders just to start counters, totals, ect. 
	char rerun;//our re-run option
	
cout<<"How many sales items do you have? :";
cin>>items;

	do//the do-while for a program rerun option
	{
	
	while ( count < items)
	{
		cout<<"Enter the value of the sales item. : $";
		cin>>price;
		total = total + price;
		count ++;
	}
	
	cout<<"Enter in the sales tax percentage. :";
	cin>>percent;
	
	tax = (total/100.0)*percent;
	g_t = tax + total;
	
		
	cout << "***************************************" << endl;
	cout << "*****    Sales         Receipt    *****" << endl;
	cout << "***************************************" << endl;
	cout << "Total Sales:    $"<<total<< endl;
	cout << "Sales Tax:      $"<<tax<< endl;
	cout << "Total:          $"<<g_t<<endl;
	
		cout<<"Do you want to run that again (y/n)";
		cin>>rerun;
	}
	
	while (rerun == 'y' || rerun == 'Y');
}
	
	


my only question is that when/if the user enters yes (to rerun the program) it skips the initial while loop (the prices loop) and goes straight to asking for the sales tax and i cant seem to understand why
You need to reset count and items to zero.
wanna give me a push in the right direction? ive googled it and searched through my book and cant find information on resetting the counter, i think i remember doing it once for a program but cant recollect, not asking for a handout, just a shove.

thanks
 
count = 0;


What exactly do you want to rerun? Also the part where he inputs the number of item? Because that should be in the loop too.
i got it figured out, thanks anyway!
Topic archived. No new replies allowed.