I am stuck with a 'grade assignment' problem for school. What I wanted to do was send the numeral grade to a subroutine and have it return a letter grade, but I can not get it to work. I am getting a loss of precision error when I try to compile.
The code here is a simplified version of what I want to do. I am trying to return a character from the subroutine, which will be saved into another character. I don't know why this doesn't work and if anyone can explain the logic to me or my error, it'll help me a bunch.
import javax.swing.*;
class learnFunction3
{
public static void main(String [] args)
{
char zoom;
zoom = integer_add (5, 12);
JOptionPane.showMessageDialog(null, "The addition of 5 and 12 results in letter " +zoom);
}
static int integer_add (int x, int y)
{
int result=0;
char vroom;
result = x + y;
if (result == 12)
{
vroom = 'K';
}
return vroom;
}
}
The code here is a simplified version of what I want to do. I am trying to return a character from the subroutine, which will be saved into another character. I don't know why this doesn't work and if anyone can explain the logic to me or my error, it'll help me a bunch.
import javax.swing.*;
class learnFunction3
{
public static void main(String [] args)
{
char zoom;
zoom = integer_add (5, 12);
JOptionPane.showMessageDialog(null, "The addition of 5 and 12 results in letter " +zoom);
}
static int integer_add (int x, int y)
{
int result=0;
char vroom;
result = x + y;
if (result == 12)
{
vroom = 'K';
}
return vroom;
}
}