In this program Roll Number and marks on English, Mathematics, Physics, Chemistry of 'n' number of students are taken in separate 1 d arrays. Promotion is granted according to the following criterias:
The candidate must have passed in English and in at least any two subjects of Mathematics, Physics, Chemistry. Pass marks is 35.
import java.util.*;
class Promition
{
Scanner sc=new Scanner(System.in);
int n;
int roll[];
int eng[];
int math[];
int phy[];
int chem[];
int i,f;
void take()
{
int roll[];
int eng[];
int math[];
int phy[];
int chem[];
int i,f;
void take()
{
System.out.print("\nHow many Students: ");
n=sc.nextInt();
roll=new int[n];
eng=new int[n];
math=new int[n];
phy=new int[n];
chem=new int[n];
for(i=0;i<n;i++)
{
System.out.print("\nRoll Number of Student Number "+(i+1)+":");
roll[i]=sc.nextInt();
System.out.print("\nEnglish Marks:");
eng[i]=sc.nextInt();
System.out.print("\nMath Marks:");
math[i]=sc.nextInt();
System.out.print("\nPhysics Marks:");
phy[i]=sc.nextInt();
System.out.print("\nChemistry Marks:");
chem[i]=sc.nextInt();
}
System.out.println("\nResult Sheet:");
System.out.println("\nRoll Eng Math Phy Chem");
for(i=0;i<n;i++)
{
if(roll[i]<10)
System.out.print("0"+roll[i]+" ");
else
System.out.print(roll[i]+" ");
if(eng[i]<10)
System.out.print("00"+eng[i]+" ");
else if (eng[i]<100)
System.out.print("0"+eng[i]+" ");
else
System.out.print(eng[i]+" ");
if(math[i]<10)
System.out.print("00"+math[i]+" ");
else if (math[i]<100)
System.out.print("0"+math[i]+" ");
else
System.out.print(math[i]+" ");
if(phy[i]<10)
System.out.print("00"+phy[i]+" ");
else if (phy[i]<100)
System.out.print("0"+phy[i]+" ");
else
System.out.print(phy[i]+" ");
if(chem[i]<10)
System.out.print("00"+chem[i]+" ");
else if (chem[i]<100)
System.out.print("0"+chem[i]+" ");
else
System.out.print(chem[i]+" ");
System.out.println();
// System.out.print("\n"+roll[i]+" "+eng[i]+" "+math[i]+" "+phy[i]+" "+chem[i]);
}
for(i=0;i<n;i++)
{
f=0;
if(eng[i]>=35)
{
if(math[i]>=35)
f++;
if(phy[i]>=35)
f++;
if(chem[i]>=35)
f++;
}
if(f>=2)
System.out.println("\n "+roll[i]+": Promition is Granted...");
else
System.out.println("\n "+roll[i]+": Promition is not Granted...");
}
}
public static void main(String args[])
{
Promotion ob=new Promotion();
ob.take();
eng=new int[n];
math=new int[n];
phy=new int[n];
chem=new int[n];
for(i=0;i<n;i++)
{
System.out.print("\nRoll Number of Student Number "+(i+1)+":");
roll[i]=sc.nextInt();
System.out.print("\nEnglish Marks:");
eng[i]=sc.nextInt();
System.out.print("\nMath Marks:");
math[i]=sc.nextInt();
System.out.print("\nPhysics Marks:");
phy[i]=sc.nextInt();
System.out.print("\nChemistry Marks:");
chem[i]=sc.nextInt();
}
System.out.println("\nResult Sheet:");
System.out.println("\nRoll Eng Math Phy Chem");
for(i=0;i<n;i++)
{
if(roll[i]<10)
System.out.print("0"+roll[i]+" ");
else
System.out.print(roll[i]+" ");
if(eng[i]<10)
System.out.print("00"+eng[i]+" ");
else if (eng[i]<100)
System.out.print("0"+eng[i]+" ");
else
System.out.print(eng[i]+" ");
if(math[i]<10)
System.out.print("00"+math[i]+" ");
else if (math[i]<100)
System.out.print("0"+math[i]+" ");
else
System.out.print(math[i]+" ");
if(phy[i]<10)
System.out.print("00"+phy[i]+" ");
else if (phy[i]<100)
System.out.print("0"+phy[i]+" ");
else
System.out.print(phy[i]+" ");
if(chem[i]<10)
System.out.print("00"+chem[i]+" ");
else if (chem[i]<100)
System.out.print("0"+chem[i]+" ");
else
System.out.print(chem[i]+" ");
System.out.println();
// System.out.print("\n"+roll[i]+" "+eng[i]+" "+math[i]+" "+phy[i]+" "+chem[i]);
}
for(i=0;i<n;i++)
{
f=0;
if(eng[i]>=35)
{
if(math[i]>=35)
f++;
if(phy[i]>=35)
f++;
if(chem[i]>=35)
f++;
}
if(f>=2)
System.out.println("\n "+roll[i]+": Promition is Granted...");
else
System.out.println("\n "+roll[i]+": Promition is not Granted...");
}
}
public static void main(String args[])
{
Promotion ob=new Promotion();
ob.take();
}
} }
No comments:
Post a Comment