0 Members and 2 Guests are viewing this topic.
String pie = new String("I like pie! "); //pie is good btw :Pfor (int i=1;i>=10;i++) { //concatenate the string Pie with itself thus adding 'I like pie!' to the string pie 10 times.}System.out.print(pie);
String pie = new String("I like pie! "); //pie is good btw :Pfor (int i=1;i<10;i++) { // changed >= to < pie.concat(pie);}System.out.print(pie);
import javax.swing.JOptionPane;public class starz { public static void main (String []args) { String numtemp = JOptionPane.showInputDialog("Enter a number of lines:"); int lines = Integer.parseInt(numtemp); String star = new String("*"); for (int count=0;count<=lines;count++) { for (int spaces=lines-1;spaces>0;spaces--) { System.out.print("."); } for (int starcount=1;starcount<=lines;starcount++) { System.out.print(star); star = star.concat(star); //still needs to be fixed star = star.concat(star); //still needs to be fixed } System.out.println(); } }}
line | stars | spaces0 1 41 3 32 5 23 7 14 9 0
for(int line = 0; line < 5; line++){ for(int spaces = 0; spaces < 4 - line; spaces++) System.out.print(" "); for(int stars = 0; stars < line * 2 + 1; stars++) System.out.print("*"); System.out.println();}
String stars = "*";for(int line = 0; line < 5; line++){ for(int spaces = 0; spaces < 4 - line; spaces++) System.out.print(" "); System.out.print(stars); stars += "**"; System.out.println();}