Physics Instrumentation

Contoh Script C++

Kumpulan tugas Mata Kuliah Algoritma Pemrograman Semester III :

Gambar terkait

1. Anda Sehat???

#include <iostream.h>
#include <conio.h>

main ()
{
char c ;
cout<<“Apakah kamu sehat?”,c;
cin>>c;

if(c== ‘Y’ || c== ‘y’)
cout<<“Selamat anda mengikuti pelajaran”,c;

else
if(c==’N’ || c==’n’)
cout<<“Maaf Anda harus  pergi ke dokter”,c;

cout<<endl;

cout<<“Tekan ENTER untuk keluar”;
getch();
}

 

2. Hello World

#include <conio.h>
#include <iostream.h>

main ()
{
cout<<“Hello World”;
getch();
}

 

3. Pengurangan

#include <iostream.h>
#include <conio.h>

int main ()
{
int a,b,hasil;
cout<<“Nilai a = “;
cin>>a;
cout<<“Nilai b = “;
cin>>b;
hasil=a-b;
cout<<“hasil pengurangan (a-b) = “<<hasil;
getch ();
}

 

4. Konversi Suhu C, F, R, K (cout, cin)

#include <iostream.h>
#include <conio.h>

main ()
{
cout<<“Aprilia Erlita Lisnawati”;
cout<<endl;
cout<<“Instrumentasi 3B”;
cout<<endl;
cout<<“42.17.0031”;
cout<<endl;
cout<<endl;

cout<<“==================================================”;
cout<<endl;
cout<<”                  KONVERSI SUHU”;
cout<<endl;
cout<<“==================================================”;
cout<<endl<<endl;

float c,f,r,k;
cout<<“Suhu dalam derajat Celcius = “;
cin>>c;
cout<<endl;
cout<<“Berikut ini hasil konversi suhu ke F, R, K :”;
cout<<endl<<endl;

f=(9*(c/5))+32;
r=(4*(c/5));
k=c+273;

cout<<“Nilai Fahrenheit (F) = “<<f;
cout<<endl;
cout<<“Nilai Reamur (R)     = “<<r;
cout<<endl;
cout<<“Nilai Kelvin (K)     = “<<k;
cout<<endl;

getch ();
}

 

5. Konversi Suhu C, F, R, K (if, else)

#include <iostream.h>
#include <conio.h>

main ()
{
cout<<“Aprilia Erlita Lisnawati”;
cout<<endl;
cout<<“Instrumentasi 3B”;
cout<<endl;
cout<<“42.17.0031”;
cout<<endl;
cout<<endl;

cout<<“==================================================”;
cout<<endl;
cout<<”                  KONVERSI SUHU”;
cout<<endl;
cout<<“==================================================”;
cout<<endl<<endl;

int satuan;
float suhu,C1,F2,K3,R4,F5,K6,R7,C8,K9,R10,C11,F12;
cout<<endl<<endl;
cout<<“Masukkan satuan suhu yang akan dikonversi : “;
cout<<endl<<endl;
cout<<“1. Reamur”;
cout<<endl;
cout<<“2. Celcius”;
cout<<endl;
cout<<“3. Fahrenheit”;
cout<<endl;
cout<<“4. Kelvin”;
cout<<endl<<endl;
cout<<“1/2/3/4 = “;
cin>>satuan;
cout<<endl;
cout<<“Masukkan nilai suhu = “;
cin>>suhu;
cout<<endl<<endl;

if (satuan==1)
{
C1=(5/4)*suhu;
F2=((9/4)*suhu)+32;
K3=((5/4)*suhu)+273;
cout<<“Celcius    = “<<C1;
cout<<endl;
cout<<“Fahrenheit = “<<F2;
cout<<endl;
cout<<“Kelvin     = “<<K3;
cout<<endl;
}
else
if (satuan==2)
{
R4=(4*(suhu/5));
F5=(9*(suhu/5))+32;
K6=suhu+273;
cout<<“Reamur     = “<<R4;
cout<<endl;
cout<<“Fahrenheit = “<<F5;
cout<<endl;
cout<<“Kelvin     = “<<K6;
cout<<endl;
}
else
if (satuan==3)
{
R7=((4/9)*suhu)-32;
C8=((5/9)*suhu)-32;
K9=((5/9)*suhu)-32+273;
cout<<“Reamur     = “<<R7;
cout<<endl;
cout<<“Celcius    = “<<C8;
cout<<endl;
cout<<“Kelvin     = “<<K9;
cout<<endl;
}
else
if (satuan==4)
{
R10=(4/5)*suhu-273;
C11=suhu-273;
F12=(9/5)*suhu+32-273;
cout<<“Reamur     = “<<R10;
cout<<endl;
cout<<“Celcius    = “<<C11;
cout<<endl;
cout<<“Fahrenheit = “<<F12;
cout<<endl;
}

cout<<endl;
cout<<“==================================================”;

getch();
}

 

6. Pengecekan Plausible AWS pada tekanan dan suhu

#include <iostream>
#include <stdio>
//using namespace std;
int main()
{
int jumlah;
char id[10][25];
int e;
int t;
float nilai[10];
float tekanan[10];
cout<<“Aprilia Erlita Lisnawati\n”;
cout<<“Instrumentasi 3B\n”;
cout<<“42.17.0031\n\n”;
cout<<“================================================\n”;
cout<<”   QC (Quality Control) Pengukuran Suhu AWS\n”;
cout<<“================================================\n”;
MULAI:cout<<“\nMasukkan jumlah AWS yang akan dievaluasi: “;
cin>>jumlah;
if (jumlah<=10){
for (int i=0;i<jumlah;i++){
cout<<“\nMasukkan nama / id AWS / lokasi AWS : “;
cin>>id[i];
cout<<“Masukkan nilai pengukuran tekanan   : “;
cin>>tekanan[i];
cout<<“Masukkan nilai pengukuran suhu      : “;
cin>>nilai[i];
}
}else{
cout<<“## Jumlah yang Anda input melampaui index ##\n”;
goto MULAI;
}
cout<<“\n## Plausible Check Evaluation##\n\n”;
for (int i=0;i<jumlah;i++){
if (nilai[i]>60 || nilai[i]<-80){
cout<<id[i]<<” dengan nilai pengukuran suhu “<<nilai[i]<<” tidak lolos QC Plausible Check\n”;
nilai [i] = 1;
nilai [i] = nilai [i]++;
e = ((jumlah – nilai [i]) / jumlah) * 100;
} else {
cout<<id[i]<<” dengan nilai pengukuran suhu “<<nilai[i]<<” lolos QC Plausible Check\n”;
nilai [i] = 0;
}
}
cout<<“\n## Plausible Check Evaluation##\n\n”;
for (int i=0;i<jumlah;i++){
if (tekanan[i]>1000 || tekanan[i]<-500){
cout<<id[i]<<” dengan nilai pengukuran tekanan “<<tekanan [i]<<” tidak lolos QC Plausible Check\n”;
tekanan [i] = 1;
tekanan [i] = tekanan [i]++;
t = ((jumlah – tekanan [i]) / jumlah) * 100;
} else {
cout<<id[i]<<” dengan nilai pengukuran tekanan “<<tekanan [i]<<” lolos QC Plausible Check\n”;
tekanan [i] = 0;
}
}
cout<<“\n\nNilai Evaluasi Pengukuran suhu   : “<<e<<“%\n”;
cout<<“Nilai Evaluasi Pengukuran tekanan: “<<t<<“%\n”;
getchar();
return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s