You are on page 1of 1

TUGAS PROGRAM MANIPULASI FILE

AHSAN WALAD
S1 TEKNIK ELEKTRO Off.A
160536612053

#include <iostream.h>
#include <fstream.h>
#include <string.h>
#include <stdlib.h>
float level_air(int x)
{
return x-0.15;
}
float suhu_air(int x)
{
return x+0.10;
}
int main() {
system("color 70");
char p='y';
while(p=='y')
{
using namespace std;
ifstream data("file.txt");
char kata[1000];
int data_[100][2];
float hasil[100][2];
int tmp=0;
int ngitung=0;
while (!data.eof())
{
for(int a=0; a<2; a++)
{
data>>kata;
data_[tmp][a]=atoi(kata);
}
tmp++;
ngitung++;
}
data.close();
cout<<"=================================================="<<endl;
cout<<"| level air | suhu air |
level
|
suhu
|"<<endl;
cout<<"=================================================="<<endl;
for(int q=0; q<ngitung; q++)
{
hasil[q][0]=level_air(data_[q][0]);
hasil[q][1]=suhu_air(data_[q][1]);
cout<<"|
"<<data_[q][0]<<"
|
"<<data_[q][1]<<"
|
"<<hasil[q][0]<<"
|
"<<hasil[q][1]<<"
|"<<endl;
}
cout<<"=================================================="<<endl;
cout<<" Tampilkan lagi??";
cin>>p;
}
return 0;
}

-- SCREENSHOT HASIL PROGRAM -File.txt


43
54
32
46
47
50
60
89
90
16
13

31
66
48
24
11
91
30
95
87
19
15

You might also like