Monday, August 22, 2022

 //Account Class

class Account

{  

   int acc_no;  

   String name;  

   float amount;  

 

   void insert(int a,String n,float amt)

   {  

      acc_no=a;  

      name=n;  

      amount=amt;  

   }  


   void deposit(float amt)

   {  

      amount=amount+amt;  

      System.out.println(amt+" deposited");  

   }  


   void withdraw(float amt)

   {  

   if(amount<amt)

      {  

         System.out.println("Insufficient Balance");  

      }

   else

      {  

      amount=amount-amt;  

      System.out.println(amt+" withdrawn");  

      }  

   }  

 

   void checkBalance()

   {

      System.out.println("Balance is: "+amount);

   }  

 

   void display()

   {

      System.out.println(acc_no+" "+name+" "+amount);

   }  

}  


class AccountTest

{  

   public static void main(String[] args)

   {  

      Account a1=new Account();  

      a1.insert(10001,"Srikanth",1000);  

      a1.display();  

      a1.checkBalance();  

      a1.deposit(40000);  

      a1.checkBalance();  

      a1.withdraw(15000);  

      a1.checkBalance();  

   }

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. roll no = 21765A0327

    class Shop
    {
    int shopno;
    String name;
    float profit_day;
    void insertRecord(int t_shopno,String t_name,float t_profit)
    {
    shopno= t_shopno;
    name=t_name;
    profit_day=t_profit;
    }
    void displayinformation ()
    {
    System.out.println("shop reg number:"+shopno+"\nshop name:"+name+"\nprofit per day :"+profit_day);
    }
    }
    class TestShop
    {
    public static void main(String args[])
    {
    Shop s1=new Shop();
    s1.insertRecord(134,"RAVI",1700);
    s1.displayinformation();
    }
    }

    ReplyDelete
  3. class Family
    {
    String brother;
    String sister;
    String mother;
    String father;
    void insert(String bro,String sis,String mom,String dad )
    {
    brother=bro;
    sister=sis;
    mother=mom;
    father=dad;
    }

    void displayInformation()
    {
    System.out.println("brother is:"+brother+" "+sister+" "+mother+" "+father);
    }
    }
    class FamilyTest {
    public static void main(String[] args) {
    Family F1=new Family();
    Family F2=new Family();
    F1.insert("vijay","Swathi","nagamani","brahmam");
    F2.insert("jhashu","Anusha","parvathi","sai");
    F1.displayInformation();
    F2.displayInformation();
    }
    }

    ReplyDelete

Program to read and display array elements

#include<stdio.h> void main() {     int a[50]; int n,i;     do     {         printf("\nEnter no. of elements in between 1 and 50:...