package loops; import java.util.Scanner; public class SeriesSum2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); float result = 0; for(float i = 1; i <=n ; i++) { if(i%2==0) { result -= 1/i; }else { result += 1/i; } System.out.println(result); } }
package conditionalStatements; public class IfClass { public static void main(String[] args) { int age = 19; if(age >= 18) { System.out.println("You Can Vote"); } } }
Comments
Post a Comment