Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2.
- import java.io.*;
- import java.util.*;
- public class Project1
- {
- public static void main(String [] args)
- {
- Scanner Kyogre = new Scanner(new File("paper.txt");
- int Linecount = 1
- int Wordcount = 1
- while(Kyogre.hasNextLine())
- {
- Linecount++;
- Scanner pikachu = new Scanner(Kyogre.nextLine());
- if(pikachu.hasNext())
- {
- Wordcount++;
- }
- }
- System.out.print("You have" + Lines + "lines in your paper, and have" + Wordcount + "words.");
- }
- }
- 4.
- import java.util.*;
- import java.io.*;
- import java.applet.*;
- import java.awt.*;
- public class babyNames
- {
- public static void main(String [] args)
- throws FileNotFoundException
- {
- Scanner pikachu = new Scanner(System.in);
- Scanner Kyogre = new Scanner(new File("names2.txt"));
- System.out.println("This program allows you to search through the \ndata from the Social Security Administration \n to see how popular a particular name has een\n since 1940.");
- System.out.print("Name?");
- String Espeon = pikachu.next();
- int year = 1940;
- System.out.println("Statistics on name \""+ Espeon + "\"");
- while(Kyogre.hasNextLine())
- {
- Scanner Shaymin = new Scanner(Kyogre.nextLine());
- String Darkrai = Shaymin.next();
- if(Darkrai == Espeon)
- {
- String Glaceon = Shaymin.next();
- System.out.print("\t" + year + ":" + Glaceon);
- year = year + 10;
- }
- else
- {
- System.out.print("");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment