Hey,
I'm having trouble with an assignment and I need some help.
basically, the assignment is the same as the from the following link:
http://www.thescripts. com/forum/thread607498.ht ml
However, there is one major exception: The pattern is reversed. Here is what it looks like:
If the user types "3", your program should produce the following output:
***
**
*
If the user types "9", your program should produce:
*********
********
*******
******
*****
****
***
**
*
I found out how to do the other pattern of my own but I am having trouble figuring out how to flip it.
Here is my code so far:
------------------------------------------------------------------
import java.io.*;
public class MagicPrinter
{
public static void main(String[] args)
throws java.io.IOExcep tion
{
String s1, s2, s3, total;
int num, minnum;
char a = 'a';
String star = "*";
total = "";
InputStreamRead er isr = new InputStreamRead er(System.in);
BufferedReader br = new BufferedReader( isr);
System.out.prin t("How many lines? ");
s1 = br.readLine();
num = Integer.parseIn t(s1);
minnum = 1;
do
{
total = total + star;
minnum++;
System.out.prin tln(total);
}
while(minnum <= num);
}
}
----------------------------------------------------------------
Any help would be apprecitated. Thanks.
I'm having trouble with an assignment and I need some help.
basically, the assignment is the same as the from the following link:
http://www.thescripts. com/forum/thread607498.ht ml
However, there is one major exception: The pattern is reversed. Here is what it looks like:
If the user types "3", your program should produce the following output:
***
**
*
If the user types "9", your program should produce:
*********
********
*******
******
*****
****
***
**
*
I found out how to do the other pattern of my own but I am having trouble figuring out how to flip it.
Here is my code so far:
------------------------------------------------------------------
import java.io.*;
public class MagicPrinter
{
public static void main(String[] args)
throws java.io.IOExcep tion
{
String s1, s2, s3, total;
int num, minnum;
char a = 'a';
String star = "*";
total = "";
InputStreamRead er isr = new InputStreamRead er(System.in);
BufferedReader br = new BufferedReader( isr);
System.out.prin t("How many lines? ");
s1 = br.readLine();
num = Integer.parseIn t(s1);
minnum = 1;
do
{
total = total + star;
minnum++;
System.out.prin tln(total);
}
while(minnum <= num);
}
}
----------------------------------------------------------------
Any help would be apprecitated. Thanks.
Comment