Wy22’s Weblog

Just another WordPress.com weblog

discon C++

Coba Aja ni sintaknya :

#include <stdio.h>
#include <conio.h>

menu();
void main()
{

  char pil;
  int jb;
  float discon;
  int bayar;
  float totbayar;

  do
  {
   clrscr();

   menu();
   scanf(“%s”,&pil);
    if (pil==’1′)
    {
      printf(“Masukan jumlah pembelian barang = “);scanf(“%d”,&jb);
      bayar= jb *  4000;

      if (bayar > 10000)
      {
        discon= bayar * 0.1;
        totbayar= bayar – discon;
      }
      else
      {
        discon= 0;
        totbayar=bayar – discon;
      }
        printf(“\n”);
        printf(” Jumlah yang di bayar adalah = %d “,bayar);
        printf(“\n Discon yang didapat         = %.2f “,discon);
        printf(“\n Jumlah Total yang harus di bayar adalah     = %.2f “,totbayar);
        getch();

    }
    else
      if (pil==’2′)
       {
          printf(“Masukan jumlah pembelian barang = “);scanf(“%d”,&jb);
          bayar= jb *  8000;

          if (bayar > 20000)
          {
          discon= bayar * 0.2;
            totbayar= bayar – discon;}
          else
           {
             discon= 0;
             totbayar=bayar – discon;
           }
            printf(“\n”);
            printf(” Jumlah yang di bayar adalah = %d “,bayar);
            printf(“\n Discon yang didapat         = %.2f “,discon);
            printf(“\n Jumlah Total yang harus di bayar adalah     = %.2f “,totbayar);
            getch();

       }

  }
  while (pil !=’3′);

}

menu()
{
  printf(“PILIHAN MENU : \n”);
  printf(“=========================================================================\n”);
  printf(“1. Sabun Mandi \n”);
  printf(“2. Pembersih wajah \n”);
  printf(“3. Keluar dari program \n”);
  printf(“=========================================================================\n”);
  printf(“Silahkan Pilih = “);
  return(0);
}

No comments yet.

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

%d bloggers like this: