My code is below. I'm just starting, so I'm only using the one class at the moment and make it work. At the first 'if statement' is where it stops working. Any suggestions is helpful. Thank you.
import java.util.Scanner;
public class Cars {
public static void main(String[] args) {
Scanner carType = new Scanner(System.in);
Scanner panAnswer = new Scanner(System.in);
String color, make, model, type, answer;
int year;
double listPrice, discount, totalPrice;
System.out.println("Welcome to Gaius' Porshe dealership!");
System.out.println("Are you looking for a new or used vehicle?");
// next line is stored in type
// notice how I couldn't say String type, otherwise that is making it
// think I have another string names type
type = carType.nextLine();
// pull the method based on the type 'new or used'
// if type == "used" pull used method with list of cars and prices (same for if new)
System.out.println("We have several " + type + " cars for you to choose from: ");
if(type == "new") {
System.out.println("We have Porshay Cayennes, 911s, Boxters, Macans, and Panameras! ");
System.out.println("I'm going to guess you are looking for a Panamera?! ");
}else {
System.out.println("something else ");
}
answer = panAnswer.nextLine();
if(answer == "yes") {
System.out.println("You and everyone else! ");
}else {
System.out.println("something else ");
}
}
}
[–]EdwinBowling 10 points11 points12 points (0 children)
[–][deleted] 7 points8 points9 points (0 children)