Monday, October 31, 2022

TUGAS MATERI PERTEMUAN 7



 



Nama : Reza Hidayatulloh
Nim : 3420210019
Prodi : Teknik Informatika



Tugas1


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


 //Nama : Reza Hidayatulloh
 //Nim  : 3420210019
 //Prodi: Teknik Informatika

void main()
{
int i;
   int a = 5;
   int b = 10;
   cout<<"-------------------------------\n";
   cout<<" No  A     B    A*A  B*B\n";
   cout<<"-------------------------------\n";
   for(i=1;i<=10;i++)
   {
    gotoxy(2,3+i);cout<<i;
      gotoxy(6,3+i);cout<<a;
      gotoxy(12,3+i);cout<<b;
      gotoxy(17,3+i);cout<<a*a;
      gotoxy(22,3+i);cout<<b*b;
      a=a+4;
      b=b+2;
      cout<<"\n";
   }
   cout<<"-------------------------------\n";
   getch();
}

Tugas2

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


 //Nama : Reza Hidayatulloh
 //Nim  : 3420210019
 //Prodi: Teknik Informatika

void judul(){
   puts("====================================");
   puts("\tContoh Array Dimensi 1");
   puts("====================================");
   }

 void main()
 {
  judul();
   int i;
   float harga [5];
   harga[0]=1000;
   harga[1]=2000;
   harga[2]=3000;
   harga[3]=4000;
   harga[4]=5000;
   harga[5]=6000;
   printf("Variable harga 1 adalah %.0f\n",harga[1]);
   printf("Variable harga 3 adalah %.0f\n",harga[3]);
   for(i=1;i<=3;i++)
   {
    cout<<endl;
   }
   puts("Nilai dari Seluruh Variabel adalah:");
   for(i=0;i<5;i++)
   {
    printf("variabel harga %d adalah %.0f\n",i,harga[i]);
   }
   getch();
 }


Tugas3


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


 //Nama : Reza Hidayatulloh
 //Nim  : 3420210019
 //Prodi: Teknik Informatika

void judul () {
    puts("========================================");
   puts(" Contoh Array Dimensi 2 ");
   puts("========================================");
}

void main() {
judul();
   int i;
   char hari[7][10]={"Minggu","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu"};
   printf("Hari ke 4 adalah %s\n",hari[4]);
   printf("Hari ke 5 adalah %s\n",hari[5]);
   for(i=1;i<=5;i++) { cout<<endl; }
   puts("Nilai dari seluruh variable hari adalah:");
   for(i=0;i<7;i++) {
   printf("Variable hari %d adalah %s\n",i,hari[i]);
   }
   getch();
}

Friday, October 28, 2022

TUGAS MATERI PERTEMUAN 6

 

Nama : Reza Hidayatulloh

Nim   : 3420210019

Prodi: Teknik Informatika

tugas 1



/*---------------------------*/
/* Program for - bilangan naik */
/*---------------------------*/

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

//Nama : Reza Hidayatulloh
//Nim    : 3420210019
//Prodi : Teknik Informatika

void main ()
{
int a;
   for (a=1;a<=10;a++)
   {
    cout<<"Ini Adalah Baris Ke - " <<a<<endl;
   }
   getch ();
   }

tugas 2


#include <iostream.h>

#include <conio.h>


//Nama : Reza hidaytulloh

//Nim  : 3420210019

//Prodi: Teknik Informatika


void main()

{

puts ("---------------------------");

puts ("   Program For Bersarang   ");

puts ("---------------------------");

int a,b;

   for (a=1;a<=4;a++) {

    for (b=2;b<=2;b++) {

    printf("Latihan Algoritma \n");

      cout<<endl;

      }

   }

   getch ();

}


tugas 3


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

//Nama : Reza hidaytulloh
//Nim  : 3420210019
//Prodi: Teknik Informatika

