Edit: my problem has been partially fixed. Now I am able to enter text, however nothing reads after I enter the 'shiphalf' value. Did I construct my if else statements incorrectly?
I am attempting to let people input a coupon code but I am unable to figure out how to let the console know that the user is inputting text. I feel that the error is somewhere in here:
System.out.println("Enter a Coupon Code: ");
String ship = input.nextLine();
But I am not entirely sure. Here is the whole source code below:
package pseudoPackage;
import java.util.Scanner;
public class PseudoCode {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int ship1 = 0;
int ship2 = 6;
int ship3 = 2;
String shiphalf = null;
System.out.print("How much will shipping cost you?");
System.out.println();
System.out.print("Enter your textbook cost in dollars without the $: ");
double cost = input.nextDouble();
if ( cost >= 100 ) {
System.out.println("Your shipping costs are $0");
} else if ( cost < 100 && cost > 50 ) {
System.out.println("Your shipping cost is $6");
} else if ( cost < 50 ) {
System.out.println("Your shipping cost is $2");
}
System.out.println("Enter a Coupon Code: ");
String ship = input.nextLine();
if ( ship == shiphalf && cost >= 100 ) {
System.out.println("Your shipping costs are $0");
} else if ( ship == shiphalf && cost < 100 && cost >50 ) {
System.out.println("Your shipping costs are $3 ");
} else if ( ship == shiphalf && cost < 50 ) {
System.out.println("Your shipping costs are $1");
}
}
}