import java.util.*;
public class ArrayObjects{
String name;//important
int age,std;
double eng,maths,phy,chem,bio;
static Scanner sc=new Scanner(System.in);
/**
* This is the monitor of the class...
*
* @param args A parameter
*/
public static void main(String []args){
System.out.println("Enter the number of students");
int n=sc.nextInt();
System.out.println("1:Accept details\n2:Display all records\n3:Display rool no. wise\n4:Deleting records\n5:Modify details\n6:Display wether pass or fail");
ArrayObjects []ob=new ArrayObjects[n];
int ch=0;
do{
System.out.println("....Enter choice....");
ch=sc.nextInt();
switch(ch){
case 1:for(int i=0;i<n;i++){
ob[i]=new ArrayObjects();
ob[i].getdetails();
}
break;
case 2:for(int i=0;i<n;i++){
ob[i].dispdetails(i);
}
break;
case 3:System.out.println("Enter the roll number you want to search");
int rollnum=sc.nextInt();
for(int i=0;i<n;i++){
if((i+1)==rollnum)
ob[i].dispdetails(i);
}
break;
case 4:System.out.println("Enter the roll number you want to delete");
int delroll=sc.nextInt();
for(int i=0;i<n;i++){
if((i+1)==delroll)
ob[i].deldetails();
}
break;
case 5:System.out.println("Enter the roll number of student to modify");
int modroll=sc.nextInt();
for(int i=0;i<n;i++){
if((i+1)==modroll)
ob[i].getdetails();
}
break;
case 6:for(int i=0;i<n;i++){
ob[i].reportcard();
}
break;
default:System.out.println("You have entered wrong choice Sir/Madam pls try again !");
break;
}
}while(ch>0);
}
/**
* This method accepts details of students
*
*/
public void getdetails(){
System.out.println("Enter the student's name");
name=sc.next();
System.out.println("Enter the student's age");
age=sc.nextInt();
System.out.println("Enter the student's class/standard");
std=sc.nextInt();
System.out.println("Enter the student's English marks");
eng=sc.nextDouble();
System.out.println("Enter the student's Maths marks(out of 100)");
maths=sc.nextDouble();
System.out.println("Enter the student's Physics marks(out of 100)");
phy=sc.nextDouble();
System.out.println("Enter the student's Chemistry marks(out of 100)");
chem=sc.nextDouble();
System.out.println("Enter the student's Biology marks(out of 100)");
bio=sc.nextDouble();
}
/**
* This method displays details of the students
*
* biodata
*/
public void dispdetails(int roll){
if(name==null){
roll=0;
System.out.println();
System.out.println("Student's name: "+name);
System.out.println("Students age: "+age);
System.out.println("Students roll number: "+roll);
System.out.println("Students standard: "+std);
System.out.println("Students English marks: "+eng);
System.out.println("Students Mathematics marks: "+maths);
System.out.println("Students Physics marks: "+phy);
System.out.println("Students Chemistry marks: "+chem);
System.out.println("Students Biology marks: "+bio);
}
else{
System.out.println();
System.out.println("Student's name: "+name);
System.out.println("Students age: "+age);
System.out.println("Students roll number: "+(roll+1));
System.out.println("Students standard: "+std);
System.out.println("Students English marks: "+eng);
System.out.println("Students Mathematics marks: "+maths);
System.out.println("Students Physics marks: "+phy);
System.out.println("Students Chemistry marks: "+chem);
System.out.println("Students Biology marks: "+bio);
}
}
/**
* This method deletes students entry as per entered roll number
*
*/
public void deldetails(){
name=null;
age=0;
std=0;
eng=0;
maths=0;
phy=0;
chem=0;
bio=0;
System.out.println("...Your respected record hasbeen deleted...");
}
/**
* This method analyzes whether student have passed or failed
*
*
*/
public void reportcard(){
double avg=(eng+maths+phy+chem+bio)/5;
if(avg>40.0 && eng>40.0 && maths>40.0 && phy>40.0)
System.out.println(name+" has passed");
else if(avg>40.0 && eng>40.0 && maths>40.0 && bio>40.0)
System.out.println(name+" has passed");
else if(avg>40.0 && eng>40.0 && maths>40.0 && chem>40.0)
System.out.println(name+"has passed");
else if(avg>40.0 && eng>40.0 && chem>40.0 && bio>40.0)
System.out.println(name+" has passed");
else if(avg>40.0 && eng>40.0 && phy>40.0 && bio>40.0)
System.out.println(name+" has passed");
else if(avg>40.0 && eng>40.0 && phy>40.0 && chem>40.0)
System.out.println(name+" has passed");
else
System.out.println(name+" has failed");
}
}
give reply as well !!!!
public class ArrayObjects{
String name;//important
int age,std;
double eng,maths,phy,chem,bio;
static Scanner sc=new Scanner(System.in);
/**
* This is the monitor of the class...
*
* @param args A parameter
*/
public static void main(String []args){
System.out.println("Enter the number of students");
int n=sc.nextInt();
System.out.println("1:Accept details\n2:Display all records\n3:Display rool no. wise\n4:Deleting records\n5:Modify details\n6:Display wether pass or fail");
ArrayObjects []ob=new ArrayObjects[n];
int ch=0;
do{
System.out.println("....Enter choice....");
ch=sc.nextInt();
switch(ch){
case 1:for(int i=0;i<n;i++){
ob[i]=new ArrayObjects();
ob[i].getdetails();
}
break;
case 2:for(int i=0;i<n;i++){
ob[i].dispdetails(i);
}
break;
case 3:System.out.println("Enter the roll number you want to search");
int rollnum=sc.nextInt();
for(int i=0;i<n;i++){
if((i+1)==rollnum)
ob[i].dispdetails(i);
}
break;
case 4:System.out.println("Enter the roll number you want to delete");
int delroll=sc.nextInt();
for(int i=0;i<n;i++){
if((i+1)==delroll)
ob[i].deldetails();
}
break;
case 5:System.out.println("Enter the roll number of student to modify");
int modroll=sc.nextInt();
for(int i=0;i<n;i++){
if((i+1)==modroll)
ob[i].getdetails();
}
break;
case 6:for(int i=0;i<n;i++){
ob[i].reportcard();
}
break;
default:System.out.println("You have entered wrong choice Sir/Madam pls try again !");
break;
}
}while(ch>0);
}
/**
* This method accepts details of students
*
*/
public void getdetails(){
System.out.println("Enter the student's name");
name=sc.next();
System.out.println("Enter the student's age");
age=sc.nextInt();
System.out.println("Enter the student's class/standard");
std=sc.nextInt();
System.out.println("Enter the student's English marks");
eng=sc.nextDouble();
System.out.println("Enter the student's Maths marks(out of 100)");
maths=sc.nextDouble();
System.out.println("Enter the student's Physics marks(out of 100)");
phy=sc.nextDouble();
System.out.println("Enter the student's Chemistry marks(out of 100)");
chem=sc.nextDouble();
System.out.println("Enter the student's Biology marks(out of 100)");
bio=sc.nextDouble();
}
/**
* This method displays details of the students
*
* biodata
*/
public void dispdetails(int roll){
if(name==null){
roll=0;
System.out.println();
System.out.println("Student's name: "+name);
System.out.println("Students age: "+age);
System.out.println("Students roll number: "+roll);
System.out.println("Students standard: "+std);
System.out.println("Students English marks: "+eng);
System.out.println("Students Mathematics marks: "+maths);
System.out.println("Students Physics marks: "+phy);
System.out.println("Students Chemistry marks: "+chem);
System.out.println("Students Biology marks: "+bio);
}
else{
System.out.println();
System.out.println("Student's name: "+name);
System.out.println("Students age: "+age);
System.out.println("Students roll number: "+(roll+1));
System.out.println("Students standard: "+std);
System.out.println("Students English marks: "+eng);
System.out.println("Students Mathematics marks: "+maths);
System.out.println("Students Physics marks: "+phy);
System.out.println("Students Chemistry marks: "+chem);
System.out.println("Students Biology marks: "+bio);
}
}
/**
* This method deletes students entry as per entered roll number
*
*/
public void deldetails(){
name=null;
age=0;
std=0;
eng=0;
maths=0;
phy=0;
chem=0;
bio=0;
System.out.println("...Your respected record hasbeen deleted...");
}
/**
* This method analyzes whether student have passed or failed
*
*
*/
public void reportcard(){
double avg=(eng+maths+phy+chem+bio)/5;
if(avg>40.0 && eng>40.0 && maths>40.0 && phy>40.0)
System.out.println(name+" has passed");
else if(avg>40.0 && eng>40.0 && maths>40.0 && bio>40.0)
System.out.println(name+" has passed");
else if(avg>40.0 && eng>40.0 && maths>40.0 && chem>40.0)
System.out.println(name+"has passed");
else if(avg>40.0 && eng>40.0 && chem>40.0 && bio>40.0)
System.out.println(name+" has passed");
else if(avg>40.0 && eng>40.0 && phy>40.0 && bio>40.0)
System.out.println(name+" has passed");
else if(avg>40.0 && eng>40.0 && phy>40.0 && chem>40.0)
System.out.println(name+" has passed");
else
System.out.println(name+" has failed");
}
}
give reply as well !!!!
No comments:
Post a Comment