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
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'...
Re: Help with conditional statements
I know exactly what you mean Henry. Thanks alot for the help!