|
|
back to boardwhy doesn't it work? java Posted by Argin 27 Feb 2020 21:10 import java.util.Scanner; public class javasucc { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int h = 2, s = 10; for(int i=0; i<n; i++) { int a = in.nextInt(); String b = in.next(); if(b=="hungry"){ if(a>h) {h = a;} } else if(b=="satisfied"){ if(a<s) {s = a;} } } if(h >= s) System.out.println("Inconsistent"); else System.out.println(s); } } and the problem is that program doesn't want to do if and i can't change s to a Re: why doesn't it work? java Re: why doesn't it work? java Posted by Argin 12 Mar 2020 20:58 1) I wasn't crying for help though but just was wondering why 2) Thanks for the link, the problem was actually in "==" |
|
|