Engineeringserver.com

A community for computer science students & developers about software development, game development, game design, games, anime preview & reviews and more!


Java stars

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...
188 views

An example to show "stars" in the command line interface. (Replace the "x" into "*" ) This is a common homework question but frequently asked for in the Java forums that i go to so here it is.

JAVA:
  1. public class CLIStars {
  2. public static void main(String[] args){
  3. int row = 9;
  4. String text = "x";
  5. String textReverse = "x";
  6.  
  7. for (int i=0; i <row; i++){
  8. System.out.println(text);
  9. text = text + "x";
  10. }
  11.  
  12. for (int y=1; y<=row; y++){
  13. for(int j=1; j<=row-y; j++)
  14. System.out.print(textReverse);
  15. System.out.println();
  16.  
  17. }
  18. }
  19. }

Output
x
xx
xxx
xxxx
xxxxx
xxxxxx
xxxxxxx
xxxxxxxx
xxxxxxxxx
xxxxxxxx
xxxxxxx
xxxxxx
xxxxx
xxxx
xxx
xx
x


Your Ad Here

Java Employee.class, Employee, Manager, Executive and HourlyWorker

1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 4.67 out of 5)
Loading ... Loading ...
477 views

I wrote this for someone a few months ago because he asked me to code it. I know that there are some students that need to do this as part of their assignment/homework so I though of sharing this for those that are struggling with it.

The code is compiled in PDF format below for easy reading.
http://www.engineeringserver.com/Software/2.0 - Employee Main.pdf
http://www.engineeringserver.com/Software/2.1 - Employee Employee.pdf
http://www.engineeringserver.com/Software/2.2 - Employee Manager.pdf
http://www.engineeringserver.com/Software/2.3 - Employee Executive.pdf
http://www.engineeringserver.com/Software/2.4 - Employee HourlyWorker.pdf


Your Ad Here