Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

hey guys,, can anybody help me with this? its for java neatbeans.. thanks A prof

ID: 3792895 • Letter: H

Question

hey guys,, can anybody help me with this? its for java neatbeans.. thanks

A professor has posted a list of student numbers and marks. Write a program to read the marks and compute the rank of a student in class; the rank is computed using the usual manner as follows: if the student has the top mark (or is tied for the top mark) his rank is 1; if he has the second best mark (or is tied) his rank is 2, and so on. Input (from a file called rank.in) The input consists of several test cases. Each case begins with Ahmed's student number, an integer between 1000000 and 9999999. Following the student number are a number of lines, each containing a student number between 1000000 and 9999999 and a mark between 0 and 100. A line with a student number and mark of 0 terminates each test case. There are no more than 1000 students in the class, and each has a unique student number. Output (to a file called rank.out) For each test case, output a line giving Ahmed's rank in the class.

Explanation / Answer

Create Project in Netbeans "Rank_Calculations"

Paste rank.in file into project directory

Check your output file rank.out in same directory.

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package rank_calculations;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;
/**
*
* @author Arjun
*/
public class Rank_Calculations {

/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
List<String> list_1=new ArrayList<String>();
// TODO code application logic here
try
{
File file = new File("rank.in");
FileReader file_read = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(file_read);
String line;
while ((line = bufferedReader.readLine()) != null)
{
list_1.add(line.toString());
}
file_read.close();
}
catch (IOException e)
{
e.printStackTrace();
}
String[] student_name = (list_1.get(0)).split(" ");
int marks[]=new int[1000];
String sname[]=new String[1000];
sname[0]=student_name[0];
marks[0]=0;
int rank=1;
int total_std=list_1.size()-2;
for(int i=1;i<list_1.size()-1;i++)
{
String[] data_l = (list_1.get(i)).split(" ");
sname[i]=data_l[0];
marks[i]=Integer.parseInt(data_l[1]);
if(sname[i].equals(sname[0]))
{
marks[0]=marks[i];
}
if(sname[i].equals("0") && marks[i]==0)
break;
}
for(int i=1;i<list_1.size()-1;i++)
{
if(marks[i]>marks[0])
{
rank++;
}
}
System.out.println("Total Students: "+total_std+" Student Rank"+ rank);
String newLine = System.getProperty("line.separator");
try
{
java.io.FileWriter fw = new java.io.FileWriter("rank.out");
String write1=""+rank+newLine+total_std;
fw.write(write1);
fw.close();
}
catch(Exception E)
{
System.out.println(E.getStackTrace());
}
  
}
}

//Console Output NetBeans:

run:
Total Students: 6 Student Rank4
BUILD SUCCESSFUL (total time: 0 seconds)

//Output File

4
6