├── Maximize_Colours.java ├── Numbering_in_words.java ├── README.md ├── Stack.java ├── bubble_sort.java └── vowels_Question.java /Maximize_Colours.java: -------------------------------------------------------------------------------- 1 | //For the human eye, primary colours are red, green, and blue. 2 | //Combining 1 drop of each of any two primary colours produces a new type of secondary 3 | //colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, 4 | //and mixing red and blue gives magenta. 5 | //You have X, Y, and Z drops of red, green, and blue colours respectively. Find the maximum 6 | //total number of distinct colours (both primary and secondary) you can have at any particular moment. 7 | //Note: You cannot mix a secondary colour with a primary or another secondary color to get a new type of colour. 8 | //Input Format 9 | // The first line of input will contain a single integer T, denoting the number of test cases. 10 | // Each test case consists of three space-separated integers X, Y, and Z, the number of drops of red, green, and blue colors respectively. 11 | //Output Format 12 | // For each test case, output on a new line the maximum total number of colors (both primary and secondary) you can have using the given primary colors. 13 | 14 | package Project; 15 | import java.util.Scanner; 16 | public class Demo { 17 | public static int colors(int red, int green, int blue) { 18 | int primary = 0; 19 | int secondary = 0; 20 | if(red > 0) { 21 | primary++; 22 | red--; 23 | } 24 | if(green > 0) { 25 | primary++; 26 | green--; 27 | } 28 | if(blue > 0) { 29 | primary++; 30 | blue--; 31 | } 32 | if(red > 0 && green > 0) { 33 | secondary++; 34 | red--; 35 | green--; 36 | } 37 | if(red > 0 && blue > 0) { 38 | secondary++; 39 | red--; 40 | blue--; 41 | } 42 | if(blue > 0 && green > 0) { 43 | secondary++; 44 | blue--; 45 | green--; 46 | } 47 | return primary + secondary; 48 | } 49 | public static void main(String[] args) { 50 | Scanner sc = new Scanner(System.in); 51 | int size = sc.nextInt(); 52 | int res[] = new int[size]; 53 | for(int i = 0;i < size;i++) { 54 | int red = sc.nextInt(); 55 | int green = sc.nextInt(); 56 | int blue = sc.nextInt(); 57 | res[i] = colors(red, green, blue); 58 | } 59 | for(int ans : res) 60 | System.out.println(ans); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Numbering_in_words.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Main { 3 | public static void main(String[] args) { 4 | Scanner s = new Scanner(System.in); 5 | int a = s.nextInt(); 6 | String[] h = {"", "One hundred", "Two hundred", "Three hundred", "Four hundred", "Five hundred", "Six hundred", "Seven hundred", "Eight hundred", "Nine hundred"}; 7 | String[] t1 = {"Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"}; 8 | String[] t2 = {"Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"}; 9 | String[] o = {"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"}; 10 | if (a == 0) { 11 | System.out.println(o[0]); 12 | return; 13 | } 14 | if (a / 100 > 0) { 15 | System.out.print(h[a / 100] + " "); 16 | } 17 | a %= 100; 18 | if (a >= 10 && a < 20) { 19 | System.out.print(t1[a - 10]); 20 | else if (a >= 20) { 21 | System.out.print(t2[a / 10 - 2] + " "); 22 | a %= 10; 23 | } 24 | if (a > 0) { 25 | System.out.print(o[a]); 26 | } 27 | System.out.println(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JAVA_Coding 2 | Java practice codes 3 | 4 | I started learning the java programming and then later deceided to recorde the codes that I learn on a daily basis. 5 | So let's get started to make the 365 days streak in the github. 6 | -------------------------------------------------------------------------------- /Stack.java: -------------------------------------------------------------------------------- 1 | package Project; 2 | public class Stack_operation { 3 | int[] stack; 4 | int size; 5 | int top; 6 | Stack_operation(int size){ 7 | this.size=size; 8 | stack = new int[size]; 9 | top=-1; 10 | } 11 | public void push(int val) { 12 | if(top==size-1) 13 | System.out.println("Stack overflow"); 14 | else 15 | stack[++top]=val; 16 | } 17 | public int pop() { 18 | if(top==-1) { 19 | System.out.println("Stack underflow"); 20 | return -1; 21 | } 22 | else 23 | return stack[top--]; 24 | } 25 | public void peek() { 26 | if(top==-1) 27 | System.out.println("Stack underflow"); 28 | else 29 | System.out.println(stack[top]); 30 | } 31 | public void update(int pos,int val) { 32 | if(top==-1) 33 | System.out.println("Stack underflow"); 34 | if(pos>size || pos<0 || pos>top) 35 | System.out.println("Unable to insert"); 36 | if(posmax ) 13 | max=a[i]; 14 | } 15 | max++; 16 | int a1[]=new int[max]; 17 | for(int i=0;i 0) { 35 | int N = scanner.nextInt(); 36 | String S = scanner.next(); 37 | String vowels = "aeiou"; 38 | int consonantStreak = 0; 39 | boolean isEasy = true; 40 | for (int i = 0; i < S.length(); i++) { 41 | char currentChar = S.charAt(i); 42 | if (vowels.indexOf(currentChar) != -1) { 43 | consonantStreak = 0; 44 | } else { 45 | consonantStreak++; 46 | } 47 | if (consonantStreak >= 4) { 48 | isEasy = false; 49 | break; 50 | } 51 | } 52 | if (isEasy) { 53 | System.out.println("YES"); 54 | } else { 55 | System.out.println("NO"); 56 | } 57 | } 58 | } 59 | } 60 | --------------------------------------------------------------------------------