'Convert Java program to Shell script
If I setup a maven project and write a Java program with main method, I want to convert this program to an equivalent shell script. In other words, the shell script should accept the arguments and should behave in the same way that the java program would behave when main method is called with arguments. How do I achieve this?
Solution 1:[1]
import java.util.Scanner; public class Print_Series3 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n,i,pr=0;
System.out.printf("Enter the range of number(Limit):");
n=sc.nextInt();
for(i=1;i<=n;i++)
{
if(i%2==0)
{
pr=(int) (2*Math.pow(i,2)+1);
System.out.print(pr+" ");
}
else
{
pr=(int) (2*Math.pow(i,2)-1);
System.out.printf(pr+" ");
}
}
sc.close();
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Royce |
