Programming Problem in ATA Prerequisites Course Module 5 ControlFlow CA-2-A

Jump to solution
AlAllen1
Community Member

I am a student enrolled in the ATA Prerequisites Course. I am currently working on the Module 5 Methods Problem in Vocareum. I am stuck on Step 2. The instructions are as flows

  1. Define a method named printResult (below the comment for this step). It should not return a value or accept any parameters.
  2. Declare an instance variable named currentResult of the double data type, but do not initialize it. Note: Make sure to declare this variable without an explicit access modifier. Although it is usually best practice to declare instance variables as private, for this activity, declare it without using the private access modifier.
  3. In the body of the method call the System.out.println() method using the currentResult instance variable as the argument.

The issue that I am having is with the declaration of the currentResult  local variable. I get a compiler error saying that currentResult is not initialized. I'm not sure how to get around this. Here is the code that I wrote.

public void printResult(){
double currentResult;
System.out.println(currentResult);
}

0 Likes
1 Solution
SusanNiemeyer
Community Contributor

Hi @AlAllen1 

You have posted your question on a worldwide forum of Canvas users. For a question about a class assignment, you need to contact your instructor instead.

Good luck!

View solution in original post

0 Likes