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 7541967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:02:10+00:00 2026-05-30T08:02:10+00:00

Editing as the problem gets narrowed down: ans1 = homeMortgage + annualTuition + annualCharity

  • 0

Editing as the problem gets narrowed down:

ans1 = homeMortgage + annualTuition + annualCharity + healthCredit;
    if( grossAnnualIncome <= ans1 )
    {
    System.out.println( "YOU OWE $0.00 IN TAXES!" );
    }
    else if(grossAnnualIncome == 0)
    {
    System.out.println( "You earned no income so you owe no taxes!" );
    }
    else
    {
    //GROSS ANNUAL INCOME > 0 OUTPUT
    System.out.printf( "\nYOUR TAXES\n\n"
                    + "Gross Annual Income: %,.0f\n\n"
                    + "Deductions: \n"
                    + "\tHigher Education: %,.0f\n"
                    + "\tCharitable Contributions: %,.0f\n"
                    + "\tHome Mortgage Interest: %,.0f\n"
                    + "\tHealth Insurance Tax Credit: %,.0f\n\n"
                    + "Tax at 17%%: %,.0f\n"
                    + "Annual Income After Taxes: %,.0f\n"
                    + "Monthly Income After Taxes: %,.0f", grossAnnualIncome, annualTuition, annualCharity,
                       homeMortgage, healthCredit, taxAt17, annualAfterTaxes, monthlyAfterTaxes);
    }

grossAnnualIncome <= ans1 outputs correctly.

grossAnnualIncome == 0 outputs YOU OWE $0.00 IN TAXES! instead of You earned no income so you owe no taxes!

grossAnnualIncome > 0 outputs correctly.

  • 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-05-30T08:02:11+00:00Added an answer on May 30, 2026 at 8:02 am

    EDIT based on new question…

    It’s actually very simple what’s happening here. You’re observing that the statement in the first block is printed. This means that the first test condition was true – that is, grossAnnualIncome (zero) was less than ans1 (also zero in this case).

    I suspect the way to fix this would be to switch the order of the first two tests, so that the check for zero income takes priority.

    In general, if you have conditions that might overlap, make sure you order the tests in an if - else if - else ... block so that the most specific one appears first.


    (And by the way, if you’re just outputting a simple string it’s more usual to call System.out.print (or println) rather than printf. No point making Java format nothing after all, and I found it slightly disorienting.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out the best build system for latex. Currently, I use
I have currently the following problem: The footers width gets smaller as soon as
I'm stumped with a problem in ASP.NET MVC 3 - handling editing and updating
My UITextField's font gets lighter when it is being edited, and bolder whenever editing
I have a problem with my Java progam suddenly exiting, without any exception thrown
Editing this code here on Stackoverflow and I'm really near to get the result
Editing a RichTextBox control's text (more specifically, modifying selection font/color) programmatically seems to be
When editing data in a JTable (Nimbus L & F), as the user tabs
While editing .scm files it would be great if Vim would automatically put the
When editing Silverlight XAML in Visual Studio 2008, the Document Outline panel is not

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.