Monday, August 22, 2022

 

  1. //Student Class for Practice
  2. class Student
  3. {  
  4.      int rollno;  
  5.      String name;  
  6.      void insertRecord(int rno, String na)
  7.      {  
  8.             rollno=rno;  
  9.             name=na;  
  10.      }  
  11.      void displayInformation()
  12.      {
  13.             System.out.println("Student Details: "+rollno+"  "+name);
  14.      }  
  15. }  
  16. class TestStudent
  17. {  
  18.      public static void main(String args[])
  19.      {  
  20.         Student s1=new Student();  
  21.         Student s2=new Student();  
  22.   
  23.         s1.insertRecord(302,"Dinesh");  
  24.         s2.insertRecord(348,"Geetheswar");  
  25.   
  26.         s1.displayInformation();  
  27.         s2.displayInformation();  
  28.     }  
  29. }  

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete

  2. class Animal
    {
    String name;
    int alive;
    int existance;
    void insert(String na,int a,int ex)
    {
    name=na;
    alive =a;
    existance=ex;
    }
    void display()
    {
    System.out.println("name of Animal:"+name+"\nno of alive:"+alive+"\nno of existance:"+existance);
    }
    void totalAlive()
    {
    float totalAlive=alive/existance;
    System.out.println("TotalAlive="+totalAlive);
    }
    }
    class AnimalTest {
    public static void main(String[] args)
    {
    Animal A1=new Animal();
    Animal A2=new Animal();

    A1.insert("green_anakonda",2300,999);
    A2.insert("riyon",1500,458);
    A1.display();
    A2.display();
    A1.totalAlive();
    A2.totalAlive();
    }
    }

    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:...