CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2011
    Posts
    5

    Help with conditional statements

    Heya, i'm a pure swedish beginner at programming. I have certain difficulties to get a program working involving conditional operators/statements.
    The task is following:
    In order for a declaration relief from double residence requires that the distance to work is more than 50 km and that the work lasts more than a year for singles and 3 years for cohabitant. Construct a program that allows the user to input the data and that informs whether the user has the right to tax or not.

    This might seem like a really easy program to construct but everyone has been beginners at some time. I would really appreciate if anyone could help me out here.

    I've made some minor pseducode on paper, although it hardly helps me with the the encoding

    best regards
    Emil

  2. #2
    Join Date
    Oct 2010
    Posts
    60

    Re: Help with conditional statements

    Do you know how to make a Scanner to take input? If you do, the rest is just 'if' statements. Maybe something like:
    Code:
    if(workDistance > 50) { //or >=50, depending if 50km counts.
        if(isSingle && workTime > 1) {
            canTax = true;
        } else if(!isSingle && workTime > 3) {
            canTax = true;
        } //if neither requirement is met, it will leave this loop and go to 'return false'
    }
    canTax = false;
    All that's left is using the Scanner to take input, and declaring 'workDistance', 'isSingle'...
    Last edited by henryswanson; February 11th, 2011 at 05:52 PM. Reason: hit submit prematurely. :\

  3. #3
    Join Date
    Feb 2011
    Posts
    5

    Re: Help with conditional statements

    I know exactly what you mean Henry. Thanks alot for the help!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured