Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 3.
- import java.util.*;
- import java.io.*;
- public class negativeSum
- {
- public static void main(String [] args)
- throws FileNotFoundException
- {
- Scanner Kyogre = new Scanner(new File("negativeSum.txt"));
- int x = 0;
- int count = 0;
- if(Kyogre.nextInt() < 0)
- {
- System.out.println("THE FIRST NUMBER IS A NEGATIVE NUMBER");
- }
- while(Kyogre.hasNextInt() && x >= 0)
- {
- x = x + Kyogre.nextInt();
- count++;
- }
- System.out.println("Sum of" + x + "after" + count + "steps");
- }
- }
- 5.
- import java.util.*;
- import java.io.*;
- public class collapseSpaces
- {
- public static void main(String [] args)
- throws FileNotFoundException
- {
- Scanner Moltres = new Scanner(new File("collapseSpaces.txt");
- while(Moltres.hasNext())
- {
- String Entei = Moltres.Next();
- System.out.print(Entei + " ");
- }
- }
- }
- 7.
- import java.util.*;
- import java.io.*;
- public class flipLines
- {
- public static void main(String [] args)
- throws FileNotFoundException
- {
- Scanner pikachu = new Scanner(new File("flipLines.txt");
- PrintStream out = new PrintStream(new File("Charmander.txt")
- while(pikachu.hasNextLine)
- {
- String line1 = pikachu.nextLine;
- String line 2 = pkachu.nextLine;
- out.println(line2);
- out.println(line1);
- }
- }
- }
- 9.
- import java.io.*;
- import java.util.*;
- public class WordWrap
- {
- public static void main(String [] args)
- {
- Scanner pikachu = new Scanner(new File("bob.txt");
- int x = pikachu.length
- int z = 60
- while(pikachu.hasNext())
- {
- output.print(pikachu.Next());
- y++;
- if(y > z)
- {
- output.println("");
- z * 2
- }
- }
- }
- }
- 11.
- import java.io.*;
- import java.util.*;
- public class WordWrap
- {
- public static void main(String [] args)
- {
- Scanner pikachu = new Scanner(new File("bob.txt");
- int x = pikachu.length
- int z = 60
- while(pikachu.hasNext())
- {
- output.print(pikachu.Next());
- y++;
- if(y > z)
- {
- output.println("");
- z * 2
- }
- }
- }
- }
- 13.
Advertisement
Add Comment
Please, Sign In to add comment