Simple java question
Hi, I'm doing a beginner Java course and need help with an assignment.
I need to ask user if he/she is a student, and if so, deduct 10% from the total cost of a pizza.
We're using the Scanner class to obtain user input. I also think that I need a boolean variable. However, I'm having a hard time trying to code this.
This is what I'm coming up with, but the line if (student="y") is wrong.
import java.util.Scanner;
public class student {
public static void main(String[] args){
boolean isStudent = false;
double pizzaCost = 9.99;
double studentDiscountRate = 0.1;
double studentDiscount;
System.out.println("Are you a student? y/n");
Scanner keyboard = new Scanner(System.in);
String student = keyboard.next();
if (student = "y"){
isStudent = true;
studentDiscount = studentDiscountRate * pizzaCost;
}
isStudent = false;
studentDiscount = 0;
}
}
Please help!!