void main()
{
int a,b;
   for (a=1;a<=5;a++)
   {
    printf ("\n");
for (b=a;b<=5;b++)
      {
      printf ("%d",a);
      }
   }
   getch ();
}

tugas 4


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

//Nama : Reza hidaytulloh
//Nim  : 3420210019
//Prodi: Teknik Informatika

void main()
{
int a,b;
   char lagi;

 atas:
  clrscr();
   cout<<"Masukan Bilangan = ";cin>>a;
   b = a % 2;
   printf ("Nilai %d %% 2 adalah = %d",a,b);
   printf ("\n\nIngin Hitung Lagi [Y/T] : ");
   lagi = getche ();
   if (lagi == 'Y' || lagi == 'y') { goto atas; }
   getch();
 }

tugas 5

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

//Nama : Reza hidaytulloh
//Nim  : 3420210019
//Prodi: Teknik Informatika

void main()
{
int bil = 1;
    while (bil<=10)
    {
    printf (" %d ",bil);
      bil++;
    }
    bil = 2;
    cout<<endl;
    do
    {
    printf (" %d ",bil);
      bil+=2;
    } while (bil <=10);
   getch();
 }

tugas 6

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

//Nama : Reza hidaytulloh
//Nim  : 3420210019
//Prodi: Teknik Informatika

void main()
 {
    int bil = 2;
    int b=0;
    do
    {
    if (bil <20) { printf (" %d +",bil); }
else {printf (" %d = ",bil); }
      b = b + bil;
      bil = bil + 2;
    } while (bil<=20);
    cout<<b;
   getch();
 }

tugas7

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

//Nama : Reza hidaytulloh
//Nim  : 3420210019
//Prodi: Teknik Informatika

void main()
 {
    int a,b,c;
    for (a=2;a<=10;a+=2)
    {
    b=2; c=0;
      do
      {
      c = c + b;
         if (a == b) {cout<<b<<" = "<<c;} else {cout<<b<<" + ";}
         b = b + 2;
      }while (b<=a);
      cout<<endl;
    }
   getch();
 }

tugas 8



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

//Nama : Reza hidaytulloh
//Nim  : 3420210019
//Prodi: Teknik Informatika

void main()
{
    int a,b,c;
    for (a=1;a<=9;a+=2)
    {
    b=1; c=1;
      do
      {
      c = c * b;
         if (a == b) {cout<<b<<" = "<<c;} else {cout<<b<<" * ";}
         b = b + 2;
      }while (b<=a);
      cout<<endl;
    }
   getch();
 }


Tuesday, October 18, 2022

TUGAS MATERI PERTEMUAN 5

 






Nama : Reza Hidayatulloh
Nim : 3420210019
Prodi : Teknik Informatika


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

//Nama : Reza hidaytulloh
//Nim  : 3420210019
//Prodi: Teknik Informatika

void main  ()
 {
 char kode, lagi;

 //Deklarasi Label
 atas:
 clrscr();
 cout<<"input your size catalog shirt [S/M/L] : ";
 kode = getche ();
 cout<<'\n';
 switch (kode) {
   case 'S': case 's':
 cout<<"why not"; break;
   case 'M': case 'm':
 cout<<"suicidal anthem"; break;
   case 'L': case 'l':
 cout<<"calvin klein"; break;
   default:
   cout<<"Anda Salah Memasukan Kode";
 }
 cout<<'\n';
 cout<<"\nYou want buy more? [Y/T]: ";
 lagi = getche();
 if(lagi == 'Y' || lagi == 'y') goto atas;
 getch();
}



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

//Nama : Reza Hidayatulloh
//Nim  : 3420210019
//prodi: Teknik Informatika
 void main  ()
 {
  char kode, lagi; char nama[50], bonus[50];
   int jml; float harga, total, pot, ppn, grand;
 lagi:
  clrscr();
   puts("****************************************");
   printf("Masukan Kode laptop [1/2/3]: ");cin>>kode;
   printf("Jumlah Pembelian laptop    : ");cin>>jml;
   switch (kode)  {
    case '1':
      strcpy(nama,"asus tuf gaming"); harga = 9000000;
         break;
      case '2':
      strcpy(nama,"msi gf63 thin 11c"); harga = 8000000;
         break;
      default:
      strcpy(nama,"acer nitro");
         harga = 9000000;
   }

   total = harga * jml; ppn = 0.1 * total;

   if(jml>5) {
    strcpy(bonus,"keyboard srgb");
      pot = 0.1 * total;
   } else {
    strcpy(bonus,"Maaf ya Tidak Dapat Bonus");
      pot = 0;
   }
   grand = total + ppn - pot;
   clrscr();
   puts("-----------------------------------------");
   puts("          ***Berkah Jaya***");
   puts("           Jl. Kesetiaan No.01");
   puts("-----------------------------------------");
   cout<<"Nama laptop : "<<nama  <<endl;
   cout<<"Harga laptop: "<<harga <<endl;
   cout<<"Bonus       : "<<bonus <<endl;
   cout<<"Total Bayar : "<<total <<endl;
   cout<<"Potongan    : "<<pot   <<endl;
   cout<<"PPN         : "<<ppn   <<endl;
   cout<<"Grand Total : "<<grand <<endl;
   puts("-----------------------------------------");
   puts("           ***Terima Kasih***            ");
   cout<<"           Input Data Lagi...?";cin>>lagi;
   if (lagi == 'y' || lagi == 'y') {goto lagi;}

getch();
 }



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

//Nama : Reza hidaytulloh
//Nim  : 3420210019
//Prodi: Teknik Informatika

void main()

{

char nama[20],tipe[20],souvenir[20];
char kode,lagi;
int lama;
float harga,total,admin=200000,ubay,ukem;



awal:

clrscr();
puts("PENGINAPAN ATIKA HOTEL");
puts("********************************");
cout<<"Nama Penyewa      : ";cin>>nama;
cout<<"Kode Kamar [S/F/D]: ";cin>>kode;



if (kode == 'S' || kode == 's')
{
strcpy(tipe,"Superior Room");
harga = 400000;
}
else if (kode == 'F' || kode == 'f')
{
strcpy(tipe,"Family Room");
harga = 300000;
}
else if (kode == 'D' || kode == 'd')
{
strcpy(tipe,"Deluxe Room");
harga = 200000;
}
else
{
puts("******************************");
cout<<"Kode kamar yang anda masukan salah, ingin input lagi?";
cin>>lagi;
switch(lagi)
{
case 'Y':
case 'y':
goto awal;
default:
goto akhir;
}
}


clrscr();
puts("PENGINAPAN ATIKA HOTEL");
puts("******************************");
cout<<"Nama Penyewa      : "<<nama<<endl;
cout<<"Kode Kamar [S/F/D]: "<<kode<<endl;
cout<<"Lama Menginap     : ";cin>>lama;
puts("******************************");
if (lama>=5)
{
strcpy(souvenir,"Selimut Batik");
}
else
{
strcpy(souvenir,"Tidak Dapat");
}

total = (harga * lama) + admin;


cout<<"Tipe Kamar \t\t: "<<tipe<<endl;
cout<<"Lama Menginap \t\t: "<<lama<<" hari"<<endl;
cout<<"Souvenir \t\t: "<<souvenir<<endl;
printf("Biaya Sewa \t\t: Rp.%8.2f \n",harga);
printf("Biaya Administrasi \t: Rp.%8.2f \n",admin);
printf("Total Biaya Sewa \t: Rp.%8.2f \n",total);
puts("******************************");
cout<<"Uang Bayar : ";cin>>ubay;
ukem = ubay - total;
   cout<<"Uang kembali : "<<ukem<<endl;
   cout<<"Ingin input lagi [Y/T] ";cin>>lagi;
switch(lagi)

{
case 'Y':
case 'y':
goto awal;
default:
goto akhir;
}

akhir:
getch();
}