SADGVD
SADGVD
Aim:
To write a program to understand input output constructs in
Java.
ALGORITHM:
OUTPUT:
RESULT:
Thus the simple java program to display the message as
welcome user was implemented and verified.
EX NO:1(b)
SWAPPING OF TWO NUMBERS
Aim:
To write a program to perform swapping of two numbers
aLGORITHM:
1. Import necessary packages and relevant classes.
2. Define a, b and temp as member
3. Read input value a and b from the user using getInput()
method.
4. Swap two numbers using swap method.
5. Print a and b value using display() method.
Program:
import java.util.Scanner;
public class Swapping
{int num1,num2, temp;
void getInput(){
Scanner obj=new Scanner(System.in);
System.out.println("Enter the number 1:");
num1=obj.nextInt();
System.out.println("Enter the number 2:");
num2=obj.nextInt();
}
void display(){
System.out.println(" Number 1 value is: "+num1);
System.out.println(" Number 2 value is: "+num2);
}
void swap(){ temp =num1;
num1=num2;
num2=temp;
}
public static void main(String args[])
{Swapping s=new Swapping();
s.getInput();
System.out.println("Before Swapping");
s.display();
s.swap(); //to perform swapping
System.out.println("After Swapping");
s.display();
}
}
Output:
Result:
Thus the java program to swap the two number was executed
and verified successfully
EX NO:1(c) CALCULATE PERIMETER AREA AND VOLUME
OF ANY ONE OF THE SHAPE
Aim:
To write a java program to calculate perimeter, Area and
volume of any one of the shape.
ALGORITHM:
1. Import necessary packages and relevant classes.
2. Define side as member.
3. Read input value of side using getInput() method.
4. Calculate the area of square using areaSquare() method.
5. Determine the perimeter of square using perimeterSquare() method.
PROGRAM:
import java.util.Scanner;
public class Shape {
int side;
void getInput(){
System.out.println("Enter the side of Square object:");
Scanner obj=new Scanner(System.in);
side=obj.nextInt();
}
void areaSquare()
{
System.out.println("The area of Square Object is:"+side*side);
}
void perimeterSquare()
{
System.out.println("The perimeter of Square Object is:"+4*side);
}
void cube()
{
System.out.println("The volume of cube is:"+side*side*side);
}
public static void main(String args[])
{Shape e=new Shape();
e.getInput();
e.areaSquare();
e.perimeterSquare();
e.cube();
}
}
OUTPUT:
RESULT:
Thus the java program to calculate the area, perimeter and volume of
any one of the shape was executed and verified successfully.
EX NO:1(d)
ELIGIBILITY FOR VOTING OR NOT
AIM:
To write a java program to check whether the person is eligible to
vote or not.
ALGORITHM:
1. Get details of the voter using getVoterDetails() .
2. Check whether the person is eligible to vote or not using
checkEligible() i.e. age >= 18 person is eligible otherwise not eligible.
PROGRAM:
import java.util.Scanner;
public class VoterDemo
{ int age;
String name;
void getVoterDetails()
{ Scanner obj=new Scanner(System.in);
System.out.println("Enter the Person Name:");
name=obj.nextLine();
System.out.println("Enter the Person Age:");
age=obj.nextInt();
}
void checkEligible(){
if(age >=18 )
System.out.println(name+" is eligible to Vote");
else
System.out.println(name+" is not eligible to Vote");
}
public static void main(String args[])
{VoterDemo v=new VoterDemo();
v.getVoterDetails();
v.checkEligible();
}
}
OUTPUT:
RESULT:
Thus the java program to check whether the person is eligible to vote
or not was implemented and verified successfully.
EX NO:1(e)
SUM OF NATURAL NUMBERS UPTO THE LIMIT
AIM:
To write a java program to find the sum of first n natural numbers.
ALGORITHM:
1. read n value using Scanner object.
2. find sum of first n natural numbers using calculate().
PROGRAM:
import java.util.Scanner;
public class SumFirstN
{
int calculate(int n)
{
int sum=0;
for(int i=1;i<=n;i++)
sum+=i;
return sum;
}
public static void main(String args[])
{ Scanner obj=new Scanner(System.in);
System.out.println("Enter the Limit (N):");
int n=obj.nextInt();
SumFirstN s=new SumFirstN();
System.out.println("The sum of First N Natural number
is:"+s.calculate(n));
}
}
OUTPUT:
RESULT:
Thus the java program to print the sum of first n natural numbers
was implemented and verified successfully.
EX NO:2
ELECTRICITY BILL CALCULATION
AIM:
To Develop a Java application to generate Electricity bill. Create a
class with the following members: Consumer no., consumer name,
previous month reading, current month reading, type of EB connection
(i.e domestic or commercial). Compute the bill amount using the
following tariff.
a. If the type of the EB connection is domestic, calculate the
amount to be paid as follows:
➢ First 100 units - Rs. 1 per unit
➢ 101-200 units - Rs. 2.50 per unit
➢ 201 -500 units - Rs. 4 per unit
➢ 501 units - Rs. 6 per unit
b. If the type of the EB connection is commercial, calculate the
amount to be paid as follows:
➢ First 100 units - Rs. 2 per unit
➢ 101-200 units - Rs. 4.50 per unit
➢ 201 -500 units - Rs. 6 per unit
➢ 501 units - Rs. 7 per unit
ALGORITHM:
1. Declare the members of the customer
2. Read the customer details using getCustomerDetails()
3. Calculate EB Bill by calling EbillCal()
4. Generate report of EB Bill Statement by calling display()
PROGRAM:
import java.util.Scanner;
int EBNumber;
String customerName;
int previousMonthReading;
int currentMonthReading;
int numberOfUnitsConsumed;
double charge;
int typeEBConnection;
void getCustomerDetails()
customerName=obj.nextLine();
previousMonthReading=obj.nextInt();
currentMonthReading=obj.nextInt();
typeEBConnection=obj.nextInt();
void eBillCal()
numberOfUnitsConsumed=currentMonthReading-previousMonthReading;
if(typeEBConnection==1)
charge=numberOfUnitsConsumed*1;
charge=100+(numberOfUnitsConsumed-100)*2.5;
charge=100+100*2.5+(numberOfUnitsConsumed-200)*4;
else
charge=100+100*2.5+300*4+(numberOfUnitsConsumed-500)*6;
}
else
charge=numberOfUnitsConsumed*2;
charge=100+(numberOfUnitsConsumed-100)*4.5;
charge=100+100*4.5+(numberOfUnitsConsumed-200)*6;
else
charge=100+100*2.5+300*4+(numberOfUnitsConsumed-500)*7;
void display()
String con=(typeEBConnection==1)?"Domestic":"Commercial";
System.out.println(" ");
System.out.println(" ");
e.getCustomerDetails();
e.eBillCal();
e.display();
OUTPUT:(1)
OUTPUT:(2)
RESULT:
Thus the java program to generate EB Bill of the customer was
implemented and verified successfully.
EX NO:3
USER DEFINED PACKAGE WITH CLASSES
AIM:
To develop a java application to implement currency converter (Dollar to
INR, EURO to INR, Yen to INR and vice versa), distance converter (meter to KM,
miles to KM and vice versa) , time converter (hours to minutes, seconds and vice
versa) using packages.
ALGORITHM:
PROGRAM:
//Currency class
package packex;
{return rupee/75;
{return euro*85;
{return rupee/85;
{return yen*0.6;
{return rupee/0.6;
//Distance class
package packex;
return miles*1.60;
return kilometer*0.62;
//TIME CLASS
package packex;
{return h*60;
{return h*3600+m*60+s;
{int h=s/3600;
int m=(s-(h*3600))/60;
int sec=(s-(h*3600)-(m*60))%60;
return h+"Hour(s)"+m+"Minute(s)"+sec+"Second(s)";
}
//Main Class
import packex.CurrencyDEY;
import packex.TimeConversion;
import packex.Distance;
import java.util.Scanner;
double dollar,rupee,yen,euro,km,miles;
int hours,minutes,seconds,meter;
void getCurrencyInput(){
dollar=obj.nextDouble();
euro=obj.nextDouble();
yen=obj.nextDouble();
rupee=obj.nextDouble();
void conCurrency(){
System.out.println("Dollar to Rupee:"+Math.ceil(c.dolToRup(dollar)));
System.out.println("Rupee to Dollar:"+Math.ceil(c.rupToDol(rupee)));
}
void getDistanceInput()
km=obj.nextDouble();
meter=obj.nextInt();
miles=obj.nextDouble();
void conDistance(){
System.out.println("Kilo-meter to meters:"+d.kmToMeter(km));
System.out.println("Meters to Kilo-meters:"+d.meterToKM(meter));
System.out.println("Miles to Kilometers:"+d.milesToKM(miles));
System.out.println("Kilometer to Miles:"+d.kmToMiles(km));
void getTimeInput()
hours=obj.nextInt();
minutes=obj.nextInt();
seconds=obj.nextInt();
else{
System.out.println("Hours to Minutes:"+t.hrsToMins(hours));
System.out.println("Hours to Seconds:"+t.hrsToSecs(hours));
System.out.println("Minutes to Hours:"+t.minsToHrs(minutes));
System.out.println("Seconds to Hours:"+t.secsToHrs(seconds));
obj.getCurrencyInput();
obj.conCurrency();
obj.getDistanceInput();
obj.conDistance();
obj.getTimeInput();
obj.conTime();
}
OUTPUT:
RESULT:
Thus the java program to import user defined package classes and
operations were implemented and Verified successfully.
EX NO:4
STRING OPERATIONS USING ARRAYLIST
AIM:
1. To write a program to perform string operations using ArrayList. Write
functions for the following
c. Search
ALGORITHM:
a. getDetails()
b. appendAtEnd()
c. insert()
d. search()
PROGRAM:
import java.io.*;
import java.util.*;
void getDetails()
int n=obj.nextInt();
for(int i=0;i<n;i++)
al.add(obj.next());
System.out.println(al);
void insert()
int pos=obj.nextInt();
String newPlayerName=obj.next();
al.add(pos,newPlayerName);
System.out.println(al);
void search()
String search=obj.next();
void starts()
String s=obj.next();
for(int i=0;i<al.size();i++)
void appendAtEnd()
al.add(obj.next());
System.out.println(al);
soa.getDetails();
int choice;
while(true){
System.out.println("Menu");
System.out.println("3.Search");
System.out.println("5.Exit");
choice=obj.nextInt();
switch(choice){
case 1:
soa.appendAtEnd();
break;
case 2:
soa.insert();
break;
case 3:
soa.search();
break;
case 4:
soa.starts();
break;
case 5:
break;
default:
if (choice==5)
break;
OUTPUt:
RESULT:
Thus the java program to perform various string operations using ArrayList
was implemented and verified successfully.
EX NO:5 EMPLOYEE SALARY CLACULATION UJSING
INHERITANCE CONCEPTS
AIM:
To develop a java application with Employee class with Emp_name,
Emp_id, Address, Mail_id, Mobile_no as members. Inherit the classes,
Programmer, Assistant Professor, Associate Professor and Professor from
employee class and Generate pay slips for the employees with their gross and net
salary with respected to given statements below.
Programmer 15000- 97 10 12 1
20000
Assistant 20001- 120 20 12 5
professor 30000
Associate 30001- 130 30 12 10
Professor 40000
ALGORITHM:
1. Create a base class Employee, necessary members and methods to read / display
the employee information.
2. Create subclasses Programmer, AssistantProfessor, AssociateProfessor and
Professor derived from Employee class and overload and override methods
like(getEmployeeDetails(basicPay) and display(). in addition cal() method which is
used to salary calculation based on employee designation with respected to
problem statements.
PROGRAM:
import java.util.Scanner;
p.getEmployeeDetails(obj.nextDouble());
p.cal();
ap.getEmployeeDetails(obj.nextDouble());
ap.cal();
asp.getEmployeeDetails(obj.nextDouble());
asp.cal();
Professor prof=new Professor();
prof.getEmployeeDetails(obj.nextDouble()); prof.cal();
class Employee
String employeeName;
int employeeID;
String address;
String mailID;
long mobileNumber;
double da,hra,pf,sc,ns,gs;
void getEmployeeDetails()
employeeName=obj.nextLine();
address=obj.nextLine();
mailID=obj.nextLine();
mobileNumber=obj.nextLong();
void display()
System.out.println("Employee ID :"+employeeID);
{double basicPay;
{return basicPay;
{this.basicPay = basicPay;
{
super.getEmployeeDetails();
setBasicPay(bp);
void cal()
{ da=getBasicPay()*97/100.0;
hra=getBasicPay()*10/100.0;
pf=getBasicPay()*12/100.0;
sc=getBasicPay()*1/100.0;
gs=getBasicPay()+da+hra+pf+sc;
ns=gs-pf-sc;
display();
void display()
{ super.display();
{double basicPay;
{return basicPay;
}
public void setBasicPay(double basicPay)
{this.basicPay = basicPay;
void getEmployeeDetails(double
bp){super.getEmployeeDetails();
setBasicPay(bp);
void cal()
{ da=getBasicPay()*110/100.0;
hra=getBasicPay()*20/100.0;
pf=getBasicPay()*12/100.0;
sc=getBasicPay()*5/100.0;
gs=getBasicPay()+da+hra+pf+sc;
ns=gs-pf-sc;
display();
void display()
{ super.display();
{return basicPay;
{this.basicPay = basicPay;
{super.getEmployeeDetails();
setBasicPay(bp);
void cal()
{ da=getBasicPay()*130/100.0;
hra=getBasicPay()*30/100.0;
pf=getBasicPay()*12/100.0;
sc=getBasicPay()*10/100.0;
gs=getBasicPay()+da+hra+pf+sc;
ns=gs-pf-sc;
display();
void display()
{ super.display();
double basicPay;
{return basicPay;
{this.basicPay = basicPay;
{super.getEmployeeDetails();
setBasicPay(bp);
void cal(){
da=getBasicPay()*140/100.0;
hra=getBasicPay()*40/100.0;
pf=getBasicPay()*12/100.0;
sc=getBasicPay()*15/100.0;
gs=getBasicPay()+da+hra+pf+sc;
ns=gs-pf-sc;
display();
void display()
{ super.display();
}
OUTPUT:
RESULT:
Thus the java program to calculate the employee salary using inheritance
concepts was implemented and verified successfully.
EX NO:6
JAVA INHERITANCE FOR ADT STACK
AIM:
To Design a Java interface for ADT Stack. Implement this interface using
array. Provide necessary exception handling in both the implementation.
ALGORITHM:
1. Declare a stack interface and necessary methods declaration.
2. Define the user defined exception classes to handle the stack overflow and
stack underflow.
3. Create a MainClass to implements all the interface methods and display
method.
PROGRAM:
import java.util.Scanner;
interface Stack
void pop();
boolean isEmpty();
boolean isFull();
{public StackIsOverflow(String s)
{
super(s);
{public StackIsUnderflow(String s)
super(s);
Stack{int top=-1;
{if (top==-1)
return true;
else
return false;
{ if(top==elements.length-1)
return true;
else
return false;
{try{
if(!isFull())
elements[++top]=data;
else
catch(StackIsOverflow e)
{ System.out.println("Excepion:"+e);
{try
if(!isEmpty())
else
catch(StackIsUnderflow e)
{ System.out.println("UserDefined Exception:"+e);
}
void display()
System.out.println(elements[i]);
int choice;
while(true)
{ System.out.println("Menu");
System.out.println("1.Push");
System.out.println("2.Pop");
System.out.println("3.Display");
System.out.println("4.Exit");
choice=obj.nextInt();
switch(choice)
{
case 1:
c.push(obj.nextInt());
break;
case 2:
c.pop();
break;
case 3:
c.display();
break;
case 4:
break;
default:
if (choice==4)
break;
}
OUTPUT:
RESULT:
Thus the program to design a Java interface for ADT Stack. Implement this
interface using array. Provide necessary exception handling in both the
implementations were implemented and verified successfully.
EX NO:7
JAVA INHERITANCE FOR ADT QUEUE
AIM:
To design a java interface for ADT Queue. Implement this interface using
array. Provide necessary exception handling in both the implementations.
ALGORITHM:
PROGRAM:
import java.util.Scanner;
interface Queue1
void dequeue();
boolean isQueueEmpty();
boolean isQueueFull();
QueueIsFull(String s)
super(s);
QueueIsEmpty(String s)
super(s);
int queueArr[];
this.capacity =queueSize;
public boolean
isQueueFull()
status = true;
return status;
status = true;
return status;
try
{
if (isQueueFull())
else
catch(QueueIsFull e)
System.out.println(e.getMessage());
try
if (isQueueEmpty())
else
catch(QueueIsEmpty e)
System.out.println(e);
void display()
if(!isQueueEmpty())
System.out.println(queueArr[i]);
else
}
public static void main(String args[])
int choice;
while(true)
System.out.println("Menu");
System.out.println("1.Enqueue");
System.out.println("2.Dequeue");
System.out.println("3.Display");
System.out.println("4.Exit");
choice=obj.nextInt();
switch(choice)
case 1:
queue.enqueue(obj.nextInt());
break;
case 2:
queue.dequeue();
break;
case 3:
queue.display();
break;
case 4: break;
if (choice==4)break;
OUTPUT:
RESULT:
Thus the java program to design a java interface for ADT queue was
implemented and verified successfully.
EX NO:8
ABSTRACT CLASS
AIM:
To write a Java Program to create an abstract class named Shape that contains
two integers and an empty method named print Area(). Provide three classes
named Rectangle, Triangle and Circle such that each one of the classes extends the
class Shape. Each one of the classes contains only the method print Area () that
prints the area of the given shape.
ALGORITHM:
1. Create a class ShapeDemo with necessary members and abstract method
printArea()
2. Create sub classes Rectangle and Triangle derived from ShapeDemo and
override the printArea().
PROGRAM:
import java.util.Scanner;
r.printArea();
t.printArea();
ShapeDemo(int l, int b)
length=l;
breadth=b;
Rectangle(int l, int b)
super(l,b);
}
void printArea()
Triangle(int l, int b)
super(l,b);
@Override
void printArea()
}
OUTPUT:
RESULT:
Thus the java program to demonstrate Abstract Class was implemented and
verified successfully.
EX NO:9
DISPLAY FILE INFORMATION
AIM:
To write a Java program that reads a file name from the user, displays
information about whether the file exists, whether the file is readable, or writable,
the type of file and the length of the file in bytes.
ALGORITHM:
PROGRAM:
import java.util.Scanner;
import java.io.File;
String name;
File f1;
void getFile()
{
Scanner input=new Scanner(System.in);
name=input.nextLine();
f1=new File(name);
void showDetails(){
System.out.println("File Name:"+f1.getName());
System.out.println("Path:"+f1.getPath());
System.out.println("Abs Path:"+f1.getAbsolutePath());
System.out.println("Is Readable:"+f1.canRead());
System.out.println("IS Writable:"+f1.canWrite());
System.out.println("File Size:"+f1.length()+"bytes");
fi.getFile();
fi.showDetails();
}
OUTPUT:
RESULT:
Thus the java program to display the file information was implemented and
verified successfully.
EX NO:10
MULTITHREADING
AIM:
To write a java program that implements a multi-threaded application that has
three threads. First thread generates a random integer every 1 second and if the
value is even, second thread computes the square of the number and prints. If the
value is odd, the third thread will print the value of cube of the number.
ALORITHM:
1. Create Master thread class as Thread1 and two slave threads
2. Master Thread generate random number every 1 seconds based on the value is
even it invoke Second Thread - prints the square of the number otherwise Third
Thread – prints the cube of the number.
PROGRAM:
import java.util.Scanner;
import java.util.Random;
try
int n=obj.nextInt();
for(int i=1;i<=n;i++)
int no=r.nextInt(100);
if(no%2==0)
t2.start();
else
{
Thread3 t3=new Thread3(no);
t3.start();
Thread.sleep(1000);
catch(Exception e)
System.out.println(e);
int n1;
Thread2(int n)
n1=n;
}
}
int n1;
Thread3(int n)
n1=n;
OUTPUT:
RESULT:
Thus the java program to demonstrate the multithreading concept was
implemented and verified successfully.
EX NO:11 FIND MAX ELEMENT USING GENERIC
FUNCTION
AIM:
To write a java program to find max element using generic function.
ALGORITHM:
PROGRAM:
import java.util.Scanner;
E max = list[0];
if(list[i].compareTo(max) > 0 )
max = list[i];
return max;
}
Integer []a={1,5,3,15};
Double []b={.5,67.8,3.8,0.01};
OUTPUT:
RESULT:
Thus the java program to find the max elements using Generic Function was
implemented and verified successfully.
EX NO:12
CALCULATION USING EVENT HANDLING
AIM:
To write a java program to perform various calculator operations using event
handling mechanism.
ALGORITHM:
1. Create a Calculator Frame class with necessary panel, buttons and textfield
2. Arrange the panel, button and textfield into Calcultor Frame using
BorderLayout/ Grid Layout .
PROGRAM:
import java.util.Scanner;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Reader;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class Cal extends javax.swing.JFrame implements ActionListener
public Cal()
setLayout(new BorderLayout());
add(io,BorderLayout.NORTH);
for(int i=0;i<10;i++)
b[i]=new JButton(""+i);
b[10]=new JButton("+");
b[11]=new JButton("-");
b[12]=new JButton("*");
b[13]=new JButton("/");
b[14]=new JButton("%");
b[15]=new JButton("(");
b[16]=new JButton(")");
b[17]=new JButton(".");
b[18]=new JButton("back");
b[19]=new JButton("clr");
b[20]=new JButton("=");
for(int i=0;i<20;i++)
p.add(b[i]);
add(p,BorderLayout.CENTER);
add(b[20],BorderLayout.SOUTH);
setSize(600,600);
for(int i=0;i<21;i++)
b[i].addActionListener(this);
java.awt.EventQueue.invokeLater(new Runnable()
c.setVisible(true);
c.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
c.show();
});
@Override
{
Object src= e.getSource();
try{
if(src==b[0]||src==b[1]||src==b[2]||src==b[3]||src==b[4]||src==b[5]||src==b[6]||src=
=b[7]||src==b[8]||src==b[9]||src==b[10]||src==b[11]||src==b[12]||src==b[13]||src==
b[14]||src==b[15]||src==b[16]||src==b[17])
io.setText(io.getText()+e.getActionCommand());
else if(src==b[18])
io.setText(io.getText().substring(0, io.getText().length()-1));
else if(src==b[19])
io.setText("");
else if(src==b[20])
if(io.getText().contains(".") || io.getText().contains("/"))
Double r=(Double)runtime.eval(io.getText().toString());
io.setText(String.valueOf(r));
else
Integer r=(Integer)runtime.eval(io.getText().toString());
io.setText(String.valueOf(r));
}
}
catch(Exception er)
io.setText(er.toString());
OUTPUT:
RESULT:
Thus the java program to find the max elements to using Generic Functions
was implemented and verified successfully.
EX NO:13
MARKSHEET CALCULATION
Aim:
To write a java file to get 5 subjects marks as input and calculate total and
percentage and write it to a file.
ALGORITHM:
1. Declare necessary variables
Program:
import javax.swing.JOptionPane;
import java.io.*;
class Marksheet{
int DS = Integer.parseInt(c);
int CE = Integer.parseInt(d);
int DM = Integer.parseInt(e);
if(OOPS >39 && DPSD >39 && DS >39 && CE >39 && DM >39 &&
(percentage <100 && percentage >=80)) {
info = " Name :"+firstname +"\n Register Number :"+ regno +"\n Total Marks :" +
total +"\n Obtained Marks : " + obtained +"\n Percentage : " + percentage +"%" +
JOptionPane.showMessageDialog(null,info);
if(OOPS >39 && DPSD >39 && DS >39 && CE >39 && DM >39 &&
(percentage <80 && percentage >=70)) {
info = " Name :"+firstname +"\n Register Number :"+ regno +"\n Total Marks :" +
total +"\n Obtained Marks : " + obtained +"\n Percentage : " + percentage +"%" +
"\n You Are Pass" + "\n You Got A Grade\n\n" ;
JOptionPane.showMessageDialog(null, info);
if(OOPS >39 && DPSD >39 && DS >39 && CE >39 && DM >39 &&
(percentage <70 && percentage >=60))
info = " Name :"+firstname +"\n Register Number :"+ regno +"\n Total Marks :" +
total +"\n Obtained Marks : " + obtained +"\n Percentage : " + percentage +"%" +
JOptionPane.showMessageDialog(null,info );
if(OOPS >39 && DPSD >39 && DS >39 && CE >39 && DM >39 &&
(percentage <60 && percentage >=50))
info = " Name :"+firstname +"\n Register Number :"+ regno +"\n Total Marks :" +
total +"\n Obtained Marks : " + obtained +"\n Percentage : " + percentage +"%" +
JOptionPane.showMessageDialog(null,info );
if(OOPS >39 && DPSD >39 && DS >39 && CE >39 && DM >39 &&
(percentage <50 && percentage >=40))
info = " Name :"+firstname +"\n Register Number :"+ regno +"\n Total Marks :" +
total +"\n Obtained Marks : " + obtained +"\n Percentage : " + percentage +"%"
+"\n You Passed" + "\n You Got D Grade\n\n";
JOptionPane.showMessageDialog(null, info);
if(OOPS <40 || DPSD <40 || DS <40 || CE <40 || DM <40 || percentage < 40) {
info = " Name :"+firstname +"\n Register Number :"+ regno +"\n Total Marks :" +
total +"\n Obtained Marks : " + obtained +"\n Percentage : " + percentage +"%" +
JOptionPane.showMessageDialog(null,info );
out.write(info);
out.close();
OUTPUT:
RESULT:
Thus the java program to get input from GUI and calculate marks percentage
and show the output in a message box and write the details to a file.