Results 1 to 1 of 1
Thread: Do while loop
 02122012, 02:50 PM #1Member
 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: 11072011, 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: 10012011, 02:12 AM 
JTextField loop 2x forloop WEIRD!
By Streetproject in forum AWT / SwingReplies: 2Last Post: 02162011, 05:46 PM
Bookmarks