Skip to main content

Posts

JAVA

                      Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let programmers write once, run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture. The syntax of Java is similar to C and C++, but has fewer low-level facilities than either of them. The Java runtime provides dynamic capabilities (such as reflection and runtime code modification) that are typically not available in traditional compiled languages. As of 2019, Java was one of the most popular programming languages in use according to GitHub,particularly for client–server web appli...
Recent posts

Assignment No: 5

Assignment No: 5   Set A: a)Write a java program that works as a simple calculator. Use a grid layout to arrange buttons for the digits and for the +, -, *, /, % operations. Add a text filed to display the result. CODE: 👇 import java.awt.*; import java.awt.event.*; import javax.swing.*; public class calc  extends JFrame implements ActionListener { String msg=" "; int v1,v2,result; JTextField t; JButton b[]=new JButton[10]; JButton add,sub,mul,div,clear,equals; char choice; JPanel p,p1; calc() { setLayout(new BorderLayout()); p =new JPanel(); t=new JTextField(20); p.add(t); p1=new JPanel(); p1.setLayout(new GridLayout(5,4)); for(int i=0;i<10;i++) { b[i]=new JButton(""+i); } equals=new JButton("="); add=new JButton("+"); sub=new JButton("-"); mul=new JButton("*"); div=new JButton("/"); clear=new JButton("C"); for(int i=0;i<10;...

Assignment No:4

 //Assignment No:4 Set A: a)Define a class of patient(patient_name, patient_age, patient_oxy_level, patient_HRTC_report). Create an object of patient handle appropriate exception while patient oxygen level less 95% and HRTC scan report greater than 10, then throw user defined Exception "Patient is Covid Positive(+) and Need to Hospitalized" otherwise display its information. CODE: 👇 import java.util.*; class HealthException extends Exception { String msg = "I'm sorry..! Your Covid Positive(+)\nNeed To Hpspital italized\n"; public String toString() { return msg; } } class patient { String pname; byte page; int p_oxy_level; int p_HRTC_report; patient(String p, byte a, int ol, int pr) { pname = p; page = a; p_oxy_level = ol; p_HRTC_report = pr; } public void display() { System.out.println("\n\t\tPatitent Details\n"); System.out.println("Patitent Name\t Patitent Age \t Oxygen_Level\tHRTC_Report"...

Assignment No:3

//Assignment No:3 Set A: a)Write a program for multilevel inheritance such that country is inherited from continent. State is inherited from country. Display the place, state, country, and Continent. CODE: 👇 import java.util.*; class continent { String Cname; } class country extends continent { String Couname; } class state extends country { String Sname; String Pname; state(String c1, String c2, String c3, String c4) { Cname = c1; Couname = c2; Sname = c3; Pname = c4; } void display() { System.out.println("Continent\tCountry\t\tState\tPlace"); System.out.println(Cname+"\t\t"+Couname+"\t\t"+Sname+"\t"+Pname); } public static void main(String[] args)  { Scanner sc = new Scanner(System.in); System.out.println("Enter Continent Name"); String c1 = sc.next(); System.out.println("Enter Country Name"); String c2 = sc.next(); System.out.println("Enter State Name");...

Assignment No:2

 //Assignment No.2 Set A: a) Create an employee class(id, name, deptname, salary). Define a default and parameterized constructor. Use 'this' keyword to initilize instance variabels. Keep a count of objects cretaed. Create objectes using parameterized constructor and display the objects count after each object is created.(Use static member and method). Also display the contents of each objects. Code: 👇 import java.util.*; class employee { int id; String name; String deptname; double salary; static int cnt=0; employee() { //Default Constructor } employee(int id, String name, String deptname, double salary) { this.id = id; this.name = name; this.deptname = deptname; this.salary = salary; cnt++; } static void objnum() { System.out.println("Count Of Object:"+cnt); } void display() { System.out.println(this.id+"\t"+this.name+"\t\t"+this.deptname+"\t\t"+this.salary); } public static v...

Assignment No:1

//Assignment No:1 Set A b) Write a program to calculate perimeter and area of reactangle. Code: 👇 import  java.util.*; public class rect { int l, b, area, perimeter; void accept() { Scanner sc =new Scanner(System.in); System.out.println("Enter Length:\t"); l = sc.nextInt(); System.out.println("Enter Breadth:\t"); b = sc.nextInt(); } void calculate() { area = l*b; perimeter = 2*(l+b); } void disp() { System.out.println("Area of Rectangle:\t"+area); System.out.println("Perimeter of Rectangle:\t"+perimeter); } public static void main(String[] args) { rect r = new rect(); r.accept(); r.calculate(); r.disp(); } } // Execute //Output /* Enter Length: 4 Enter Breadth: 8 Area of Rectangle: 32 Perimeter of Rectangle: 24 */ c) Write a program menu driven program to perform the following operations.     i) Calculate the volume of cylinder.(hint: V...