Java



Java is a programming language originally developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simplerobject model and fewer low-level facilities. Java applications are typically compiled to bytecode (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture. Java is a general-purpose, concurrent, class-based, object-oriented language that is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere.", meaning that code that runs on Windows does not need to be edited to run on a Mac. Java is currently one of the most popular programming languages in use, particularly for client-server web applications, with a reported 10 million users.[10][11]
The original and reference implementation Java compilers, virtual machines, and class libraries were developed by Sun from 1995. As of May 2007, in compliance with the specifications of the Java Community Process, Sun relicensed most of its Java technologies under the GNU General Public License. Others have also developed alternative implementations of these Sun technologies, such as the GNU Compiler for Java and GNU Classpath.

Program for c++


#include<iostream.h>
#include<stdio.h>
#include<fstream.h>
#include<iomanip.h>
#include<conio.h>
#include<string.h>
#include<process.h>
//using namespace std;
FILE *fp1,*fp2;
class student
{
int rn;
char name[50];
char add[50];
char prog[60];
char facu[60];
//char adr[60];
char semi[60];
//int r;
int s1;
int s2;
int s3;
int s4;
int s5;
int s6;
int s7;
int t;
float p;
char result[7];
char division[20];
public:
int calculateTotal();
float calculatePercent();
void findResult();
void findDivision();
void  getdata()
{
fflush(stdin);
cout<<"Enter the roll no:\t\t\t";
cin>>rn;
cout<<"Enter the name of student:\t\t";
gets(name);
cout<<"Enter  the semister of student:\t\t";
gets(semi);
cout<<"\n\n****Enter your marks on these subject****\n\n\n";
cout<<"Networking Fundamental:\t\t\t";
cin>>s1;
cout<<"Data Structure:\t\t\t\t";
cin>>s2;
cout<<"Data Communication:\t\t\t";
cin>>s3;
cout<<"Microprocessor:\t\t\t\t";
cin>>s4;
cout<<"Social Studies:\t\t\t\t";
cin>>s5;
cout<<"Workshop:\t\t\t\t";
cin>>s6;
cout<<"Project:\t\t\t\t";
cin>>s7;
//total=s1+s2+s3+s4+s5+s6+s7;
//l=total/7;
calculateTotal();
calculatePercent();
findResult();
findDivision();
}
void  showdata()
{
cout<<"\n"<<rn<<"\t"<<name<<"\t\t"<<semi<<"\t"<<t<<"\t"<<p<<"\t"<<result<<"\t"<<division;
}
void updatedata()
{
int x;
student s;
fp1=fopen("e:\\std.dat","r");
fp2=fopen("E:\\newstd.dat","w");
cout<<"\n\nEnter the roll no. whose record you want to update ";
cin>>x;
//while(fread((char *) &s,sizeof(s),1,fp1)==1)
while(fread((char *)&s,sizeof(s),1,fp1)==1)
{

if(x==s.rn)
{
s.getdata();
fwrite((char *)&s,sizeof(s),1,fp2);
}
else
{
fwrite((char *) & s,sizeof(s),1,fp2);
}
}
fclose(fp1);
fclose(fp2);
remove("E:\\std.dat");
rename("E:\\newstd.dat","E:\\std.dat");
}
void deletedata()
{
int x;
student s;
fp1=fopen("e:\\std.dat","r");
fp2=fopen("E:\\newstd.dat","w");
cout<<"\n\nEnter the roll no. whose record you want to delete ";
cin>>x;
while(fread((char *)&s,sizeof(s),1,fp1)==1)
{

if(x==s.rn)
{
continue;
}
else
{
fwrite((char *) & s,sizeof(s),1,fp2);
}
}
fclose(fp1);
fclose(fp2);
remove("E:\\std.dat");
rename("E:\\newstd.dat","E:\\std.dat");
}
void search(int val)
{
student s;
int searchResult=0;
fp1=fopen("e:\\std.dat","r");

while(fread((char *)&s,sizeof(s),1,fp1)==1)
{
if(s.rn==val)
{
searchResult=1;
break;
}
}
if(searchResult==1)
{
clrscr();
cout<<"\n\n*********************************************";
cout<<"\nRoll=\t\t\t\t"<<rn<<"\nName=\t\t\t\t"<<name<<"\nSemister=\t\t\t"<<semi<<"\nNetworking Fundamental=\t\t"<<s1<<"\nData Structure=\t\t\t"<<s2<<"\nData Communication=\t\t"<<s3<<"\nMicroprocessor=\t\t\t"<<s4<<"\nSocial Study=\t\t\t"<<s5<<"\nWorkshop=\t\t\t" <<s6<<"\nProject=\t\t\t"<<s7<<"\nTotal=\t\t\t\t"<<t<<"\nPercentage=\t\t\t"<<p;
cout<<"\n*********************************************";

}
else
{
cout<<"\nthe record which your have searched is not in computer";
}
}
};
int student::calculateTotal()
{
t=s1+s2+s3+s4+s5+s6+s7;
return(t);
}
float student::calculatePercent()
{
if(s1>=32&&s2>=32&&s3>=32&&s4>=32&&s5>=32&&s6>=32&&s7>=32)
{
p=(float)t*100/700;
}
else
{
p=0;
}
return(p);
}
void student::findResult()
{
if(s1>=32 && s2>=32 && s3>=32 && s4>=32 && s5>=32 && s6>=32 && s7>=32)
{
strcpy(result,"Pass");
}
else
{
strcpy(result,"Fail");
}
}
void student::findDivision()
{
if(p>=80)
{
strcpy(division,"Distinction");
}
else if(p>=60)
{
strcpy(division,"First");
}
else if(p>=45)
{
strcpy(division,"Second");
}
else if(p>=32)
{
strcpy(division,"Third");
}
else
{
strcpy(division,"---");
}
}
main()
{
int ch;
int rk;
char next='y';
student s;
fstream file;
while(1)
{
clrscr();
cout<<"This program is develop for only computer overseer fourth semister faculty";
cout<<"\n*****************Enter your choice*****************";
cout<<"\n\t\t1. Insert Record";
cout<<"\n\t\t2. Display Record";
cout<<"\n\t\t3. Search";
cout<<"\n\t\t4. Update Record ";
cout<<"\n\t\t5. Delete Record";
cout<<"\n\t\t6. Quit";
printf("\nEnter your choice ");
cin>>ch;
switch(ch)
{
case 1:
clrscr();
file.open("e:\\std.dat",ios::app);
while(next=='y'||next=='Y')
{
s.getdata();
file.write((char *) &s,sizeof(s));
cout<<"\nDo you want to write next record (Y/N)?  ";
cin>>next;
}
file.close();
break;
case 2:
clrscr();
file.open("e:\\std.dat",ios::in);
//file.open("MyFile.txt",ios::out);
file.seekg(0);
cout<<"\n   If you want students detail information please search them by roll number.\n\t\tThis is for security of student information.\n";
cout<<"\nRollno\tName\t\tSemister\tTotal\tPercent\tResult\tDivision";
while(file.read((char *) &s,sizeof(s)))
{
s.showdata();
//getch();
}
// file.close();
file.close();
getch();
break;
case 3:
//code to search
int searchval;
cout<<"Enter the roll no. to search ";
cin>>searchval;
s.search(searchval);
getch();
break;
case 4:
//block for update
s.updatedata();
break;
case 5:
//code to delete
s.deletedata();
break;
case 6:
exit(0);
default:
printf("\n you entered invalid number");
}



getch();
}
return(0);
}