i have the code below, i want to use a switch-case to check the grade of the student, my problem is that the compiler tells me that swithc only takes intergers as arguments. i had thought i cud have a statement like case a > b where a and b are double.
package tutorial3;
public class Tutorial3
{
private String Name, StdID,Program, Year, Class, attendance;
private double Marks;
Tutorial3()
{
Name = "No data entered";
StdID = "No data entered";
Program = "No data entered";
Year = "No data entered";
Class = "No data entered";
Marks = 00.00;
}
Tutorial3(String name,String StudId,String program, String year,String Class, double MARKS)
{
this.setName(name);
this.setProgram(program);
this.setStudID(StudId);
this.setYear(year);
this.setClass(Class);
this.setMarks(Marks);
}
public void setMarks(double marks)
{
this.Marks = marks;
}
public void setName(String name)
{
Name = name;
}
public void setStudID(String StudId)
{
StdID = StudId;
}
public void setProgram(String program)
{
Program = program;
}
public void setYear(String year)
{
Year = year;
}
public void setClass(String Class)
{
this.Class = Class;
}
public void getMarks()
{
if(this.Marks>50 && this.Marks <=100)
System.out.println("Pass");
else
System.out.println("Fail");
}
public String getName()
{
return this.Name;
}
public String getStudId()
{
return this.StdID;
}
public String getProgram()
{
return this.Program;
}
public String getYear()
{
return this.Year;
}
public String getClasss()
{
return this.Class;
}
//define
public void setAttendance(String answer)
{
if (answer == "YES" || answer == "yes" || answer == "Yes")
{
this.attendance = "present";
}
else
this.attendance = "absent";
}
/*
public char Grade()
{
char grade;
int mark = (int)this.Marks;
switch(mark)
{
case 1: mark > 80: grade ='A';
}
}*/
public String getAttendance()
{
return this.attendance;
}
public void print()
{
System.out.println("name : "+ this.getName());
System.out.println("ID : "+ this.getStudId());
System.out.println("Program : "+ this.getProgram());
System.out.println("Class : "+this.getClasss());
System.out.println("Year: "+this.getYear());
}
public static void main(String[] args)
{
Tutorial3 NewStudent = new Tutorial3();
//(String name,String StudId,String program, String year,String Class, double MARKS)
Tutorial3 maas = new Tutorial3("mochakisa","901002555","S/E","2009","Bsem",90);
NewStudent.print();
maas.print();
}
}