Selasa, 01 Maret 2011

Script Bahasa C untuk Kalkulator Sederhana

#include
#include

int main()
{
printf("================================================\n");
printf(" Automation Engineering \n");
printf(" Surabaya Shipbuilding State of Polytechnic \n");
printf(" Sepuluh Nopember Institute of Technology \n");
printf("================================================\n");
printf(" BRILIANTA FANNI SAIFULLAH \n");
printf(" NRP 6910040050 \n");
printf("================================================\n");
printf(" Calculator Project \n");
printf("================================================\n");

printf(" \n");
printf(" \n");


int valid_operator =1;
char operator;
float Number1,Number2,result;

printf("Masukkan 2 Bilangan yang Diinginkan\n");
printf("Dengan format => Bilangan1 - operator - Bilangan2\n");

printf(" \n");
printf(" \n");

scanf("%f %c %f", &Number1, &operator, &Number2);
if (operator == '*')
result = Number1*Number2;
if (operator == '/')
result = Number1/Number2;
if (operator == '+')
result = Number1+Number2;
if (operator == '-')
result = Number1-Number2;
if (valid_operator);
printf("= %g",result);


scanf("%f %c %f", &Number1, &operator, &Number2);
if (operator == '*')
result = Number1*Number2;
if (operator == '/')
result = Number1/Number2;
if (operator == '+')
result = Number1+Number2;
if (operator == '-')
result = Number1-Number2;
if (valid_operator);
printf("= %g",result);

scanf("%f %c %f", &Number1, &operator, &Number2);
if (operator == '*')
result = Number1*Number2;
if (operator == '/')
result = Number1/Number2;
if (operator == '+')
result = Number1+Number2;
if (operator == '-')
result = Number1-Number2;
if (valid_operator);
printf("= %g",result);


scanf("%f %c %f", &Number1, &operator, &Number2);
if (operator == '*')
result = Number1*Number2;
if (operator == '/')
result = Number1/Number2;
if (operator == '+')
result = Number1+Number2;
if (operator == '-')
result = Number1-Number2;
if (valid_operator);
printf("= %g",result);


printf(" \n");
printf(" \n");

printf("================================================\n");
printf(" CopyRight By Brilianta | 2011 \n");
printf(" briliant_46@yahoo.com \n");
printf("================================================\n");
return 0;
}

ini hasil run dari script di atas

Tidak ada komentar:

Posting Komentar