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!!

[1007 byte] By [Curious-George_1@Otta] at [2007-11-26 16:59:37]
# 1
common mistake. you mean student == 'y'
georgemca at 2007-7-8 23:27:24 > top of Java-index,Java Essentials,New To Java...
# 2
> common mistake. you mean student == 'y'No. It's a String.(student.equals("Y"))or(student.equalsIgnoreCase("Y"))
doremifasollatidoa at 2007-7-8 23:27:24 > top of Java-index,Java Essentials,New To Java...
# 3

> > common mistake. you mean student == 'y'

>

> No. It's a String.

> (student.equals("Y"))

> or

> (student.equalsIgnoreCase("Y"))

good catch. for no apparent reason, I assumed it was a char

georgemca at 2007-7-8 23:27:24 > top of Java-index,Java Essentials,New To Java...
# 4
He's also missing the word "else" and an opening brace.
doremifasollatidoa at 2007-7-8 23:27:24 > top of Java-index,Java Essentials,New To Java...
# 5
He isn't, but the lack of formatting makes it look that way.
DavidKNa at 2007-7-8 23:27:24 > top of Java-index,Java Essentials,New To Java...
# 6
Umm yes he IS missing the keyword else. Now isStudent gets set to false everytime. =)
duckbilla at 2007-7-8 23:27:24 > top of Java-index,Java Essentials,New To Java...