b

b

Tuesday, February 16, 2016

Programming Project 6.7 a,b,c,d star.java

Programming Project 6.7 a, 6.7 b, 6.7 c, 6.7 d... star.java

===============================================================
//*************************************************************
// stars_a.java
// Programming Project 6.7 a
//*************************************************************
package stars_a;
public class stars_a {

public static void main(String[]args)
{
for (int row = 0; row < 11; ++row)
{
for (int space = 0; space < 11 - row - 1; ++space)
{
System.out.print("*");
}
for (int stars = 10; stars < row + 1; ++stars)
{
System.out.print(" ");
}
System.out.println();
}}}

=============================================================
//**************************************************************
// stars_b.java   
// Programming Project 6.7 b
//**************************************************************
package stars_b;
public class stars_b {

public static void main(String[]args)
{
for (int row = 0; row < 11; ++row) 
{  
for (int space = 0; space < 11 - row; ++space) 
{  
System.out.print(" ");  
}  
for (int stars = 0; stars < row; ++stars) {  
System.out.print("*");  
}  
System.out.println();  
}}}


=============================================================

//************************************************************
// stars_c.java   
// Programming Project 6.7 c
//************************************************************
package stars_c;
public class stars_c {

public static void main(String[]args){
for (int row = 0; row < 10; ++row )
{
for (int spaces = 10; spaces > 10 - row - 1; --spaces)
{
System.out.print(" ");
}
for (int stars = 10; stars > row; --stars)
{
System.out.print("*");
}
System.out.println();
}}}

============================================================

//*************************************************************
// stars_d.java   
// Programming Project 6.7 d
//*************************************************************
package stars_d;
public class stars_d {
public static void main(String[] args) {
    for (int i = 1; i < 11; i += 2) {
      for (int j = 0; j < 10 - i / 2; j++)
        System.out.print(" ");

      for (int j = 0; j < i; j++)
        System.out.print("*");

      System.out.print("\n");
    }

    for (int i = 9; i > 0; i -= 2) {
      for (int j = 0; j < 10 - i / 2; j++)
        System.out.print(" ");

      for (int j = 0; j < i; j++)
        System.out.print("*");

      System.out.print("\n");
    }}}

1 comment: