Unable to build program BUILD OUTPUT IntTreeTest.java:14: error: method evenBranches in class IntTree cannot be applied

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Unable to build program BUILD OUTPUT IntTreeTest.java:14: error: method evenBranches in class IntTree cannot be applied

Post by answerhappygod »

Unable To Build Program Build Output Inttreetest Java 14 Error Method Evenbranches In Class Inttree Cannot Be Applied 1
Unable To Build Program Build Output Inttreetest Java 14 Error Method Evenbranches In Class Inttree Cannot Be Applied 1 (39.98 KiB) Viewed 30 times
Unable To Build Program Build Output Inttreetest Java 14 Error Method Evenbranches In Class Inttree Cannot Be Applied 2
Unable To Build Program Build Output Inttreetest Java 14 Error Method Evenbranches In Class Inttree Cannot Be Applied 2 (40.87 KiB) Viewed 30 times
Please help me fix my code!!!! Thanks
Unable to build program BUILD OUTPUT IntTreeTest.java:14: error: method evenBranches in class IntTree cannot be applied to given types; assertEquals(new GoodIntTree(s).evenBranches(), new IntTree(s).evenBranches()); required: IntTreeNode found: no arguments reason: actual and formal argument lists differ in length IntTreeTest.java:30: error: method evenBranches in class IntTree cannot be applied to given types; assertEquals(new GoodIntTree(s).evenBranches(), new IntTree(s).evenBranches(); A required: IntTreeNode found: no arguments reason: actual and formal argument lists differ in length 2 errors

public class IntTree { private IntTreeNode overallroot; public int countEvenBranches() { return evenBranches (overallRoot); } public int evenbranches (IntTreeNode root) { if (root == null) { return; } else if (root.data % 2 == 1 || root.left == null && root.right == null) { return evenBranches (root. left) + evenBranches (root.right); } else { return 1 + evenBranches (root. left) + evenBranches (root.right); } public static void main(String[] args) { System.out.println(new IntTree("[2 [8 [0] null] [1 [7 [4] null] [6 null [9]]]]").countEvenBranches());
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply