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 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
|
// Progarm :
// Author :
// Date :
// Comments :
#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);
void set_screen (void);
void set_screen1 (void);
int get_no( int col, int row); //Number > 0
int get_no1( int col, int row); //Number between 1-5
int get_no2( int col, int row); //Number between 25000 and 45000
int get_no3( int col, int row); //Number between 25000 and 45000
struct delivery {
int invoice_no;
float weight;
char quality[1];
int moisture;
float reduction;
float basic;
float payment;
};
void main(void)
{
//Data Declaration
struct delivery deliveries[5];
int x, y, z,out, opt, delivery_nos;//each int used for loops
//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==2 && deliveries[0].weight==0)
//{
// message ("Option 2 can only be selected after entering delivery data",5,15);
// 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();
deliveries[x].invoice_no = get_no1(40,5);
deliveries[x].weight = get_no2(46,7);
deliveries[x].quality[0] = get_reply(46,9);
deliveries[x].moisture = get_no3(45,11);
}
for(y=0;y,delivery_nos;y++)
{
if (deliveries[y].moisture<13)
deliveries[y].reduction =0.00;
if (deliveries[y].moisture>12 || deliveries[y].moisture<16)
deliveries[y].reduction = 0.02;
if(deliveries[y].moisture>15)
deliveries[y].reduction=0.05;
if (deliveries[y].quality[0]=='S')
deliveries[y].basic = deliveries[y].weight * 0.176;
else
deliveries[y].basic = deliveries[y].weight * 0.135;
if(deliveries[y].reduction==0.00)
deliveries[y].payment = deliveries[y].basic;
else
deliveries[y].payment = deliveries[y].basic - (deliveries[y].reduction * deliveries[y].weight);
}
}
if (opt==2)
{
set_screen1();
for (z=0;z< delivery_nos; z++)
{
gotoxy(21,out);
if(deliveries[x].basic<0.00)
cout<<"0.00";
else
cout<<deliveries[z].basic;
gotoxy(36,out);
if(deliveries[z].reduction<0.00)
cout<<"0.00";
else
cout<<deliveries[z].reduction;
gotoxy(56,out);
if(deliveries[z].payment<0.00)
cout<<"0.00";
else
cout<<deliveries[z].payment;
//gotoxy(48,19);cout<<total_payment;
}
}
}while(opt!=3);
} // 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;
}
int get_no2( int col, int row) //Number > 0
{
int no; //local variable
gotoxy(col,row); cin >> no;
while ( no <25000 || no>45000)
{
message("No must be between 25000 and 45000", 30,23);
gotoxy(col,row); cout <<" ";
gotoxy(col,row); cin >> no;
}
return no;
}
int get_no3( int col, int row) //Number > 0
{
int no; //local variable
gotoxy(col,row); cin >> no;
while ( no <0 || no>40)
{
message("No must be between 0 and 40", 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 !='S' && c !='F')
{
message("Must be S or F",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 :";
}
|