28 Nisan 2012, 10:31
#1 Çevrimdışı
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
Girilen Öğrenci Bilgilerini Dosyaya Yazdırma
Girilen Öğrenci Bilgilerini Dosyaya Yazdıran Programın kaynak kodları
PHP Kod: Kodu kopyalamak için üzerine çift tıklayın!
#include<iostream>
#include<string>
#include<fstream>
using namespace std ;
class ogrenci {
private:
string ad ;
string soyad ;
int note [ 3 ];
float ort ;
public:
ogrenci (): ort ( 5 )
{}
void bilgiAl ();
void ortBul (){
int toplam = 0 ;
for( int i = 0 ; i < 3 ; i ++){
toplam = toplam + note [ i ];
}
ort =(float) toplam / 3 ;
cout << "ortalama=" << ort << endl ;
}
void dosyaYaz (){
ofstream dosya ;
dosya . open ( "yazı.txt" );
dosya << "ogrencinin adi=" << ad << endl ;
dosya << "ogrencinin soyadi=" << soyad << endl ;
for( int i = 0 ; i < 3 ; i ++){
dosya << "Not " << i + 1 << " =" << note [ i ]<< endl ;
}
dosya << "ortalama=" << ort << endl ;
dosya . close ();
}
};
void ogrenci :: bilgiAl (){
string ad1 ;
string soyad1 ;
int note1 [ 3 ];
cout << "ogrencinin adi=" ; cin >> ad1 ;
cout << "ogrencinin soyadi=" ; cin >> soyad1 ;
for( int i = 0 ; i < 3 ; i ++){
cout << "note=" ;
cin >> note1 [ i ];
note [ i ]= note1 [ i ];
}
for( int i = 0 ; i < 3 ; i ++){
cout << "Not " << i + 1 << " =" << note [ i ]<< endl ;
}
ad = ad1 ;
soyad = soyad1 ;
}
int main ()
{
ogrenci x [ 5 ];
for( int i = 0 ; i < 5 ; i ++){
x [ i ]. bilgiAl ();
x [ i ]. ortBul ();
x [ i ]. dosyaYaz ();
}
system ( "pause" );
return 0 ;
}
__________________ Kullanıcı imzalarındaki bağlantı ve resimleri görebilmek için en az 20 mesaja sahip olmanız gerekir ya da üye girişi yapmanız gerekir.