Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string.h>
- using namespace std;
- class CMhs {
- private:
- char*NRP, *Nama, *Prodi;
- float IPK;
- int sks;
- public:
- CMhs() {
- NRP = new char[15];
- Nama = new char[20];
- Prodi = new char[20];
- IPK = 4.0;
- sks = 24;
- }
- CMhs(char*nrp, char*nama, char*prodi, float ipk, int SKS) {
- NRP = new char[15];
- Nama = new char[20];
- Prodi = new char[20];
- strcpy(NRP, nrp);
- strcpy(Nama, nama);
- strcpy(Prodi, prodi);
- IPK = ipk;
- if (SKS != NULL)
- {
- sks = SKS;
- }
- else
- {
- if (ipk <= 3.0)
- {
- sks = 20;
- }
- else {
- sks = 24;
- }
- }
- }
- CMhs(const CMhs &a) {
- NRP = new char[15];
- Prodi = new char[strlen(a.Prodi)];
- Nama = new char[strlen(a.Nama)];
- strcpy(NRP, a.NRP);
- strcpy(Nama, a.Nama);
- strcpy(Prodi, a.Prodi);
- IPK = a.IPK;
- sks = a.sks;
- }
- void setNama(const char*a) {
- Nama = new char[20];
- strcpy(Nama, a);
- }
- void setIPK(float a) {
- IPK = a;
- if (a <= 3.0)
- {
- sks = 20;
- }
- else {
- sks = 24;
- }
- }
- void display();
- };
- void CMhs::display() {
- cout << "NRP\t" << "Nama\t" << "Prodi\t" << "IPK\t" << "SKS Ambil\n";
- cout << NRP << "\t" << Nama << "\t" << Prodi << "\t" << IPK << "\t" << sks << endl;
- }
- void main() {
- CMhs A("C14170900", "Dina", "Informatika", 3.49, 23) , B , C[10];
- B = A;
- B.setNama("Dini"); B.setIPK(2.5);
- A.display();
- B.display();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement