HelpMeOutAlways: Projects
Showing posts with label Projects. Show all posts
Showing posts with label Projects. Show all posts

Saturday, March 2, 2019

Logic Gates Program In Java(Project)
March 02, 20190 Comments

Source Code



import java.util.Scanner;
//=====================================================================================================================
class star{
      public void star(){
        for(int i=1;i<=50;i++){
            System.out.print("*");
        }
    }
}
class OrGate extends star{
    int or1,or2;

    public void getSet(){
        Scanner Sc=new Scanner(System.in);
     
        System.out.println("\nEnter your Two numbers(either(1/0))\n");
        or1=Sc.nextInt();
        or2=Sc.nextInt();
    }
    public void or(){
        if((or1==0)&&(or2==0)){
            System.out.println("Your output is:");
            System.out.println("0");
        }
        else{
            System.out.println("Your Output is:");
            System.out.println("1");
        }
    }
}
//======================================================================
class AndGate extends star{
    int and1,and2;
 
    public void getSet(){
        Scanner Sc=new Scanner(System.in);
     
        System.out.println("\nEnter your Two numbers(either(1/0))\n");
        and1=Sc.nextInt();
        and2=Sc.nextInt();
    }
    public void and(){
        if((and1==1)&&(and2==1)){
            System.out.println("Your output is:");
            System.out.println("1");
        }
        else{
            System.out.println("Your Output is:");
            System.out.println("0");
        }
    }
}




//======================================================================

class NotGate extends star{
    int not1,not2;
 
    public void getSet(){
        Scanner Sc=new Scanner(System.in);
     
        System.out.println("\nEnter your one numbers(either(1/0))\n");
        not1=Sc.nextInt();
        //not2=Sc.nextInt();
    }
    public void or(){
        if(not1==0){
            System.out.println("Your output is:");
            System.out.println("1");
        }
        else if(not1==1){
            System.out.println("Your Output is:");
            System.out.println("0");
        }
        else{
            System.out.println("Invalid Input");
        }
    }
}

//======================================================================
class NorGate extends star{
    int nor1,nor2;
 
    public void getSet(){
        Scanner Sc=new Scanner(System.in);
     
        System.out.println("\nEnter your Two numbers(either(1/0))\n");
        nor1=Sc.nextInt();
        nor2=Sc.nextInt();
    }
    public void nor(){
        if((nor1==0)&&(nor2==0)){
            System.out.println("Your output is:");
            System.out.println("1");
        }
        else {
            System.out.println("Your Output is:");
            System.out.println("0");
        }
     
    }
}

//======================================================================
class NandGate extends star{
    int nand1,nand2;
 
    public void getSet(){
        Scanner Sc=new Scanner(System.in);
     
        System.out.println("\nEnter your Two numbers(either(1/0))\n");
        nand1=Sc.nextInt();
        nand2=Sc.nextInt();
    }
    public void nand(){
        if((nand1==1)&&(nand2==1)){
            System.out.println("Your output is:");
            System.out.println("0");
        }
        else {
            System.out.println("Your Output is:");
            System.out.println("1");
        }
     
    }
}

//======================================================================
class XorGate extends star{
    int xor1,xor2;
 
    public void getSet(){
        Scanner Sc=new Scanner(System.in);
     
        System.out.println("\nEnter your Two numbers(either(1/0))\n");
        xor1=Sc.nextInt();
        xor2=Sc.nextInt();
    }
    public void xor(){
        if(xor1==xor2){
            System.out.println("Your Output is");
            System.out.println("0");
         
        }
        else if(xor1==xor2){
             System.out.println("Your Output is");
         System.out.println("0");
        }
        else{
            System.out.println("1");

        }
    }
}
//======================================================================
class XnorGate extends star{
    int xnor1,xnor2;
 
