Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package amanda_tian_cccl1_test2;
  7. import java.util.Scanner;
  8. import java.util.Stack;
  9.  
  10. /**
  11. *
  12. * @author amand
  13. */
  14. public class ItsColdHere {
  15. public static void main(String[]args){
  16. Scanner input = new Scanner(System.in);
  17. String ncity = "";
  18. int temperature = 0;
  19. int min = 200;
  20. int count = 0;
  21. Stack<Integer> temp = new Stack<Integer>();
  22. Stack<String> city = new Stack<String>();
  23. do{
  24. ncity = input.next();
  25. temperature = input.nextInt();
  26. city.push(ncity);
  27. temp.push(temperature);
  28. }
  29. while(!city.peek().equals("Waterloo"));
  30.  
  31. if(temp.peek() < min){
  32. min = temp.peek();
  33. temp.pop();
  34. count++;
  35. }
  36. for(int i = 0; i < city.size() - count + 1; i++){
  37. city.pop();
  38. }
  39.  
  40. System.out.print(city.peek());
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement