help with these 4 more problems please.
Code:
1. Given an int variable k that has already been declared, use a for loop to print a single line consisting of 97 asterisks. Use no variables other than k .
ans: but don't work.
for(k=0;k<97;k++)
System.out.print(“*”);
2. Given an int variable n that has already been declared and initialized to a positive value, and another int variable j that has already been declared, use a for loop to print a single line consisting of n asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j .
ans: but don't work.
for(j=0;j<5;j++)
System.out.print(“*”);
3. Given an int variable k that has already been declared, use a while loop to print a single line consisting of 88 asterisks. Use no variables other than k .
ans: but don't work
k=0;
while(k<88)
{
System.out.print(“*”);
k++;
}
4. Given an int variable n that has already been declared and initialized to a positive value, use a while loop to print a single line consisting of n asterisks. Use no variables other than n .
ans: but don't work
while(n>0)
{
System.out.print(“*”);
n--;
}