pada kali ini saya kan share bagaiman cara mencari nilai seluruh gaji
tampilan nya seperti ini
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string>
using namespace std;
struct node
{
int nim;
string nama;
int umur;
int gaji;
node *next;
};
main()
{
struct node *n, *t, *h, *t1;
char jawab = 'y';
int total = 0;
int jumlah=0;
float rata_rata;
n = t = h = NULL;
while (jawab != 'n')
{
n=new node;
n -> next = NULL;
cout << "Masukkan NIM : ";
cin >> n -> nim;
cout << "Masukkan Nama: ";
cin >> n -> nama;
cout << "Masukkan Umur: ";
cin >> n -> umur;
cout << "Masukkan Gaji: ";
cin >> n -> gaji;
total = n ->gaji;
jumlah++;
if (h == NULL)
{
t = n;
h = n;
}
else
{
t -> next = n;
t = n;
}
cout << "Masih ada lagi? (y/n) : ";
cin >> jawab;
cout << "\n";
}
cout << "=============================================================================\n";
cout << "Tampilkan data yang telah diinput...\n";
getch();
cout << "Data-data yang sudah di input : \n\n";
t1=h;
while (t1 -> next != NULL)
{
cout << "NIM : " << t1 -> nim << "\n";
cout << "Nama : " << t1 -> nama << "\n";
cout << "Umur : " << t1 -> umur << "\n";
cout << "Gaji : " << t1 -> gaji << "\n\n";
total = total + t1 -> gaji;
rata_rata=total/jumlah;
t1 = t1 -> next;
}
cout << "NIM : " << t1 -> nim << "\n";
cout << "Nama : " << t1 -> nama << "\n";
cout << "Umur : " << t1 -> umur << "\n";
cout << "Gaji : " << t1 -> gaji << "\n\n";
cout << "\n" << "total gaji :";
cout << total;
cout << "\n" << "rata-rata gaji :";
cout << rata_rata;
getch();
}
tampilan nya seperti ini
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string>
using namespace std;
struct node
{
int nim;
string nama;
int umur;
int gaji;
node *next;
};
main()
{
struct node *n, *t, *h, *t1;
char jawab = 'y';
int total = 0;
int jumlah=0;
float rata_rata;
n = t = h = NULL;
while (jawab != 'n')
{
n=new node;
n -> next = NULL;
cout << "Masukkan NIM : ";
cin >> n -> nim;
cout << "Masukkan Nama: ";
cin >> n -> nama;
cout << "Masukkan Umur: ";
cin >> n -> umur;
cout << "Masukkan Gaji: ";
cin >> n -> gaji;
total = n ->gaji;
jumlah++;
if (h == NULL)
{
t = n;
h = n;
}
else
{
t -> next = n;
t = n;
}
cout << "Masih ada lagi? (y/n) : ";
cin >> jawab;
cout << "\n";
}
cout << "=============================================================================\n";
cout << "Tampilkan data yang telah diinput...\n";
getch();
cout << "Data-data yang sudah di input : \n\n";
t1=h;
while (t1 -> next != NULL)
{
cout << "NIM : " << t1 -> nim << "\n";
cout << "Nama : " << t1 -> nama << "\n";
cout << "Umur : " << t1 -> umur << "\n";
cout << "Gaji : " << t1 -> gaji << "\n\n";
total = total + t1 -> gaji;
rata_rata=total/jumlah;
t1 = t1 -> next;
}
cout << "NIM : " << t1 -> nim << "\n";
cout << "Nama : " << t1 -> nama << "\n";
cout << "Umur : " << t1 -> umur << "\n";
cout << "Gaji : " << t1 -> gaji << "\n\n";
cout << "\n" << "total gaji :";
cout << total;
cout << "\n" << "rata-rata gaji :";
cout << rata_rata;
getch();
}
Jangan Lupa commen nya dan kunjungi terus blog saya http://berbagitips46.blogspot.com atau http://sahatpg.wordpress.com/
supaya saya lebih giat lagi untuk mencari aplikasi-aplikasi yang
terbaru atau anda bisa request software yang anda ingin kan siapa tau
saya bisa bantu cari
sekian terimakasih semoga bermanfaat ^_^
sekian terimakasih semoga bermanfaat ^_^
0 comments:
Post a Comment