my code for this part work fine and is import java.io.BufferedReader; import jav
ID: 3656823 • Letter: M
Question
my code for this part work fine and is
import java.io.BufferedReader;
import java.io.IOException;
import java.io.*;
import java.io.InputStreamReader;
import java.util.*;
public class q4w
{
public static void main(String[] args) throws IOException
{
String filename,buffer,parts[];
double grade;
Scanner input=new Scanner (System.in);
System.out.print("Enter name of input file:");
filename=input.nextLine();
Scanner scan=new Scanner(new File(filename));
System.out.print("Enter name of output file: ");
filename=input.next();
PrintStream output=new PrintStream(new File(filename));
output.println("name Grade");
while(scan.hasNext())
{
buffer=scan.nextLine();
parts=buffer.split(":");
grade=Double.parseDouble(parts[1]);
output.println(parts[0]+" "+getGrade(grade));
}
System.out.println("Processing complete.");
} // main close
public static String getGrade(double mark)
{
if(mark < 50) // Less then 50 "F"
{
return "F";
} else if (mark >= 50 && mark <= 59) // 50 -59 "D"
{
return "D";
} else if(mark >= 60 && mark <= 69) // 60-69 "C"
{
return "C";
} else if(mark >= 70 && mark <= 79) // 70-79 "B"
{
return "B";
} else if(mark >= 80 && mark <= 89) // 80-89 "A"
{
return "A";
} else
{
return "A+"; // 90 - 100 "A+"
}
} // getGrade close
}
Need help to do this part below.
input file contains:
Steve Jobs:102
Bill Gates:12
Dennis Ritchie:B
Ken Thompson:-9
Linus Torvalds:55
Mark Zuckerberg:62