Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import java.io.FileNotFoundException;
  2. import java.util.Scanner;
  3. import java.io.File;
  4. import java.io.IOException;
  5. public class Homework08 {
  6. public static void main (String [] args) throws FileNotFoundException {
  7. Scanner scan = new Scanner(System.in);
  8. Scanner scanFileName= new Scanner(System.in);
  9. System.out.print("Enter a file name to read: ");
  10. String fileName = scanFileName.next();
  11. File f = new File(fileName);
  12. Scanner scanFile = new Scanner(f);
  13. System.out.print("Enter number of layer of stars: ");
  14. int n = scan.nextInt();
  15. for(int i=1; i <= n; i++) {
  16. //display stars
  17. for(int j=1; j <= (n+1-i); j++) {
  18. System.out.print("*");
  19. }
  20. System.out.println();
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement