When I was surfing the net, I just thought to search about Flow charts.
Then I found the wiki page about it.
http://en.wikipedia.org/wiki/Flowchart#Examples
In there I saw this simple flow chart. And I made a program for that in Java. But it doesn't work as expected.
If I enter "1" I get correct result.
But if I enter another amount, Then nothing happens it only prints "1' no matter what amount I enter I tried to correct but I couldn't. I even searched on Google to find out a similar program but they are different than my code.
Here is the code
Code: Select all
import java.util.Scanner;
class WikiFlowChartDemo{
public static void main(String args[]){
Scanner input = new Scanner(System.in);
System.out.println("Enter N");
int n= input.nextInt();
int m = 1;
int f = 1;
f=f*m;
if(m==n){
System.out.println(f);
}else{
m=m+1; // I could use m++ but just used this one.
}
System.out.println(f);
}
}
Thanks