Search code examples
javaprintfbluej

Why doesn't charon accept my code?


I have just started a computer science degree at university, and I am stuck on a task. I am obviously very new to programming so please don't judge, i'm trying to learn the basics, and this exercise is very basic yet i cannot quite solve it. I have done many iterations to this code, and when i compile and run it on BlueJ it outputs what is expected, however when i submit it to charon, it responds telling me that the code is wrong.

here is my code;

class Main extends BIO
{
public static void main( String args[] )
{
    System.out.print( "#Enter Student mark: ");
    int cw = BIO.getInt();
    System.out.print( "#Enter Student mark: ");
    int examMark = BIO.getInt();
    System.out.print( ("ex = 71 cw = 40 mark = ") );
    System.out.println( (double) (cw+examMark) / 2); 
}

}

I have attached a screenshot of the exercise below as well for context.

enter image description here

any help is appreciated thank you.


Solution

  • You need to put in the variables into the print statement, and not a hardcoded value.

    System.out.print("ex = " + examMark + " cw = " + cw + " mark = ");
    System.out.println((double) (cw + examMark) / 2);