Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8808531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:38:51+00:00 2026-06-14T02:38:51+00:00

I am revising for a test upcoming this week using previous exam questions and

  • 0

I am revising for a test upcoming this week using previous exam questions and I just can’t get 100% coverage, my program is :

public int computeInsurance(boolean SportsEquipment, boolean MusicEquipment)
{
int insurance;
if(SportsEquipment == true && MusicEquipment==true)
insurance = 20;
else if((SportsEquipment == true && MusicEquipment == false)||(SportsEquipment == false        && MusicEquipment == true))
        insurance = 10;
    else
        insurance= 5;

    return insurance;
}

}

I am using the following test cases:

public class Lab5CarTest {

@Test
public void testComputeInsurance() {
    Lab5Car t = new Lab5Car();

    int result = t.computeInsurance(true, true);
    assertEquals(20,result);

    int i = t.computeInsurance(true,false);
    assertEquals(10,i);

    int u = t.computeInsurance(false,false);
    assertEquals(5,u);


}

}

But I am missing 3 branches out of 8 in the else if line of my code!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:38:53+00:00Added an answer on June 14, 2026 at 2:38 am

    Why don’t you test for:

    int ip = t.computeInsurance(false,true);
    assertEquals(10,ip);
    

    Like this you should cover all.

    you can simplify your code like this:

    if (SportsEquipment && MusicEquipment)
        insurance = 20;
    else if (SportsEquipment != MusicEquipment)
        insurance = 10;
    else
        insurance= 5;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am revising for a software testing exam. One of the questions gives this
Revising for php and cant seem to get this to print the values out
I'm revising for an upcoming Haskell exam and I don't understand one of the
I am revising for an exam tomorrow, and going over a previous years one.
Hey I'm just revising for my functional programming exam coming up on friday and
So I am revising for an exam and I got stuck in this problem:
In revising for an upcoming exam here is my solution to finding the min
I need some help revising this. It keeps only displaying 0s as the temp.
I encountered an issue while I was revising my session library today, and this
I'm just revising chapter 4 of C# in Depth which deals with nullable types,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.