├── README.md ├── bin └── com │ └── w3epic │ └── wiprotraining │ ├── Assignment1.class │ ├── Assignment10.class │ ├── Assignment11.class │ ├── Assignment12.class │ ├── Assignment13.class │ ├── Assignment14.class │ ├── Assignment15.class │ ├── Assignment16.class │ ├── Assignment17.class │ ├── Assignment18.class │ ├── Assignment19.class │ ├── Assignment2.class │ ├── Assignment20.class │ ├── Assignment3.class │ ├── Assignment4.class │ ├── Assignment5.class │ ├── Assignment6.class │ ├── Assignment7.class │ ├── Assignment8.class │ └── Assignment9.class └── src └── com └── w3epic └── wiprotraining ├── Assignment1.java ├── Assignment10.java ├── Assignment11.java ├── Assignment12.java ├── Assignment13.java ├── Assignment14.java ├── Assignment15.java ├── Assignment16.java ├── Assignment17.java ├── Assignment18.java ├── Assignment19.java ├── Assignment2.java ├── Assignment20.java ├── Assignment3.java ├── Assignment4.java ├── Assignment5.java ├── Assignment6.java ├── Assignment7.java ├── Assignment8.java └── Assignment9.java /README.md: -------------------------------------------------------------------------------- 1 | Wipro TalentNext PBL 2 | 3 | Topics Covered 4 | 5 | Command Line Argument 6 | 7 | 8 | 9 | No. Hands-on Assignment Topics Covered Status 10 | 1 11 | 12 | Write a program to check if a given number is Positive, Negative, or Zero. 13 | 14 | If Statement 15 | 2 16 | 17 | Write a program to check if a given number is odd or even. 18 | 19 | If Statement 20 | 3 21 | 22 | Write a program to check if the program has received command line arguments or not. If the program has not received the values then print "No Values", else print all the values in a single line separated by ,(comma). 23 | Eg1) java Example 24 | O/P: No values 25 | Eg2) java Example Mumbai Bangalore 26 | O/P: Mumbai,Bangalore 27 | [Note: You can use length property of an array to check its length 28 | 29 | If Statement 30 | 4 31 | 32 | Initialize two character variables in a program and display the characters in alphabetical order. 33 | Eg1) if first character is s and second is e 34 | O/P: e,s 35 | Eg2) if first character is a and second is e 36 | O/P:a,e 37 | 38 | If Statement 39 | 5 40 | 41 | Intialize a character variable in a program and if the value is alphabet then print "Alphabet" if it’s a number then print "Digit" and for other characters print "Special Character" 42 | 43 | If Statement 44 | 6 45 | 46 | Write a program to accept gender ("Male" or "Female") and age (1-120) from command line arguments and print the percentage of interest based on the given conditions. 47 | Interest == 8.2% 48 | Gender ==> Female 49 | Age ==>1 to 58 50 | Interest == 7.6% 51 | Gender ==> Female 52 | Age ==>59 -120 53 | Interest == 9.2% 54 | Gender ==> Male 55 | Age ==>1-60 56 | Interest == 8.3% 57 | Gender ==> Male 58 | Age ==>61-120 59 | 60 | If Statement 61 | 7 62 | 63 | Write a program to convert from upper case to lower case and vice versa of an alphabet and print the old character and new character as shown in example (Ex: a->A, M->m). 64 | 65 | If Statement 66 | 8 67 | 68 | Write a program to print the color name, based on color code. If color code in not valid then print "Invalid Code". R->Red, B->Blue, G->Green, O->Orange, Y->Yellow, W->White. 69 | 70 | Switch Statement 71 | 9 72 | 73 | Write a program to print month in words, based on input month in numbers 74 | Example1: 75 | 76 | C:\>java Sample 12 77 | 78 | O/P Expected : December 79 | 80 | Example2: 81 | 82 | C:\>java Sample 83 | 84 | O/P Expected : Please enter the month in numbers 85 | 86 | Example3: 87 | 88 | C:\>java Sample 15 89 | 90 | O/P Expected : Invalid month 91 | 92 | Switch Statement 93 | 10 94 | 95 | Write a program to print numbers from 1 to 10 in a single row with one tab space. 96 | 97 | For Loop 98 | 11 99 | 100 | Write a program to print even numbers between 23 and 57, each number should be printed in a separate row. 101 | 102 | For Loop 103 | 12 104 | 105 | Write a program to check if a given number is prime or not 106 | 107 | For Loop 108 | 13 109 | 110 | Write a program to print prime numbers between 10 and 99. 111 | 112 | For Loop 113 | 14 114 | 115 | Write a Java program to find if the given number is prime or not. 116 | 117 | Example1: 118 | 119 | C:\>java Sample 120 | 121 | O/P Expected : Please enter an integer number 122 | 123 | Example2: 124 | 125 | C:\>java Sample 1 126 | 127 | O/P Expected : 1 is neither prime nor composite 128 | 129 | Example3: 130 | 131 | C:\>java Sample 0 132 | 133 | O/P Expected : 0 is neither prime nor composite 134 | 135 | Example4: 136 | 137 | C:\>java Sample 10 138 | 139 | O/P Expected : 10 is not a prime number 140 | 141 | Example5: 142 | 143 | C:\>java Sample 7 144 | 145 | O/P Expected : 7 is a prime number 146 | 147 | For Loop 148 | 15 149 | 150 | Write a program to add all the values in a given number and print. Ex: 1234->10 151 | 152 | For Loop 153 | 16 154 | 155 | Write a program to print * in Floyds format (using for and while loop) 156 | * 157 | * * 158 | * * * 159 | 160 | 161 | 162 | Example1: 163 | 164 | C:\>java Sample 165 | 166 | O/P Expected : Please enter an integer number 167 | 168 | Example1: 169 | 170 | C:\>java Sample 3 171 | 172 | O/P Expected : 173 | * 174 | * * 175 | * * * 176 | 177 | For Loop 178 | 17 179 | 180 | Write a program to reverse a given number and print 181 | Eg1) 182 | I/P: 1234 183 | O/P:4321 184 | Eg2) 185 | I/P:1004 186 | O/P:4001 187 | 188 | While Loop 189 | 18 190 | 191 | Write a Java program to find if the given number is palindrome or not 192 | 193 | Example1: 194 | 195 | C:\>java Sample 110011 196 | 197 | O/P Expected : 110011 is a palindrome 198 | 199 | Example2: 200 | 201 | C:\>java Sample 1234 202 | 203 | O/P Expected : 1234 is not a palindrome 204 | 205 | While Loop 206 | 19 207 | 208 | Write a program to print first 5 values which are divisible by 2, 3, and 5. 209 | 210 | While Loop 211 | 20 212 | 213 | Write a program that displays a menu with options 1. Add 2. Sub 214 | Based on the options chosen, read 2 numbers and perform the relevant operation. After performing the operation, the program should ask the user if he wants to continue. If the user presses y or Y, then the program should continue displaying the menu else the program should terminate. 215 | [ Note: Use Scanner class, you can take help from the trainer regarding the same ] 216 | 217 | Do While -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment1.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment10.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment10.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment11.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment11.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment12.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment12.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment13.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment13.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment14.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment14.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment15.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment15.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment16.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment16.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment17.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment17.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment18.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment18.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment19.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment19.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment2.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment20.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment20.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment3.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment4.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment4.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment5.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment5.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment6.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment6.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment7.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment7.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment8.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment8.class -------------------------------------------------------------------------------- /bin/com/w3epic/wiprotraining/Assignment9.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Cyberster/Wipro-Training-Java-Fundamentals---Assignments-for-Flow-Control-Statements/60485dfb7f9cb6df728d1581e1486f467108e201/bin/com/w3epic/wiprotraining/Assignment9.class -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment1.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Assignment1 { 6 | 7 | public static void main(String[] args) { 8 | Scanner sc = new Scanner(System.in); 9 | 10 | System.out.print("Enter a number: "); 11 | int x = sc.nextInt(); 12 | 13 | if (x < 0) System.out.println("Negative"); 14 | else if (x == 0) System.out.println("Zero"); 15 | else System.out.println("Positive"); 16 | 17 | main(args); 18 | sc.close(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment10.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | public class Assignment10 { 4 | 5 | public static void main(String[] args) { 6 | for (int i = 1; i <= 10; i++) { 7 | System.out.print(i + "\t"); 8 | } 9 | 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment11.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | public class Assignment11 { 4 | 5 | public static void main(String[] args) { 6 | for (int i = 23; i <= 57; i++) { 7 | if (i % 2 == 0) 8 | System.out.println(i); 9 | } 10 | 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment12.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | public class Assignment12 { 4 | 5 | public static void main(String[] args) { 6 | int no = -4; 7 | 8 | if (no < 0) no *= -1; 9 | 10 | Boolean isPrime = true; 11 | 12 | for (int i = 2; i < no/2+1; i++) { 13 | if (no % i == 0) { 14 | isPrime = false; 15 | break; 16 | } 17 | } 18 | 19 | if (no == 0 || no == 1) isPrime = false; 20 | 21 | if (isPrime) System.out.println("prime"); 22 | else System.out.println("not prime"); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment13.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | public class Assignment13 { 4 | 5 | public static void main(String[] args) { 6 | for (int i = 10; i <= 99; i++) { 7 | if (isPrime(i)) System.out.println(i); 8 | } 9 | 10 | } 11 | 12 | public static boolean isPrime(int no) { 13 | if (no < 0) no *= -1; 14 | 15 | Boolean isPrime = true; 16 | 17 | for (int i = 2; i < no/2+1; i++) { 18 | if (no % i == 0) { 19 | isPrime = false; 20 | break; 21 | } 22 | } 23 | 24 | if (no == 0 || no == 1) isPrime = false; 25 | 26 | return isPrime; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment14.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | public class Assignment14 { 4 | 5 | public static void main(String[] args) { 6 | if (args.length == 0) { 7 | System.out.println("Please enter an integer number"); 8 | System.exit(0); 9 | } 10 | 11 | int number = Integer.parseInt(args[0]); 12 | 13 | if (number == 0 || number == 1) { 14 | System.out.println(number + " is neither prime nor composite"); 15 | } else { 16 | if (isPrime(number)) 17 | System.out.println(number + " is a prime number"); 18 | else 19 | System.out.println(number + " is not a prime number"); 20 | } 21 | 22 | } 23 | 24 | public static boolean isPrime(int no) { 25 | if (no < 0) no *= -1; 26 | 27 | Boolean isPrime = true; 28 | 29 | for (int i = 2; i < no/2+1; i++) { 30 | if (no % i == 0) { 31 | isPrime = false; 32 | break; 33 | } 34 | } 35 | 36 | if (no == 0 || no == 1) isPrime = false; 37 | 38 | return isPrime; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment15.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | public class Assignment15 { 4 | 5 | public static void main(String[] args) { 6 | int number = 1234; 7 | int sum = 0; 8 | 9 | while (number != 0) { 10 | sum += number % 10; 11 | number /= 10; 12 | } 13 | 14 | System.out.println(sum); 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment16.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | public class Assignment16 { 4 | 5 | public static void main(String[] args) { 6 | if (args.length == 0) { 7 | System.out.println("Please enter an integer number"); 8 | System.exit(0); 9 | } 10 | 11 | int rowCount = Integer.parseInt(args[0]); 12 | 13 | for (int i = 0; i < rowCount; i++) { 14 | for (int j = 0; j <= i; j++) { 15 | System.out.print("*"); 16 | } 17 | System.out.println(); 18 | } 19 | 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment17.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Assignment17 { 6 | 7 | public static void main(String[] args) { 8 | Scanner sc = new Scanner(System.in); 9 | 10 | int ip = sc.nextInt(); // 1234 11 | int op = 0; // 4321 12 | int i = (int) Math.pow(10, String.valueOf(ip).length() - 1); 13 | 14 | while (ip != 0) { 15 | int digit = ip % 10; 16 | op += digit * i; 17 | i /= 10; 18 | ip /= 10; 19 | } 20 | 21 | System.out.println(op); 22 | 23 | sc.close(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment18.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | public class Assignment18 { 4 | 5 | public static void main(String[] args) { 6 | int number = Integer.parseInt(args[0]); 7 | 8 | if (getPalindromeNumber(number) == 2) 9 | System.out.println(number + " is a palindrome"); 10 | else 11 | System.out.println(number + "is not a palindrome"); 12 | } 13 | 14 | public static int getPalindromeNumber (int input1) { 15 | String numberStr = String.valueOf(input1); 16 | int digitCount = numberStr.length(); 17 | boolean isPalindrome = true; 18 | 19 | int range = digitCount / 2; 20 | if (digitCount % 2 == 0) range--; 21 | 22 | for (int i = 0; i <= range; i++) { 23 | if (numberStr.charAt(i) != numberStr.charAt(digitCount - i - 1)) isPalindrome = false; 24 | } 25 | 26 | if (isPalindrome == true) return 2; 27 | else return 1; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment19.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | public class Assignment19 { 4 | 5 | public static void main(String[] args) { 6 | 7 | int counter = 0; 8 | int i = 0; 9 | 10 | while (counter != 5) { 11 | i++; 12 | 13 | if (i % 2 == 0 && i % 3 == 0 && i % 5 == 0) { 14 | System.out.println(i); 15 | counter++; 16 | } 17 | } 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment2.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Assignment2 { 6 | 7 | public static void main(String[] args) { 8 | Scanner sc = new Scanner(System.in); 9 | 10 | System.out.print("Enter a number: "); 11 | int x = sc.nextInt(); 12 | 13 | if (x % 2 == 0) System.out.println("Even"); 14 | else System.out.println("Odd"); 15 | 16 | main(args); 17 | sc.close(); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment20.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | import java.util.Scanner; 4 | 5 | public class Assignment20 { 6 | 7 | public static void main(String[] args) { 8 | Scanner sc = new Scanner(System.in); 9 | 10 | System.out.println("1. Add\n2. Sub"); 11 | int choice = sc.nextInt(); 12 | 13 | int operand1; 14 | int operand2; 15 | int result; 16 | 17 | if (choice == 1) { 18 | System.out.println("Enter first operand: "); 19 | operand1 = sc.nextInt(); 20 | System.out.println("Enter second operand: "); 21 | operand2 = sc.nextInt(); 22 | result = operand1 + operand2; 23 | } else { 24 | System.out.println("Enter first operand: "); 25 | operand1 = sc.nextInt(); 26 | System.out.println("Enter second operand: "); 27 | operand2 = sc.nextInt(); 28 | result = operand1 - operand2; 29 | } 30 | 31 | System.out.println("Result: " + result); 32 | 33 | System.out.println("Do you want to continue? Y or N"); 34 | 35 | sc.nextLine(); 36 | choice = sc.nextLine().charAt(0); 37 | 38 | if (choice == 'Y' || choice == 'y') main(args); 39 | 40 | sc.close(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment3.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | public class Assignment3 { 4 | 5 | public static void main(String[] args) { 6 | if (args.length == 0) { 7 | System.out.println("No Values"); 8 | } else { 9 | for (int i = 0; i < args.length; i++) { 10 | System.out.print(args[i]); 11 | if (i < args.length - 1) System.out.print(", "); 12 | } 13 | } 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment4.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | public class Assignment4 { 4 | 5 | public static void main(String[] args) { 6 | char x = 'a'; 7 | char y = 'e'; 8 | 9 | if (x < y) { 10 | System.out.println(x + ", " + y); 11 | } else { 12 | System.out.println(y + ", " + x); 13 | } 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment5.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | public class Assignment5 { 4 | 5 | public static void main(String[] args) { 6 | char ch = '*'; 7 | 8 | //for (int i = 0; i < 128; i++) System.out.printf("%d: %c \n", i, i); 9 | 10 | if ((ch >= 65 && ch <= 90) || (ch >= 97 && ch <= 122)) { 11 | System.out.println("Alphabet"); 12 | } else if (ch >= 48 && ch <= 57) { 13 | System.out.println("Digit"); 14 | } else { 15 | System.out.println("Special Character"); 16 | } 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment6.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | public class Assignment6 { 4 | 5 | public static void main(String[] args) { 6 | String gender = args[0]; 7 | int age = Integer.parseInt(args[1]); 8 | 9 | if (!gender.equals("Male") && !gender.equals("Female")) 10 | System.out.println("Invalid gender"); 11 | 12 | if (age < 1 || age >= 120) 13 | System.out.println("Invalid age"); 14 | 15 | 16 | if (gender.equals("Female") && (age >= 1 && age <= 58)) { 17 | System.out.println("Interest == 8.2%"); 18 | } else if (gender.equals("Female") && (age >= 59 && age <= 120)) { 19 | System.out.println("Interest == 7.6%"); 20 | } else if (gender.equals("Male") && (age >= 1 && age <= 60)) { 21 | System.out.println("Interest == 9.2%"); 22 | } else if (gender.equals("Male") && (age >= 61 && age <= 120)) { 23 | System.out.println("Interest == 8.3%"); 24 | } 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment7.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | public class Assignment7 { 4 | 5 | public static void main(String[] args) { 6 | char ch = 'a'; 7 | 8 | if (Character.isLowerCase(ch)) 9 | System.out.println(ch + "->" + Character.toUpperCase(ch)); 10 | else 11 | System.out.println(ch + "->" + Character.toLowerCase(ch)); 12 | 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment8.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | public class Assignment8 { 4 | 5 | public static void main(String[] args) { 6 | char colorCode = 'Q'; 7 | 8 | switch (colorCode) { 9 | case 'R': 10 | System.out.println("R->Red"); 11 | break; 12 | case 'G': 13 | System.out.println("G->Green"); 14 | break; 15 | case 'B': 16 | System.out.println("B->Blue"); 17 | break; 18 | case 'O': 19 | System.out.println("O->Orange"); 20 | break; 21 | case 'Y': 22 | System.out.println("Y->Yellow"); 23 | break; 24 | case 'W': 25 | System.out.println("W->White"); 26 | break; 27 | default: 28 | System.out.println("Invalid Code"); 29 | } 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/com/w3epic/wiprotraining/Assignment9.java: -------------------------------------------------------------------------------- 1 | package com.w3epic.wiprotraining; 2 | 3 | import java.time.Month; 4 | 5 | public class Assignment9 { 6 | 7 | public static void main(String[] args) { 8 | if (args.length == 0) { 9 | System.out.println("Please enter the month in numbers"); 10 | System.exit(0); 11 | } 12 | 13 | int month = Integer.parseInt(args[0]); 14 | 15 | 16 | if (month < 1 || month > 12) { 17 | System.out.println("Invalid month"); 18 | System.exit(0); 19 | } 20 | 21 | // toUpperCaseFirst 22 | String monthStr = Month.of(month).name(); 23 | monthStr = monthStr.substring(0,1).toUpperCase() + monthStr.substring(1).toLowerCase(); 24 | 25 | System.out.println(monthStr); 26 | 27 | } 28 | 29 | 30 | } 31 | --------------------------------------------------------------------------------