Advertisement
Nancy-M

Homework

Jun 16th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class ccc11j2 {
  3.  
  4. public static void main(String[] args) {
  5. // TODO Auto-generated method stub
  6.  
  7. // what is h, h is first input
  8. // what is M, M is second input, Maximum t
  9.  
  10. Scanner sc = new Scanner (System.in);
  11. int h = sc.nextInt();
  12. int M = sc.nextInt();
  13. boolean touch = false;
  14. for (int t=1;t<=M; t++) {
  15. int A = -6*t*t*t*t+h*t*t*t+2*t*t+t;
  16. if (A<=0) {
  17. System.out.println("The balloon first touches ground at hour: ");
  18. System.out.println(t);
  19. touch = true;
  20. break;
  21. }
  22. }
  23. if (touch==false) {
  24. System.out.println("The balloon does not"
  25. +"touch ground in the given time.");
  26. }
  27. }
  28.  
  29. }
  30.  
  31.  
  32. import java.util.Scanner;
  33. public class ccc13j2{
  34. public static void main(String[] args) {
  35.  
  36. Scanner sc = new Scanner(System.in);
  37.  
  38. String t = sc.nextLine();
  39.  
  40. for(int i = 0; i<t.length();i++) {
  41.  
  42. if(t.charAt(i) == 'A'||t.charAt(i) == 'B' ||t.charAt(i) == 'C'||
  43. t.charAt(i) == 'D' || t.charAt(i) == 'E' || t.charAt(i) == 'F' || t.charAt(i) == 'G' ||
  44. t.charAt(i) == 'J' || t.charAt(i) == 'K' || t.charAt(i) == 'L' || t.charAt(i) == 'M' || t.charAt(i) == 'P' ||
  45. t.charAt(i) == 'Q' || t.charAt(i) == 'R' || t.charAt(i) == 'T' || t.charAt(i) == 'U' || t.charAt(i) == 'V' ||
  46. t.charAt(i) == 'W' || t.charAt(i) == 'Y') {
  47. System.out.println("NO");
  48. System.exit(0);
  49. }
  50.  
  51. }
  52. for(int i = 0; i<t.length();i++) {
  53. if(t.charAt(i) == 'I' ||t.charAt(i) == 'O' ||t.charAt(i) == 'S' ||t.charAt(i) == 'H' ||t.charAt(i) == 'Z' ||t.charAt(i) == 'X' ||t.charAt(i) == 'N' ) {
  54. System.out.println("YES");
  55. System.exit(0);
  56. }
  57. }
  58.  
  59. }
  60. }
  61.  
  62.  
  63. import java.util.Scanner;
  64. public class ccc09j2 {
  65.  
  66. public static void main(String[] args) {
  67. // TODO Auto-generated method stub
  68. Scanner sc = new Scanner(System.in);
  69. int trout = sc.nextInt();
  70. int pike = sc.nextInt();
  71. int pickerel = sc.nextInt();
  72. int total = sc.nextInt();
  73. int count =0;
  74. for(int i=0;i<=total+1;i++) {
  75. for( int j=0;j<=total+1;j++) {
  76. for(int k=0;k<=total+1;k++) {
  77. if((i*trout)+(j*pike)+(k*pickerel)<=total&&i+j+k>0) {
  78. System.out.print(i+" Brown Trout, ");
  79. System.out.print(j+" Northern Pike, ");
  80. System.out.print(k+" Yellow Pickerel");
  81. System.out.println();
  82. count++;
  83. }
  84. }
  85. }
  86. }
  87. System.out.println("Number of ways to catch fish: "+count);
  88. }
  89. }
  90.  
  91. import java.util.Scanner;
  92.  
  93. public class ccc07j2 {
  94.  
  95. public static void main(String[] args) {
  96. // TODO Auto-generated method stub
  97.  
  98. Scanner sc = new Scanner(System.in);
  99. while(true) {
  100. String S = sc.next();
  101. if (S.equals("CU")) {
  102. System.out.println("See you");
  103. }else if (S.equals(":-)")) {
  104. System.out.println("I'm happy");
  105. }else if (S.equals(":-(")) {
  106. System.out.println("I'm unhappy");
  107. }else if (S.equals(";-)")) {
  108. System.out.println("wink");
  109. }else if (S.equals(":-p")) {
  110. System.out.println("Stick out my tongue");
  111. }else if (S.equals("~.~")){
  112. System.out.println("sleepy");
  113. }else if (S.equals("TA")){
  114. System.out.println("totally awesome");
  115. }else if (S.equals("CCC")){
  116. System.out.println("Canadian Computing Competition");
  117. }else if (S.equals("CUZ")){
  118. System.out.println("because");
  119. }else if (S.equals("TY")) {
  120. System.out.println("thank-you");
  121. }else if (S.equals("TW")) {
  122. System.out.println("You're welcome");
  123. }else if (S.equals("TTYL")) {
  124. System.out.println("Talk to you later");
  125. break;
  126.  
  127. }
  128. else
  129. System.out.println();
  130. }
  131. }
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement