Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am writing a program to only return part of the array if another part of the array is True. public static void main(String[] args

I am writing a program to only return part of the array if another part of the array is True.

public static void main(String[] args) {

// TODO code application logic here

Course[] courses = {

new Course("IT1006", 6, false),

new Course("IT4782", 3, false),

new Course("IT4789", 3, false),

new Course("IT4079", 6, false),

new Course("IT2230", 3, true),

new Course("IT3345", 3, true),

new Course("IT2249", 6, false)

};

WriteCurrentRegistration(courses);

}

Now I have to write the WriteCurrentRegistration(courses);

public static void WriteCurrentRegistration(Course[] courses) {

int total = 0;

System.out.print("{");

for(int i=0;i<courses.length; i++) {

if (courses[i].isRegisteredFor(true))

System.out.print("%s", courses[i].getCode());

if (i != courses.length-1) {

System.out.print(", ");

}

total += courses[i].getCreditHour();

}

System.out.println("}");

System.out.println("Total credit: " + total);

}

}

However, while I don't have any red marks on the IDE, the build keeps failing because it can't absolve the true part of my if (courses[i].isRegisteredFor(true) to a variable.

A little help?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions