Not getting the correct outputs

I have just started learning c++ and was set a problem to solve but i cant get the program to output the proper calculations.The program should accept the quality & the weight of deliveries by a supplier. For each delivery enter the weight and moisture content to produce the:
Basic payment for each delivery
Reduction if any (depending on the moisure content)
Total payment to the supplier
Total weight of grain delivered by the supplier

My code is below and i'm totaly stuck on how to get it going so any help would be greatly appreciated.

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
226
227
228
229
230
231
232
233
234
235
236
237
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>

//Protoype
char get_reply( int col, int row);
void press_key(int col, int row);
void message(char msg[],int col , int row);
int get_no( int col, int row);  //Number > 0
void set_screen (void);
int get_no1( int col, int row);
void set_screen1 (void);

struct delivery {
						int invoice_no;
                  float weight;
                  char quality[1];
                  int moisture;
                  float reduction;
                  float basic;
                  float payment;
					};

void main(void)
{
   //Data Declaration
   int x, opt, delivery_nos,y,z; //x,y&z are for loop purposes
   struct delivery deliveries[5];
   float total_weight=0.00, total_payment=0.00;


   //Condition Output Stream for floating point values
   cout.setf(ios::fixed);
   cout.setf(ios::showpoint);
   cout.precision(2);
   do
   {
   	clrscr();
   	gotoxy(20,3); cout <<"ABC Deliveries Menu";
   	gotoxy(20,5); cout << "1.Enter Delivery";
   	gotoxy(20,7); cout << "2.Display Payment Totals";
   	gotoxy(20,9); cout << "3.Exit";
   	gotoxy(20,11); cout << "Choose Option [ ]";
   	opt = get_no(35,11);

   		if (opt==1)
   		{
      		gotoxy(20,15); cout << "How Many Deliveries? 1-5 [ ]";
         	delivery_nos = get_no1(46,15);
               for(x=0;x < delivery_nos; x++)
   				{
   					set_screen();
   					gotoxy(40,5); cin>> deliveries[x].invoice_no; cin.ignore (10,'\n');

                  while (deliveries[x].invoice_no<1||deliveries[x].invoice_no>5)// validation of invoice no
                  {
                   	message("Please Enter a Number between 1 and 5", 5,20);
                     gotoxy(40,5);cout<<" ";
                     gotoxy(40,5); cin>> deliveries[x].invoice_no; cin.ignore (10,'\n');
                  }

      				gotoxy(46,7); cin>> deliveries[x].weight;cin.ignore (10,'\n');
                  while (deliveries[x].weight<25000||deliveries[x].weight>45000)// validation of weight
                  {
                  	message("Please Enter a Number between 25000 and 45000", 5,20);
                  	gotoxy(46,7);cout<<"     ";cin.ignore (10,'\n');
                  	gotoxy(46,7); cin>> deliveries[x].weight; cin.ignore (10,'\n');
                  }

      			  	gotoxy(46,9); cin.getline(deliveries[x].quality, 1,'\n'); cin.ignore (10,'\n');
                 	gotoxy(45,11);cin>> deliveries[x].moisture; cin.ignore (10,'\n');

                  while (deliveries[x].moisture < 0 || deliveries[x].moisture > 40)//Validation of moisture
                  {
                  	message ("Please enter a number between 0 and 40",20,20);
                     gotoxy(45,11); cout<< "  ";
                     gotoxy(45,11);cin>> deliveries[x].moisture; cin.ignore (10,'\n');

                  }
   				}


    		}
    		if (opt==2)
    		{
         	//processing reductions
            for (x=0; x< delivery_nos - 1;x++)
         	{
                   if (deliveries[x].moisture<13)
                       deliveries[x].reduction = 0.00;
                   if (deliveries[x].moisture>12 || deliveries[x].moisture<16)
                   		deliveries[x].reduction=0.02;
                   if (deliveries[x].moisture>15)
								deliveries[x].reduction=0.05;

                   //processing basic price before reductions
                   if (deliveries[x].quality[1] =='S'||deliveries[x].quality[1] =='s')
                   		deliveries[x].basic = deliveries[x].weight * 0.176;
                   else
                   		deliveries[x].basic = deliveries[x].weight * 0.135;


                   //processing payment
                   deliveries[x].payment = deliveries[x].basic - (deliveries[x].reduction*deliveries[x].weight);
                   //processing totals
                   total_payment = total_payment + deliveries[x].payment;

                   set_screen1();

                   y=6;
                   while(y<11)
            		{
            			gotoxy(21,y);
                     if(deliveries[x].basic<0.00)
               			cout<<"0.00";
                     else
               				cout<<deliveries[x].basic;

               			gotoxy(36,y);

               		if(deliveries[x].reduction<0.00)
               			cout<<"0.00";
               		else
               			cout<<deliveries[x].reduction;

               		gotoxy(56,y);

                  	if(deliveries[x].payment<0.00)
               			cout<<"0.00";
               		else
               			cout<<deliveries[x].payment;

                  	y++;
               		gotoxy(48,19);cout<<total_payment;
            		}
         			press_key(1,25);


   }while(opt!=3);
	press_key (1,25);
} // End of Program

int get_no( int col, int row)  //Number > 0
{
		int no;		//local variable
      gotoxy(col,row); cin >> no;
      while ( no <=0)
      {
      		message("No must be Greater than Zero", 30,23);
            gotoxy(col,row); cout <<"____";
            gotoxy(col,row); cin >> no;
      }

      return no;
}

int get_no1( int col, int row)  //Number > 0
{
		int no;		//local variable
      gotoxy(col,row); cin >> no;
      while ( no <1||no>5)
      {
      		message("No must be between 1 and 5", 30,23);
            gotoxy(col,row); cout <<" ";
            gotoxy(col,row); cin >> no;
      }

      return no;
}

void message(char msg[],int col , int row)
{
		int x;
		gotoxy(col,row); cout << msg;
      press_key(col,row+1);
      gotoxy(col,row);
      for( x=0; x < strlen(msg); x++)
      	cout<<" ";
      gotoxy(col, row+1); cout << "                                   ";
}

void press_key(int col, int row)
{
	char c;
   gotoxy(col,row); cout << "Press any key to Continue";
   c=getche();
}
char get_reply( int col, int row)        //Foreces Y or N
{
		char c;
      gotoxy(col,row); c=getche(); c = toupper(c);
      while( c !='Y' && c !='N')
      {
       		message("Must be Y or N",30,23);
            gotoxy(col,row); cout <<" ";
      		gotoxy(col,row); c=getche(); c = toupper(c);
      }
      return c;
}

void set_screen (void)
{
   clrscr();
	gotoxy(20,3); cout << "Please Enter your delivery details";
   gotoxy(20,5); cout << "Invoice Number 1-5 [ ]";
   gotoxy(20,7); cout << "Weight 25000kg - 45000kg [     ]";
   gotoxy(20,9); cout << "Quality [S]eed or [F]eed [ ]";
   gotoxy(20,11); cout << "Moisture Content 0 - 40 [  ]";
}
void set_screen1 (void)
{
   clrscr();
   gotoxy(20,3); cout << "Supplier Payment Details";
   gotoxy(17,5); cout <<"Basic Payment";
   gotoxy(5,6); cout <<"Invoice NO: 1. :";
   gotoxy(5,7); cout <<"            2. :";
   gotoxy(5,8); cout <<"            3. :";
   gotoxy(5,9); cout <<"            4. :";
   gotoxy(5,10); cout <<"            5. :";
   gotoxy(52,5); cout <<"Reduction";
   gotoxy(40,6); cout <<"            1. :";
   gotoxy(40,7); cout <<"            2. :";
   gotoxy(40,8); cout <<"            3. :";
   gotoxy(40,9); cout <<"            4. :";
   gotoxy(40,10); cout <<"            5. :";
   gotoxy(72,5); cout <<"Payment";
   gotoxy(60,6); cout <<"            1. :";
   gotoxy(60,7); cout <<"            2. :";
   gotoxy(60,8); cout <<"            3. :";
   gotoxy(60,9); cout <<"            4. :";
   gotoxy(60,10); cout <<"            5. :";
   gotoxy(20,19); cout <<"Total Payment to Supplier : ";
   gotoxy(20,20); cout <<"Total Weight of Grain Deliveries :";
}

It would be helpful if you told us what you were expecting and what you got instead.
Topic archived. No new replies allowed.