Professional Documents
Culture Documents
Code :
package javaapplication21;
public class JavaApplication21 {
a=1;
while(a<=line){
int c=line;
while(c>=1){
if(c!=a)
System.out.print(c);
else
MTS3033 A201
System.out.print("^");
c=c-1;
}
System.out.print("\n");
a=a+1;
}
}
}
Output:
Neatbeans :
Cmd :
MTS3033 A201
STEP 1: START
STEP 2: SET size = 4
STEP 3: SET r = size. REPEAT STEP 4 to 9 until r !=0
STEP 4: SET s=0. REPEAT STEP 5 UNTIL s<(size – r)
STEP 5: PRINT ** and SET s=s+1
STEP 6: SET t=0. REPEAT STEP 7 UNTIL t< (2*r – 1)
STEP 7: PRINT * and SET t=t+1
STEP 8: PRINT new line
STEP 9: SET r=r-1
STEP 10: END
Code :
package javaapplication22;
while(r!=0){
int s=0;
while(s<(size-r)){
System.out.print("**");
s=s+1;
}
int t=0;
while(t<(2*r-1)){
System.out.print("*");
t=t+1;
}
MTS3033 A201
System.out.print("\n");
r=r-1;
}
}
}
Output :
Neatbeans :
Cmd:
MTS3033 A201
STEP 1: START
STEP 2: DEFINE i, j
STEP 3: SET n=7
STEP 4: PRINT ‘Right Angle Triangle’
STEP 5: SET i=1. REPEAT STEP 6 to 8 UNTIL i
STEP 6: SET j=1. REPEAT STEP 7 UNTIL j<=i
STEP 7: PRINT * and SET j=j+1
STEP 8: PRINT new line and SET i=i+1
STEP 9: END
Code :
package javaapplication23;
Output :
Neatbeans :
Cmd:
MTS3033 A201
STEP 1: START
STEP 2: SET m=1
STEP 3: SET k=0. REPEAT STEP 4 TO STEP 8 UNTIL k<6
STEP 4: SET L=1. REPEAT STEP 5 and STEP 6 UNTIL L
STEP 5: PRINT m
STEP 6: SET m=m+1, L=L+1
STEP 7: PRINT new line
STEP 8: SET k= k+1
STEP 9: END
Code :
package javaapplication24;
Outpot :
Neatbeans:
Cmd :
MTS3033 A201
}
public static void main(String[] args){
class laptop{
laptop(){
System.out.println("Constructor of Laptop class");
}
void laptop_method(){
System.out.println("99% Battery available");
}
}
MTS3033 A201
Outpot :
When switch the main to bottom part of the code. I got error
massage. I think it because compiler always search main
method first.