fuctions not outputting

not outputting any help is wanted

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
/****************************************************************************
 * Author Keith 
 * Assignment #3: Functions
 * Class: CS1B
 * Section: M/W 10:30a - 12p
 * Due Date: 2/08/2010
 ***************************************************************************/
#include <iostream>
#include <iomanip>

using namespace std;

void PrintHeader(string asName, char asType, int asNum);

void GetSalesInfo(int accountNumber, int month, int day, int year, char county,
	float salesAmount, int weight);

float CalcDiscount (int orderMonth);

float CalcSalesTax (char county);

float CalcShipping (int weight);

void OutputInvoice ( int accountNumber, int month, int day,int year, char county,
		float salesAmount, float discount, float salesTax, float shippingCost);


int main ()
{

		int accountNumber;
		int month;
		int day;
		int year;
		char county;
		float salesAmount;
		int weight;
		float discount;
		float salesTax;
		float shippingCost;

		PrintHeader("Functions",'A', 3);

		GetSalesInfo(accountNumber,month,day,year,county,
			salesAmount,weight);

		discount = CalcDiscount(month);
		salesTax = CalcSalesTax(county);
		shippingCost = CalcShipping (weight);


		OutputInvoice (accountNumber, month, day, year, county, salesAmount,
				discount, salesTax, shippingCost);



	return 0;
}



 void PrintHeader(string asName, char asType, int asNum)
	{
	cout<<left;
	cout<<"**************************************************\n";
	cout<<"* Programmed by : Keith ";
	cout<<"\n* "<<setw(14) <<"Student ID"<<": 616881";
	cout<<"\n* "<<setw(14) <<"Class"<<": CS1B –-> MW - 10:30a-12:00p";
	cout<<"\n* ";
	if(toupper(asType) == 'L')
	{
	cout<<"Lab #"<<setw(9);
	}
	else
	{
	cout<<"Assignment #"<<setw(2);
	}
	cout<<asNum<<": "<<asName;
	cout<<"\n**************************************************\n\n";
	cout<<right;
	}

 void GetSalesInfo (int fnAccountNumber, int fnMonth, int fnDay, int fnYear,
		 char fnCounty, float fnSalesAmount, int fnWeight)
 {


	 	cout << "Please Enter your Account Number: ";
	 	cin >> fnAccountNumber;
	 	cout <<"Please Enter the Sales Date.\n";
	 	cout <<"Enter Month: ";
	 	cin >> fnMonth;
	 	cout << "Enter Day: ";
	 	cin >> fnDay;
	 	cout << "Enter Year: ";
	 	cin >> fnYear;
	 	cout << "Please Enter the County Code: ";
	 	cin >> fnCounty;
	 	cout << "Please Enter the Sales Amount: ";
	 	cin >> fnSalesAmount;
	 	cout << "Please Enter the package weight: ";
	 	cin >> fnWeight;

 }


 float CalcDiscount( int orderMonth)
	{
	 float disc;

	 if (orderMonth <= 5)
		 {
		 disc = 0.05;
		 }
	 if ((orderMonth >= 6) && (orderMonth <= 9))
		 {
		 disc = 0.10;
		 }

	 if (orderMonth >= 10)
		{
		 disc = 0.15;
		}

	return (disc);
	}

 float CalcSalesTax (char county)
	 {
		 float tax;

		 switch(county)
		 {
			 case 'O':
				 tax = .0775;
				 break;
			 case 'S':
				tax = .0825;
			case 'L':
				tax = .08;
			}

		 return (tax);
	}

 float CalcShipping (int weight)
	 {
		 float shipping;
		 shipping = 0.00;

		 if (weight <= 25)
		 {
			shipping = 5.00;
		 }
		 if ((weight >= 26) && (weight <= 50))
		 {
			shipping = (weight - 25) * 0.10 + 5.00;
		 }
		if (weight >= 50)
			 {
				 shipping = (weight - 50) * 0.07 + 7.50;
			 }
		 return (shipping);
	}

 void OutputInvoice ( int accountNumber, int month, int day,int year, char county,
			float salesAmount, float discount, float salesTax, float shippingCost)
	 {
		 cout << accountNumber;
		 cout << month;
		 cout << day;
		 cout << year;
		 cout << county;
		 cout << salesAmount;
		 cout << discount;
		 cout << salesTax;
		 cout << shippingCost;

	 }


this is my output

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
**************************************************
* Programmed by : Keith 
* Student ID    : 616881
* Class         : CS1B –-> MW - 10:30a-12:00p
* Assignment #3 : Functions
**************************************************

Please Enter your Account Number: 1234
Please Enter the Sales Date.
Enter Month: 4
Enter Day: 3
Enter Year: 2008
Please Enter the County Code: O
Please Enter the Sales Amount: 44.46
Please Enter the package weight: 22
2009288233-120091474722009291924

not outputting
[snip]
this is my output


Looks like it's outputting to me.

Can you be more specific? What output are you expecting vs. what you're actually getting.
* Due Date: 2/08/2010

LOL :D
It looks to me like its outputting junk on line 16, wheres the rest of the program?
Last edited on
This is where the problem occurs.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 void GetSalesInfo (int fnAccountNumber, int fnMonth, int fnDay, int fnYear,
		 char fnCounty, float fnSalesAmount, int fnWeight)
 {


	 	cout << "Please Enter your Account Number: ";
	 	cin >> fnAccountNumber;
	 	cout <<"Please Enter the Sales Date.\n";
	 	cout <<"Enter Month: ";
	 	cin >> fnMonth;
	 	cout << "Enter Day: ";
	 	cin >> fnDay;
	 	cout << "Enter Year: ";
	 	cin >> fnYear;
	 	cout << "Please Enter the County Code: ";
	 	cin >> fnCounty;
	 	cout << "Please Enter the Sales Amount: ";
	 	cin >> fnSalesAmount;
	 	cout << "Please Enter the package weight: ";
	 	cin >> fnWeight;
                //so what is this function all about?? there is no return value..
                //your cin >> ... is useless.
 }
Yeah its definitly a problem of scope, would using pointers solve this problem. Better would have the inputs in main and then send them to the outputInvoice function.
Last edited on
Topic archived. No new replies allowed.