Create an input file Lab7lintxt with following content Write

Create an input file Lab7_l_in.txt with following content: Write a JAVA Program that will implement two dimensional array. Define the row size as 10 and column size as 10. Define an one dimensional array called name of size of row to store name of students and two dimensional array called score to store the score of each student in each assignment. Run the program as follow to store your output in a file Lab7_l_out.txt. java Lab7_l Lab7_l_out.txt Your program should read the input file and should show the output as sample output: Submit your JAVA file, input file and output file.

Solution

import java.io.*;
class Studentdatabase
{
int rollnumber;
String name;
int number_of_subjects;
int marks[]; // to store marks in 3 subjects

Studentdatabase(int roll,String student_name,int numberofsub)throws IOException
{
rollnumber=roll;
name=stud_name;
number_of_subjects= numberofsub;
getMarks(numberofsub);
}
public void getMarks(int numberofsub ) throws IOException
{
marks=new int[numberofsub];
BufferedReader br= new BufferedReader (new InputStreamReader(System.in));
for (int i=0; i<numberofsub;i++)
{
System.out.println(“pLEASE Enter “+i+”Subject Marks.:=> “);
marks[i]=Integer.parseInt(br.readLine());
System.out.println(“”);
}

}
public void calculateGrade() // to calculate the grade on the basis of marks
{
double percentage=0;
String grade;
int totalmarks=0;
for (int i=0;i<marks.length;i++)
{
totalmarks+=marks[i];
}
percentage=totalmarks/number_of_subjects;
System.out.println(“The Roll Number is :=> “+rollno);
System.out.println(“The Name Of the Student is :=> “+name);
System.out.println(“ The Number Of Subject :=> “+number_of_subjects);
System.out.println(“ The Percentage Is :=> “+percentage);

if (percentage>=70)
System.out.println(“THE Grade Is First Class With Distinction “);
else if(percentage>=60 && percentage<70)
System.out.println(“tThe grade Is First Class”);
else if(percentage>=50 && percentage<60)
System.out.println(“tHE Grade Is Second Class”);
else if(percentage>=40 && percentage<50)
System.out.println(“The Grade Is Pass Class”);
else
System.out.println(“You Are Fail”);
}
}
class Studenttest
{
public static void main(String args[])throws IOException
{
int rollno,num,numberstud;
String name;
BufferedReader br= new BufferedReader (new InputStreamReader(System.in));
System.out.println(“Please enter How many Students are there:=> “);
numberstud=Integer.parseInt(br.readLine());
Studentdatabase stud[]=new Studentdatabase[numberstud];

for(int i=0;i<numberstud;i++)
{
System.out.println(“now please enter Roll Number:=> “);
rollno=Integer.parseInt(br.readLine());
System.out.println(“now you will be Enter Name:=> “);
name=br.readLine();
System.out.println(“Finally Enter No of Subject:=> “);
num=Integer.parseInt(br.readLine());
stud[i]=new Student(rollno,name,no);
}
for(int i=0;i<numberstud;i++)
{
stud[i].calculateGrade();
}

}
}

 Create an input file Lab7_l_in.txt with following content: Write a JAVA Program that will implement two dimensional array. Define the row size as 10 and column
 Create an input file Lab7_l_in.txt with following content: Write a JAVA Program that will implement two dimensional array. Define the row size as 10 and column

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site