I'm just learning the creating method part of java, and because of that I have no idea of what it's even saying or asking from me when it says "Build Failure". I seemed to have completed the code just fine and the calculate premium does work and counts 2/4 of the answers right, but it seems no matter what I do it just always says "Build Failure" for the other 2 questions.
// Insurance.java
// Chapter 3, Exercise 9
import java.util.Scanner;
class Insurance{
public static void main(String args[]){
int currY, birthY, ageD = 0;
Scanner scanny = new Scanner(System.in);
System.out.println("What year was you born?");
birthY = scanny.nextInt();
System.out.println("What is the current year?");
currY = scanny.nextInt();
calculatePremium(currY, birthY, ageD);
}
public static void calculatePremium(int currY, int birthY, int ageD){
ageD = (((birthY - currY)/10)+15)*20;
System.out.println(ageD);
}
}
I've tried changing the birthY and currY opposite, changing calculatePremium to an int, because I think it had int sign before it as kind of the setting up the answer, so it's easier on the student, and I put a void sign in place of the int, because I knew it would return the variable automatically.
Now this is the part I have no idea what it means since i'm still fairly new. The only part I can kind of understand is that 2016 - 1991 == 340, because the code wants to get the decades of your age, then + it by 15 then * by 20. I'm also having the problem of if i switch the System.out.prinln
of the string code above it will say I got a question wrong, when that shouldn't even matter which order it's in.
Unit TestIncomplete
calculatePremium works for a 26 year old
Build Status
Build Failed
Build Output
NtTest4231c145.java:9: error: method calculatePremium in class Insurance cannot be applied to given types;
assertTrue(tester47.calculatePremium(2016, 1991) == 340);
^
required: int,int,int
found: int,int
reason: actual and formal argument lists differ in length
1 error
Test Contents
Insurance tester47 = new Insurance();
@Test
public void unitTest() {
assertTrue(tester47.calculatePremium(2016, 1991) == 340);
}
The expected and actual results are the "Build Output" and the "Test Contents".