Results 1 to 1 of 1
Thread: Do while loop
- 02-12-2012, 02:50 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 5
- Rep Power
- 0
Do while loop
How would I insert the following code, into a do while loop following the below critieria
salary *=1.03;
int contribution=(int) (salary*(limit/100));
int cumulcontribution += contribution;
}
if (age%5==0)
{
System.out.println(age +salary +limit +contribution +cumulcontribution);
}
else
{
System.out.println();
}
(A) Compute a cumulative total retirement contribution.
The limit to contributions is determined by the age, as follows:
-- if age is greater than 50, limit is 40%.
-- if age is greater than 40 but less than or equal to 50, limit is 30%.
-- limit is 25 % in all other cases.
( Assume the contributions begin at age 30 and amount equal to the limit is contributed.)
(B) Increment the salary by 3 % every year
(C) Using a product of salary and limit percent, compute the current year's contribution and add to the cumulative total
(D) Check if current age is a multiple of 5, using the modulus (%) operator. If so, print out the current values of: age, salary (truncate fraction or cents.. example: print 38504 if value is 38504.82), limit (%), contribution and cumulative contribution.
do
{
age++;
}while (age>=30 && age <=60);
if (age > 50)
{
limit = 40;
}
else if (age > 40 && age <= 50)
{
limit =30;
}
else
{
limit =25;
}
Similar Threads
-
Problem with while loop, assigning a variable with a different value every loop? Help
By JavaProg in forum New To JavaReplies: 2Last Post: 11-07-2011, 02:25 AM -
Is it Possible? Array elements Initialized in Loop, can it be viewed outside loop?
By JPH in forum New To JavaReplies: 1Last Post: 10-01-2011, 02:12 AM -
JTextField loop 2x for-loop WEIRD!
By Streetproject in forum AWT / SwingReplies: 2Last Post: 02-16-2011, 05:46 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks