/*WAP to take the marks of N number of students.
Display the marks of all the students.
Display the marks of students whose marks are more than or equal to 39.
Display the marks of students whose marks are less than 39.
Display the marks of students whose marks are more than or equal to average marks.
*/
import java.util.*;
public class score
{
public static void main(String []args)
{
Scanner in=new Scanner(System.in);
double marks[]=new double[100];
double sum=0.0, avg;
int n, c;
char ch='y';
//For taking the number of students.
System.out.print("Enter the No. of Students : ");
n=in.nextInt();
//For taking the marks of the no. of students.
for(int i=0;i<n;i++)
{
marks[i]=(int)(Math.random()*100);
sum=sum+marks[i];
}
avg=(int)(sum/n);
do
{
System.out.println("\n\nFollowing Operations can be done.");
System.out.println("1. Show Marks of all students.");
System.out.println("2. Show Marks of students whose marks are more than equal 39.");
System.out.println("3. List of students whose marks are less than 39.");
System.out.println("4. List of students whose marks are more than or equal to average.");
System.out.print(" Enter Your Choice : ");
c=in.nextInt();
switch(c)
{
case 1:
//Displaying the marks obtained by the no. of students.
for(int i=0;i<n;i++)
{
System.out.println("Roll No. "+(i+1)+" : "+marks[i]);
}
break;
case 2:
//Displaying the list of students whose marks are more than 39
for(int i=0;i<n;i++)
{
if(marks[i]>=39)
System.out.println("Roll No. "+(i+1)+" : "+marks[i]);
}
break;
case 3:
//Displaying the list of students whose marks are more than 39
for(int i=0;i<n;i++)
{
if(marks[i]<39)
System.out.println("Roll No. "+(i+1)+" : "+marks[i]);
}
break;
case 4:
System.out.println("The Average marks of the student is : "+avg);
//Displaying the list of students whose marks are more than or equal to average marks
for(int i=0;i<n;i++)
{
if(marks[i]>=avg)
System.out.println("Roll No. "+(i+1)+" : "+marks[i]);
}
break;
default:
System.out.println("Please enter the correct option.");
break;
}
System.out.print("\n\nDo you want to run the options again (Y/N) ? ");
String str=in.next();
ch=str.charAt(0);
}while(ch=='y'||ch=='Y');
}
}
Display the marks of all the students.
Display the marks of students whose marks are more than or equal to 39.
Display the marks of students whose marks are less than 39.
Display the marks of students whose marks are more than or equal to average marks.
*/
import java.util.*;
public class score
{
public static void main(String []args)
{
Scanner in=new Scanner(System.in);
double marks[]=new double[100];
double sum=0.0, avg;
int n, c;
char ch='y';
//For taking the number of students.
System.out.print("Enter the No. of Students : ");
n=in.nextInt();
//For taking the marks of the no. of students.
for(int i=0;i<n;i++)
{
marks[i]=(int)(Math.random()*100);
sum=sum+marks[i];
}
avg=(int)(sum/n);
do
{
System.out.println("\n\nFollowing Operations can be done.");
System.out.println("1. Show Marks of all students.");
System.out.println("2. Show Marks of students whose marks are more than equal 39.");
System.out.println("3. List of students whose marks are less than 39.");
System.out.println("4. List of students whose marks are more than or equal to average.");
System.out.print(" Enter Your Choice : ");
c=in.nextInt();
switch(c)
{
case 1:
//Displaying the marks obtained by the no. of students.
for(int i=0;i<n;i++)
{
System.out.println("Roll No. "+(i+1)+" : "+marks[i]);
}
break;
case 2:
//Displaying the list of students whose marks are more than 39
for(int i=0;i<n;i++)
{
if(marks[i]>=39)
System.out.println("Roll No. "+(i+1)+" : "+marks[i]);
}
break;
case 3:
//Displaying the list of students whose marks are more than 39
for(int i=0;i<n;i++)
{
if(marks[i]<39)
System.out.println("Roll No. "+(i+1)+" : "+marks[i]);
}
break;
case 4:
System.out.println("The Average marks of the student is : "+avg);
//Displaying the list of students whose marks are more than or equal to average marks
for(int i=0;i<n;i++)
{
if(marks[i]>=avg)
System.out.println("Roll No. "+(i+1)+" : "+marks[i]);
}
break;
default:
System.out.println("Please enter the correct option.");
break;
}
System.out.print("\n\nDo you want to run the options again (Y/N) ? ");
String str=in.next();
ch=str.charAt(0);
}while(ch=='y'||ch=='Y');
}
}