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
|
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
double cost(int n,int m, double k)
{
double cost = n+((k-0.5)*m) ;
return cost;
}
void main()
{
int A[100],B[100],C[100],D[100],E[100],ides[100],w[100],firstkilo[100],addkilo[100];
ifstream InF;
int a,b,c,d,e,f, num1,x,y,n,k,counter;
double h;
InF.open("d:\\destination.txt");
ifstream IF("d:\\shipments.txt");
ofstream OF("d:\\shipments.txt");
string name1;
char ans='y';
for(int j=0;j<100;j++){
InF>>num1>>name1>>x>>y;
ides[j]=num1;
firstkilo[j]=x;
addkilo[j]=y;
}
for(int i=0;i<100 && !InF.eof();i++){
IF>>a>>b>>c>>d>>e;
A[i]=a;
B[i]=b;
C[i]=c;
counter=i;
cout <<A[i];
}
while(tolower(ans)=='y'){
cout<<"enter the ship ID to edit ";
cin>>n;
for(int i=0;i<counter;i++){
if(n==A[i]){
cout<<"enter new destination ID "<<endl;
cin>>k;
for(int j=0;j<100;j++){
if(k==ides[j]){
D[i]=firstkilo[j];
E[i]=addkilo[j];
cout<<"enter the weight"<<endl;
cin>>h;
w[i]=h;
}
}
}
}
cout<<"continue? "<<endl;
}
for(int i=0;i<counter;i++){
OF<<A[i]<<" "<<B[i]<<" "<<C[i]<<" "<<w[i]<<cost( D[i], E[i], w[i]);
}
}
|