hi i am making a program where you enter the data with one program and if the values are less than a number it will tell you to reorder so many more it then goes into a txt file and then i want to have another file read specific lines from that txt file like if the values are less it then writes it to a file(the ones i want) plus if i do reorder the parts i want to know the total. using Dev C++ Thanks a bunch
input file:
Code:#include<iostream> #include<string> #include<fstream> using namespace std; using std::string; string Part1; string Part2; string Part3; string Part4; string Part5; string des1; string des2; string des3; string des4; string des5; float qual1; float qual2; float qual3; float qual4; float qual5; float order1; float order2; float order3; float order4; float order5; float quan1; float quan2; float quan3; float quan4; float quan5; float cost1; float cost2; float cost3; float cost4; float cost5; float total1; float total2; float total3; float total4; float total5; int main(){ fstream file("Part.txt",ios::out); cout<<"Part Number: "; cin>>Part1; file<<Part1<<endl; cout<<"Part Description: "; cin>>des1; file<<des1<<endl; cout<<"Quality on Hand: "; cin>>qual1; file<<qual1<<endl; cout<<"Unit Cost: "; cin>>cost1; file<<cost1<<endl; cout<<"Part Number: "; cin>>Part2; file<<Part2<<endl; cout<<"Part Description: "; cin>>des2; file<<des2<<endl; cout<<"Quality on Hand: "; cin>>qual2; file<<qual2<<endl; cout<<"Unit Cost: "; cin>>cost2; file<<cost2<<endl; cout<<"Part Number: "; cin>>Part3; file<<Part3<<endl; cout<<"Part Description: "; cin>>des3; file<<des3<<endl; cout<<"Quality on Hand: "; cin>>qual3; file<<qual3<<endl; cout<<"Unit Cost: "; cin>>cost3; file<<cost3<<endl; cout<<"Part Number: "; cin>>Part4; file<<Part4<<endl; cout<<"Part Description: "; cin>>des4; file<<des4<<endl; cout<<"Quality on Hand: "; cin>>qual4; file<<qual4<<endl; cout<<"Unit Cost: "; cin>>cost4; file<<cost4<<endl; cout<<"Part Number: "; cin>>Part5; file<<Part5<<endl; cout<<"Part Description: "; cin>>des5; file<<des5<<endl; cout<<"Quality on Hand: "; cin>>qual5; file<<qual5<<endl; cout<<"Unit Cost: "; cin>>cost5; file<<cost5<<endl; if (qual1<=150){total1=cost1*200; file<<"Reorder 200 of Part number xl101 now!"<<endl; file<<Part1<<" total reorder cost: $"<<total1<<endl;} if (qual2<=250){total2=cost2*300; file<<"Reorder 300 of Part Number xm215 now!"<<endl; file<<Part2<<" total reorder cost: $"<<total2<<endl;} if (qual3<=115){total3=cost3*150; file<<"Reorder 150 of Part Number xr218 now!"<<endl; file<<Part3<<" total reorder cost: $"<<total3<<endl;} if (qual4<=435){total4=cost4*500; file<<"Reorder 500 of Part Number xg321 now!"<<endl; file<<Part4<<" total reorder cost: $"<<total4<<endl;} if (qual5<=250){total5=cost5*750; file<<"Reorder 750 of Part Number xk178 now!"<<endl; file<<Part5<<" total reorder cost: $"<<total5<<endl;} file.close(); system("pause"); return 0; }
and here is the file that reads it. (file that has the errors on it)
Code:#include<iostream> #include<string> #include<fstream> using namespace std; using std::string; string Part1; string Part2; string Part3; string Part4; string Part5; float qual1; float qual2; float qual3; float qual4; float qual5; float cost1; float cost2; float cost3; float cost4; float cost5; float total1; float total2; float total3; float total4; float total5; int main(){ ifstream file; string qual1; string qual2; string qual3; string qual4; string qual5; string cost1; string cost2; string cost3; string cost4; string cost5; string total1; string total2; string total3; string total4; string total5; file.open("Part.txt"); getline(file,Part1); getline(file,Part2); getline(file,Part3); getline(file,Part4); getline(file,Part5); getline(file,qual1); getline(file,qual2); getline(file,qual3); getline(file,qual4); getline(file,qual5); getline(file,cost1); getline(file,cost2); getline(file,cost3); getline(file,cost4); getline(file,cost5); getline(file,total1); getline(file,total2); getline(file,total3); getline(file,total4); getline(file,total5); if (qual1<=150){total1=cost1*200; cout<<"Reorder 200 of Part number:"<<Part1<<" now!"<<endl; cout<<Part1<<" total reorder cost: $"<<total1<<endl;} if (qual2<=250){total2=cost2*300; cout<<"Reorder 300 of Part Number:"<<Part2<<" now!"<<endl; cout<<Part2<<" total reorder cost: $"<<total2<<endl;} if (qual3<=115){total3=cost3*150; cout<<"Reorder 150 of Part Number:"<<Part3<<" now!"<<endl; cout<<Part3<<" total reorder cost: $"<<total3<<endl;} if (qual4<=435){total4=cost4*500; cout<<"Reorder 500 of Part Number:"<<Part4<<" now!"<<endl; cout<<Part4<<" total reorder cost: $"<<total4<<endl;} if (qual5<=250){total5=cost5*750; cout<<"Reorder 750 of Part Number:"<<Part5<<" now!"<<endl; cout<<Part5<<" total reorder cost: $"<<total5<<endl;} file.close(); system("pause"); return 0; }



LinkBack URL
About LinkBacks



