need help with output

Hi [/code]
Last edited on
OP:

Hi my code is executing but it keeps asking for the price and weight over and over again instead of going to the next statement, any help would be appreciated
Thanks

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

float CalcDiscount(int &mon, float &bTax);
float CalcSalesTax(char &code, float &Total);
float CalcShipping(int &totalWt, float &sTotal);


void GetSalesInfo(int &accountNum, int &month, int &day, int &year, char
  &cCode)

{

  cout << "Please Enter your account number: ";
  cin >> accountNum;

  cout << "Please Enter the Sales Date. " << endl;

  cout << "Enter Month: ";
  cin >> month;

  cout << "Enter day: ";
  cin >> day;

  cout << "Enter year: ";
  cin >> year;

  cout << "Please Enter the County Code: ";
  cin >> cCode;

 
};

void getItemInfo(float& bTax, int&totalWt)//get the prices and wt
{
  cout<<"\nEnter information on an item? Y or N:";
  char choice;//declares choice in local function only
  float price;//declares price in local function only
  int weight;//declares weight variable in local function only
  cin>>choice;//read input choice

  while(choice=='Y')//while user enters yes then get the price and weight
    {
      cout<<"\nPlease enter the price of the item";//outputs price
      cin>>price;//reads price input
      cout<<"\nPlease enter the weight of the item";//outputs weight
      cin>>weight;//reads the weight from user
      bTax+=price;//calculates price to total
      totalWt+=weight;//calculates total weight
      cout<<"\nEnter information on an item? Y or N";
    }
  return;
}
void OutputInvoice(int accountNum, char &cCode, int day, int year, int
  month, float bTax, float discount, float taxTotal, float shipTotal,
  float totalDue)
{


  cout << "ACCOUNT NUMBER" << setw(20) << "COUNTY" << endl;
  cout << setw(9) << accountNum;
  cout << setw(29);

  switch (cCode)

  {
    case 'o':
      cout << "Orange County";
      break;
    case 'O':
      cout << "Orange County";
      break;
    case 's':
      cout << "San Diego county";
      break;
    case 'S':
      cout << "San Diego county";
      break;
    case 'l':
      cout << "LA County";
      break;
    case 'L':
      cout << "LA County";
      break;
    default:
      cout << "Invalid input";
      break;

  }

  cout << endl << endl;

  cout << "DATE OF SALE: " << month << "/" << day << "/" << year;

  cout << endl << endl << endl;


  cout << setw(20) << left << "SALE AMOUNT:" << "$" << setw(11) << right
    << bTax << endl;
  cout << setw(20) << left << "DISCOUNT:" << "$" << setw(11) << right <<
    discount << endl;
  cout << setw(20) << left << "SALES TAX:" << "$" << setw(11) << right <<
    taxTotal << endl;
  cout << setw(20) << left << "SHIPPING:" << "$" << setw(11) << right <<
    shipTotal << endl;
  cout << setw(20) << left << "TOTAL DUE:" << "$" << setw(11) << right <<
    totalDue;


};

int main()
{

  int accountNum;
  int month;
  int day;
  int year;
  char cCode;
  float bTax;
  int weight;
  int totalWt;
  float discount;
  float taxTotal;
  float aDisTotal;
  float shipTotal;
  float sTotal;
  float totalDue;

  GetSalesInfo(accountNum, month, day, year, cCode);
 getItemInfo(bTax,totalWt);
  cout << fixed << setprecision(2);

  discount = CalcDiscount(month, bTax);

  aDisTotal = bTax - discount;

  taxTotal = CalcSalesTax(cCode, aDisTotal);


  shipTotal = CalcShipping(totalWt, sTotal);

  totalDue = aDisTotal + taxTotal + shipTotal;



  OutputInvoice(accountNum, cCode, day, year, month, bTax, discount,
    taxTotal, shipTotal, totalDue);


  return 0;

}



float CalcDiscount(int &mon, float &bTax)
{
  float one = .05;
  float two = .1;
  float three = .15;

  if (mon <= 5)
  {
    return bTax *one;
  }
  else if (mon <= 8)
  {
    return bTax *two;
  }
  else
    return bTax *three;
}

float CalcSalesTax(char &code, float &total)
{
  float one = .0775;
  float two = .0825;
  float three = .08;

  switch (code)

  {
    case 'o':
      return one *total;
      break;
    case 'O':
      return one *total;
      break;
    case 's':
      return two *total;
      break;
    case 'S':
      return two *total;
      break;
    case 'l':
      return three *total;
      break;
    case 'L':
      return three *total;
      break;
    default:
      cout << "Invalid input";
      break;

  }
}

float CalcShipping(int &totalWt, float &sTotal)
{
  if (totalWt <= 25)
  {
    return 5.00;
  }
  else if (totalWt <= 50)
  {
    return (totalWt - 25) *.1 + 5.00;
  }
  else if (totalWt > 50)
  {
    return (totalWt - 25) *.07 + 5.00;
  }
}
i am new to functions so please correct me if i'm wrong, but first of all why is there a semicolon at the end of line 34? why does line 54 only have return and no int?
1) It doesn't need a ; there actually, but it won't cause any harm.
2) Since the function returns void (nothing), you don't return anything inside it.
Here we have it; the reason we ask people not to delete their posts demonstrated in the wild. Thank you, Aramil.
ummm ur welcome?
ummm ur welcome?


Can you expand on that question? It's not very clear.
the reason we ask people not to delete their posts demonstrated in the wild. Thank you, Aramil.


I don't understand what am I being thanked for and what is deleting posts "demonstrated" in the wild?
To delete a post is to edit it such that all the words that were in it are gone. Look at the first post in this thread.

"demonstrated" is a word meaning "clearly showed" in this context.

You are being thanked for making it clear why deleting posts is bad. You had a question about the post that you could only ask because I copied it out again. Asking a question is good - it helped you understand more about C++. When a post is deleted, people cannot use it to help them understand.
oh ok. Thank you
oh ok. Thank you


AKA: this won't be the last time I delete my posts.
It was vlc25 that deleted his post, not Aramil.
Only reason I can think of why people want to remove their posts is so that their teachers won't find it, which is a bad reason of course.
Haha well that was a fail, I should look at who the OP is before posting o.O.
Topic archived. No new replies allowed.