0
import java.util.Scanner;

public class ISP
{
   public static void main(String[] args)
   {
      Scanner input = new Scanner(System.in);
      String ISPP;
      int hours;
  double runup, total;

  System.out.println("Please enter which package you have.");
  ISPP = input.nextLine();

  if(ISPP == "A")
  {
     System.out.println("Please enter the number of hours you have used the         
     interwebs.");
     hours = input.nextInt();
     if(hours > 10)
        {
          runup = (hours - 10) * 2; 
          total = runup + 9.95;
          System.out.println("The total charge is $" + total);
        } 
  }


}

}

So when it runs the user enters either A B or C, if I try to enter to to test it out and enter A the operation ends and nothing happens, have not written the B or C yet

  • Not sure if students now just write code by themselves or professors/teachers are failing on the basics of programming by no explaining the difference between using `==` and `equals` method =\ – Luiggi Mendoza Oct 12 '13 at 18:16

1 Answers1

0

You have to make comparision of String with equals method.

if (ISPP.equals("A"))

Also, you can use compareTo method

if (ISPP.compareTo("A") == 0)
libik
  • 22,239
  • 9
  • 44
  • 87