    public void getSet(){
        Scanner Sc=new Scanner(System.in);
     
        System.out.println("\nEnter your Two numbers(either(1/0))\n");
        xnor1=Sc.nextInt();
        xnor2=Sc.nextInt();
    }
    public void xnor(){
        if((xnor1==1)&&(xnor2==1)){
            System.out.println("Your output is:");
            System.out.println("1");
        }
        else if((xnor1==0)&&(xnor2==0)) {
            System.out.println("Your Output is:");
            System.out.println("1");
        }
        else{
            System.out.println("0");
        }
     
    }
}
//======================================================================
public class Main{
    public static void main(String args[]){
 System.out.println("Note: You have to give input either 1 or 0");     
System.out.println("1. OR Gate");
System.out.println("2.AND Gate");
System.out.println("3. NOT Gate");
System.out.println("4. NOR Gate");
System.out.println("5. NAND Gate");
System.out.println("6. XOR Gate");
System.out.println("7. XNOR Gate");
System.out.println("Which operation would you like to perform:");     
int menu;
 Scanner In=new Scanner(System.in);
 menu=In.nextInt();
 
    switch(menu){
    case 1:
       
         OrGate obj1=new OrGate();
         obj1.star();
         System.out.println("\nOR Gate\n");
         obj1.star();
        obj1.getSet();
        obj1.or();
     
       break;
     case 2:
         AndGate obj2=new AndGate();
         obj2.star();
         System.out.println("\nAND Gate\n");
         obj2.star();
        obj2.getSet();
        obj2.and();
     
        break;
    case 3:
        NotGate obj3=new NotGate();
        obj3.star();
         System.out.println("\n NOT Gate\n");
         obj3.star();
        obj3.getSet();
        obj3.or();
        break;
     
     
    case 4:
        NorGate obj4=new NorGate();
        obj4.star();
         System.out.println("\nNOR Gate\n");
         obj4.star();
        obj4.getSet();
        obj4.nor();
        break;
    case 5:
        NandGate obj5=new NandGate();
        obj5.getSet();
        obj5.nand();
     
        break;
    case 6:
         XorGate obj6=new XorGate();
         obj6.star();
         System.out.println("\n XOR Gate\n");
         obj6.star();
        obj6.getSet();
        obj6.xor();
     
        break;
    case 7:
         XnorGate obj7=new XnorGate();
         obj7.star();
         System.out.println("\n XNOR Gate\n");
         obj7.star();
        obj7.getSet();
        obj7.xnor();
     
        break;
    default:
    System.out.println("Invalid Input");
     
     
    }
    }

 
    }

Output

logic gate program

logic gates

 

Reading Time:

Sunday, June 10, 2018

ATM Program In C language (SHows Notes of 5000,1000,500,100,50 and 10)
June 10, 20181 Comments
Here you can find the source code of ATM Machine Program Transaction In C language by HelpMeOutAlways.

ATM Machine Program Source Code

 #include <stdio.h>

unsigned long int amount = 50000, depositS;
//Number Of Notes Available in The ATM Machine, down below statements
unsigned long int FiveThousandNotes = 50;

unsigned long int ThousandNotes = 50;

unsigned long int FiveHundredNotes = 50;

unsigned long int OneHundredNotes = 50;

unsigned long int TenNotes = 50;

unsigned long int fiftyNotes = 50;

unsigned long int withdrawAmount;

unsigned long int totalMoney;

unsigned long int fivethousand = 0, thousand = 0, fiveHundred =
  0, oneHundred = 0, fifty = 0, ten = 0;

int choice, pin, k;

char transaction = 'y';


main ()
{

  while (pin != 1520)

    {

      printf ("ENTER YOUR FOUR DIGIT PIN NUM:"); //User will Enter His Four Digit Pin Code

      scanf ("%d", &pin); // REads OutPut

      if (pin != 1520) /// IF It is Not The COrrect Pin

printf ("WRONG PASSWORD! TRY AGAIN\n");

    }

  do // It Will Once Print All the Statements Given Below

    {

      printf ("********Welcome to ATM Service**************\n");

      printf ("1. Check Balance\n");

      printf ("2. Withdraw Cash\n");

      printf ("3. Deposit Cash\n");

      printf ("4. Quit\n");

      printf ("******************?**************************?*\n\n");

      printf ("Enter your choice: "); // Chooes One of The Option

      scanf ("%d", &choice); //Read The input

      switch (choice)

{

case 1: // Check Balance

  printf ("\n YOUR BALANCE IN Rs : %lu ", amount);

  break;

case 2: // To widthdraw Money

  printf ("Enter the amount in multiple of 10:"); // Enter money more than 100 in multiples

  scanf ("%lu", &withdrawAmount);

  if (withdrawAmount < amount)

    {

      amount = amount - withdrawAmount;

      printf ("\nYour balance is Rs: %lu \n", amount);

    }

  if (withdrawAmount % 10 != 0) // If not in Multip
    {

      printf ("Invalid amount\n");

      return 0;

    }

  totalMoney =
    ThousandNotes * 1000 + FiveHundredNotes * 500 +
    OneHundredNotes * 100 + fiftyNotes * 50 + TenNotes * 10;

  if (withdrawAmount > totalMoney)
    {

      printf ("Sorry,Insufficient money\n");

      return 0;

    }

  fivethousand = withdrawAmount / 5000;

  if (fivethousand > FiveThousandNotes)

    fivethousand = FiveThousandNotes;

  withdrawAmount = withdrawAmount - fivethousand * 5000;



  thousand = withdrawAmount / 1000;

  if (thousand > ThousandNotes)

    thousand = ThousandNotes;

  withdrawAmount = withdrawAmount - thousand * 1000;



  fiveHundred = withdrawAmount / 500;

  if (fiveHundred > FiveHundredNotes)

    fiveHundred = FiveHundredNotes;

  withdrawAmount = withdrawAmount - fiveHundred * 500;



        if (withdrawAmount > 0)
     
        oneHundred=withdrawAmount/100;
     
  if (oneHundred > OneHundredNotes)

    oneHundred = OneHundredNotes;

  withdrawAmount = withdrawAmount - oneHundred * 100;


        if (withdrawAmount > 0)
     
        fifty=withdrawAmount/50;
     
  if (fifty > fiftyNotes)

    fifty = fiftyNotes;

  withdrawAmount = withdrawAmount - fifty * 50;


     
  if (withdrawAmount > 0)

    ten = withdrawAmount / 10;

  if (ten > TenNotes)

    ten = TenNotes;

  withdrawAmount = withdrawAmount - ten * 10;



  printf ("Total 5000 note:%lu\n", fivethousand);

  printf ("Total 1000 note:%lu\n", thousand);

  printf ("Total 500 note:%lu\n", fiveHundred);

  printf ("Total 100 note:%lu\n", oneHundred);

  printf ("Total 50 notes:%lu\n", fifty);

  printf ("Total  10 notes:%lu\n", ten);


  break;

case 3:

  printf ("\n ENTER THE AMOUNT TO DEPOSIT:");

  scanf ("%lu", &depositS);

  amount = amount + depositS;

  printf ("YOUR BALANCE IS %lu", amount);

  break;

case 4:

  printf ("\n THANK U USING ATM");

  break;

default:

  printf ("\n INVALID CHOICE");

}

      printf ("\n\n\n DO U WISH TO HAVE ANOTHER TRANSCATION?(y/n): \n");

      fflush (stdin); //It make a wide Space Between the Line

      scanf ("%c", &transaction);

      if (transaction == 'n' || transaction == 'N')

k = 1;

    }
  while (!k);

  printf ("\n\n THANKS FOR USING OUT ATM SERVICE");

  return 0;
}




Outputs


atm machine program in c language

atm machine program in c language

atm machine program in c language

atm machine program in c language


I hope that this ATM Program In C language has helped you to understand how ATM Machine works.
Reading Time:

@way2themes