this is my java coding:
import java.util.Scanner;
import java.io.*;
public class readNumbers
{
public static void main(String[]args) throws IOException
{
int num;
String filename;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter the filename: ");
filename=keyboard.nextLine();
FileWriter fwriter=new FileWriter(filename);
PrintWriter outputFile=new PrintWriter(fwriter);
for(int i=1; i<=5; i++)
{
System.out.print("Enter a number: ");
num=keyboard.nextInt();
outputFile.println(num);
keyboard.nextLine();
}
outputFile.close();
int sum;
String str;
double average;
FileReader freader=new FileReader(filename);
BufferedReader inputFile=new BufferedReader(freader);
sum=0;
str=inputFile.readLine();
while(str!=null)
{
sum=sum+Integer.parseInt(str);
str=inputFile.readLine();
}
inputFile.close();
System.out.println("The sum is: "+sum);
average=sum / 5.0;
System.out.println("the average is: "+average);
}
}
i dont know how to write the coding to find the largest number..
anyone know how to do it?
thanks