0
import java.util.*;

public class HOA6
{
    public static void main(String args[])
    {
        if(args[0] =="Male" && (Integer.parseInt(args[1])>=1 && Integer.parseInt(args[1])<=58))
        {
            System.out.println("The percentage of interest is: " + 8.4+"%");
        }
        else if(args[0] =="Male" && (Integer.parseInt(args[1])>=59 && Integer.parseInt(args[1])<=100))
        {
            System.out.println("The percentage of interest is: " + 10.5+"%");
        }
        else if(args[0] =="Female" && (Integer.parseInt(args[1])>=1 && Integer.parseInt(args[1])<=58))
        {
            System.out.println("The percentage of interest is: " + 8.2+"%");
        }
        else if(args[0] =="Female" && (Integer.parseInt(args[1])>=59 && Integer.parseInt(args[1])<=100))
        {
            System.out.println("The percentage of interest is: " + 9.2+"%");
        }
    }
}

This is the code of the program. Why this is not giving any output ? I am using the Java language here. I am passing command line arguments as Male and 28 but instead of the logic written for this input , it is not giving any output. What is the problem ?

  • `boolean isMale = "Male".equalsIgnoreCase(args[0]);` - you could (perhaps) *infer* that `if (!isMale)` then the input should be ***female***. Best of luck! – Elliott Frisch Feb 16 '20 at 06:31
  • 2
    Object values are compared with `equals()` check and not `==` – papaya Feb 16 '20 at 06:40

0 Answers0