Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Adding asterisks

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sean Magee
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you have an array of ints.
Each int is the number of asterisks you need to print on the corresponding line...
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Acetylsalicylic acid is aspirin. This could be handy too:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic