Advertisement
Epi-Pdo

Tuto7_1(b)

Nov 20th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package tutoetc;
  7.  
  8. import java.util.Random;
  9.  
  10. /**
  11.  *
  12.  * @author WIF170097
  13.  */
  14. //import java.io.PrintWriter;
  15. //import java.io.FileOutputStream;
  16. //import java.io.IOException;
  17. import java.io.*;
  18. import java.util.*;
  19. public class Tutoetc {
  20.  
  21.     /**
  22.      * @param args the command line arguments
  23.      */
  24.     public static void main(String[] args) {
  25.         // TODO code application logic here
  26.        int max=0,num;
  27.        try {
  28.            Scanner inputStream = new Scanner(new FileInputStream("integer.txt"));
  29.            
  30.            System.out.println("the list of integer is ");
  31.            while(inputStream.hasNextInt())
  32.            {
  33.                num=inputStream.nextInt();
  34.                System.out.print(num +" ");
  35.                if(num>max)
  36.                    max=num;
  37.            }
  38.            System.out.println();
  39.            System.out.println("The largest integer is "+max);
  40.            inputStream.close();
  41.        } catch (FileNotFoundException e) {
  42.            System.out.println("File was not found");
  43.        }
  44.         }
  45.        
  46.  
  47.    
  48.    
  49.  
  50.    
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement