willieshi232

Untitled

Nov 29th, 2015
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. 3.
  2.  
  3. import java.util.*;
  4. import java.io.*;
  5. public class negativeSum
  6. {
  7. public static void main(String [] args)
  8. throws FileNotFoundException
  9. {
  10. Scanner Kyogre = new Scanner(new File("negativeSum.txt"));
  11. int x = 0;
  12. int count = 0;
  13. if(Kyogre.nextInt() < 0)
  14. {
  15. System.out.println("THE FIRST NUMBER IS A NEGATIVE NUMBER");
  16. }
  17. while(Kyogre.hasNextInt() && x >= 0)
  18. {
  19. x = x + Kyogre.nextInt();
  20. count++;
  21. }
  22. System.out.println("Sum of" + x + "after" + count + "steps");
  23. }
  24. }
  25. 5.
  26. import java.util.*;
  27. import java.io.*;
  28. public class collapseSpaces
  29. {
  30. public static void main(String [] args)
  31. throws FileNotFoundException
  32. {
  33. Scanner Moltres = new Scanner(new File("collapseSpaces.txt");
  34. while(Moltres.hasNext())
  35. {
  36. String Entei = Moltres.Next();
  37. System.out.print(Entei + " ");
  38. }
  39. }
  40. }
  41. 7.
  42. import java.util.*;
  43. import java.io.*;
  44. public class flipLines
  45. {
  46. public static void main(String [] args)
  47. throws FileNotFoundException
  48. {
  49. Scanner pikachu = new Scanner(new File("flipLines.txt");
  50. PrintStream out = new PrintStream(new File("Charmander.txt")
  51. while(pikachu.hasNextLine)
  52. {
  53. String line1 = pikachu.nextLine;
  54. String line 2 = pkachu.nextLine;
  55. out.println(line2);
  56. out.println(line1);
  57. }
  58. }
  59. }
  60. 9.
  61. import java.io.*;
  62. import java.util.*;
  63. public class WordWrap
  64. {
  65. public static void main(String [] args)
  66. {
  67. Scanner pikachu = new Scanner(new File("bob.txt");
  68. int x = pikachu.length
  69. int z = 60
  70. while(pikachu.hasNext())
  71. {
  72. output.print(pikachu.Next());
  73. y++;
  74. if(y > z)
  75. {
  76. output.println("");
  77. z * 2
  78. }
  79. }
  80. }
  81. }
  82. 11.
  83. import java.io.*;
  84. import java.util.*;
  85. public class WordWrap
  86. {
  87. public static void main(String [] args)
  88. {
  89. Scanner pikachu = new Scanner(new File("bob.txt");
  90. int x = pikachu.length
  91. int z = 60
  92. while(pikachu.hasNext())
  93. {
  94. output.print(pikachu.Next());
  95. y++;
  96. if(y > z)
  97. {
  98. output.println("");
  99. z * 2
  100. }
  101. }
  102. }
  103. }
  104. 13.
Advertisement
Add Comment
Please, Sign In to add comment