private couseName & grade
i have errors in the "if" and both "else if"
the compiler says "cannot convert from String to boolean and
int to String
1. Add two private instance variables,
String courseName and char grade to this class.
2. Add accessor and mutator methods for these
3. Add a method register which receives an integer data type and returns String data type according to the argument passed to it (“Math” for 1, “English” for 2, “No course” for any other input)
what i have so far:
public class BannerUser
private int userId;
public int getUserId()
public void setUserId(int userId)
private String courseName;
public String getcourseName()
public void setcourseName(String courseName)
private char grade;
public char getGrade()
public String getCourse()
if (course = 1)
else if(course = 2)
else if (course != 1 !=2)
return "No course";
Re: private couseName & grade
this statement else if (course != 1 !=2) made a compilation error, that is not a boolean expression and an invalid syntax in java.
if you want to compare a course to 1 or 2, you can use logical operator || for conditional OR && for conditional AND etc.
please refer to this link: Summary of Operators (The Java™ Tutorials > Learning the Java Language > Language Basics) or Java logical operators