aspose file tools*
The moose likes Beginning Java and the fly likes Adding asterisks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Adding asterisks" Watch "Adding asterisks" New topic
Author

Adding asterisks

Sean Magee
Ranch Hand

Joined: Aug 23, 2004
Posts: 69
I have this assignment due fairly soon. I was wondering if anyone could help me on one particular task. I have to make some sort of calculation, when the calculation becomes TRUE i need to add an asterisk to an element in a array, (or however i want to do it).

For example, if calculation is 2, 8 times, i need result 2 to print out 8 asterisks. and for calculation 3. hits 4 times, i need a result 3 to print out 4 times.

for ex.

result 1 ****
result 2 *
result 3 ******
result 4 ****

Everytime i run the program the out put should be different.

Now, I dont want the answer, or exactly how to do this.

I just need help with how I would add an asterisk, or a char, everytime something is true or whatever.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
what about just keeping a count of the number of times each of your calculations returns true?
You could use an array of integers that for example.


42
Sean Magee
Ranch Hand

Joined: Aug 23, 2004
Posts: 69
Ok, here is my code so far. Everything works just how it should.

The output should look like this

***
*****
*******
*********
************
***************
************
*********
*******
****
***

Of course it should vary,but it should alway be represented as a bellcurve however atm the asterisks are represented as numbers, I do not understand how to make the conversion over.

And, if anyone sees anything that deserves constructive criticism, please feel free.

Any Help would be greatly appreciated. here is my code::::





[ February 07, 2005: Message edited by: Sean Magee ]
[ February 07, 2005: Message edited by: Sean Magee ]
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
you have an array of ints.
Each int is the number of asterisks you need to print on the corresponding line...
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1815
Looks like a job for nested loops!

in Pseudo-code:

for each element in the results array
for 1 to element.value
print an asterisk
next
print a new line
next


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding asterisks
 
Similar Threads
Problem with FOR loop..Need Help ASAP...
For Loop Problem
Bad sentinel loop structure for intro to java class
I need help with code, to create a pyramid with asterisk
problems comparing two people for a dating agency program