package conditionalStatements; public class TernaryOperator { public static void main(String[] args) { int a = 15; int b = 80; int max = 0; // // if(a>b) { // max = a; // } else { // max = b; // } max = a>b ? a : b; System.out.println("Max of both numbers is " + max); } }
package arrays; import java.util.Scanner; public class ArrayIntro { public static void main(String[] args) { /* int[] marks; marks = new int[5]; */ //int marks[] = new int [5]; //ALL ARE SAME int[] age = {2,4,8,16,32}; double[] percentage = {1.0,3.14,4.6,78}; Scanner sc = new Scanner(System.in); while(6>age.length) { int n = sc.nextInt(); System.out.println(age[n-1]); }}}
Comments
Post a Comment