├── Main.java ├── README.md ├── conditions_statement.java ├── conditions_statement_practise_Q.java ├── leacture6_javaProgrammingEeercise.java ├── leacture_12.java ├── leacture_7.java ├── string_lession.java ├── string_practise.java └── variables_datatypes.java /Main.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | // Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`, 4 | // then press Enter. You can now see whitespace characters in your code. 5 | public class Main { 6 | public static void main(String[] args) { 7 | // Press Alt+Enter with your caret at the highlighted text to see how 8 | // IntelliJ IDEA suggests fixing it. 9 | System.out.printf("Hello and welcome!"); 10 | 11 | // Press Shift+F10 or click the green arrow button in the gutter to run the code. 12 | for (int i = 1; i <= 5; i++) { 13 | 14 | // Press Shift+F9 to start debugging your code. We have set one breakpoint 15 | // for you, but you can always add more by pressing Ctrl+F8. 16 | System.out.println("i = " + i); 17 | } 18 | // variables 19 | // variables are container that store data values 20 | // string int float boolean char 21 | // how to declare variavles 22 | String name = "aman"; 23 | // short cut to write sout 24 | System.out.println(name); 25 | int a = 45; 26 | float b = 45.22f ; 27 | boolean isAdult = false ; 28 | 29 | System.out.println(b); 30 | System.out.println(isAdult); 31 | // taking user input in java 32 | Scanner scan = new Scanner(System.in); 33 | System.out.println("enter the input"); 34 | String input = scan.nextLine(); 35 | System.out.println(input); 36 | 37 | // now taking integer input 38 | System.out.println("enter a number"); 39 | int input1 = scan.nextInt(); 40 | System.out.println(input1); 41 | 42 | // string methods 43 | // escape sequence character 44 | 45 | 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # java-files 2 | notes 3 | -------------------------------------------------------------------------------- /conditions_statement.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class conditions_statement { 4 | public static void main(String[] args) { 5 | 6 | // int age = 6 ; 7 | // if (age>18){ 8 | // System.out.println("yes boy is can drive"); 9 | // } 10 | // else { 11 | // System.out.println("no boy not yet"); 12 | // } 13 | int age ; 14 | System.out.println("please enter the age "); 15 | Scanner sc = new Scanner(System.in); 16 | age = sc.nextInt(); 17 | if (age>56){ 18 | System.out.println("you are experience"); 19 | } 20 | else if(age > 46){ 21 | System.out.println("you are semi experice"); 22 | } 23 | else if (age>36) { 24 | System.out.println("you are semi semi eperinced"); 25 | } 26 | else{ 27 | System.out.println("you are not experience"); 28 | } 29 | 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /conditions_statement_practise_Q.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | public class conditions_statement_practise_Q { 3 | public static void main(String[] args) { 4 | // byte m1 , m2 , m3 ; 5 | // Scanner sc = new Scanner(System.in); 6 | // System.out.println("enter the makes for physics"); 7 | // m1 = sc.nextByte(); 8 | // System.out.println("enter the makes for chemistry"); 9 | // m2 = sc.nextByte(); 10 | // System.out.println("enter the makes for maths"); 11 | // m3 = sc.nextByte(); 12 | // float avg = (m1+m2+m3)/3.0f; 13 | // System.out.println("overall percentage is: "+avg); 14 | // if (avg>=40 && m1>=33 && m2>=33 && m3>=33){ 15 | // System.out.println("cong, you have been promoted"); 16 | // } 17 | // else { 18 | // System.out.println("soory, you have not "); 19 | // } 20 | 21 | // question 2 -- tax paid my the employye 22 | 23 | Scanner sc = new Scanner(System.in); 24 | System.out.println("enter the income in lakhs"); 25 | float tax = 0; 26 | float income = sc.nextFloat(); 27 | if (income<=2.5){ 28 | tax = tax+0; 29 | } 30 | else if (income>2.5f && income<=5.0f){ 31 | tax = tax + 0.05f *(income - 2.5f); 32 | 33 | 34 | } else if (income >5f && income<=10.0f) { 35 | tax = tax + 0.05f * (5.0f - 2.5f); 36 | tax = tax + 0.2f * (income - 5f); 37 | } else if (income>10.0f) { 38 | tax = tax + 0.05f * (5.0f - 2.5f); 39 | tax = tax + 0.2f * (10.0f - 5.0f); 40 | tax = tax + 0.3f * (income - 10.0f); 41 | 42 | } 43 | System.out.println("the tottal tax = "+ tax); 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /leacture6_javaProgrammingEeercise.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | public class leacture6_javaProgrammingEeercise { 3 | public static void main(String[] args){ 4 | System.out.println("enter the 5 subject marks"); 5 | Scanner sc = new Scanner(System.in); 6 | System.out.println("enter the first subject"); 7 | int sub1 = sc.nextInt(); 8 | System.out.println("enter the second subject"); 9 | int sub2 = sc.nextInt(); 10 | System.out.println("enter the third subject"); 11 | int sub3 = sc.nextInt(); 12 | System.out.println("enter the fourth subject"); 13 | int sub4 = sc.nextInt(); 14 | System.out.println("enter the fifth subject"); 15 | int sub5 = sc.nextInt(); 16 | 17 | int total = sub1 +sub2 + sub3 + sub4 + sub5 ; 18 | double percentage = (total/500.0f) * 100 ; 19 | System.out.println(percentage); 20 | 21 | 22 | 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /leacture_12.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class leacture_12 { 4 | public static void main(String[] args) { 5 | /* System.out.println("result of float a"); 6 | float a = 7/4.0f * 9/2.0f ; 7 | System.out.println(a); */ 8 | // Question 2 :----- wap to encript a grade by adding 8 to it . Decrypt it to show the correct grade . 9 | //encryption 10 | /* char grade = 'B' ; 11 | grade = (char)(grade +8) ; 12 | System.out.println(grade); 13 | //decryption 14 | grade = (char)(grade -8) ; 15 | System.out.println(grade); */ 16 | 17 | // Question 3:---- use comparisson operator to find out wheather a given number is greater than the user entered number or not . 18 | Scanner sc = new Scanner(System.in); 19 | int a = sc.nextInt(); 20 | System.out.println(a>8); 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /leacture_7.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class leacture_7 { 4 | public static void main(String[] args) { 5 | // System.out.print("what is your name:"); 6 | // Scanner sc = new Scanner(System.in); 7 | // String name = sc.nextLine(); 8 | // System.out.println("hello " + name + " have a good DAY"); 9 | 10 | // Question:- WAP to detect wheather a number is integer or not eentered by the user 11 | System.out.print("integer or not "); 12 | Scanner sc = new Scanner(System.in); 13 | 14 | System.out.println(sc.hasNextInt()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /string_lession.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | public class string_lession { 3 | public static void main(String[] args) { 4 | // String name = new String("aman"); 5 | String name = "Aman"; 6 | System.out.println(name); 7 | 8 | int value = name.length(); 9 | System.out.println(value); 10 | 11 | String smallletter = name.toLowerCase(); 12 | System.out.println(smallletter); 13 | 14 | String biggerletter = name.toUpperCase(); 15 | System.out.println(biggerletter); 16 | 17 | System.out.println(name.substring(1,4)); 18 | System.out.println(name.replace('a' , 'c')); 19 | System.out.println(name.replace("m","aaaaa")); 20 | System.out.println(name.startsWith("A")); 21 | System.out.println(name.endsWith("m")); 22 | 23 | 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /string_practise.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | public class string_practise { 3 | public static void main(String[] args) { 4 | String name = "Aman Gupta" ; 5 | name = name.toLowerCase(); 6 | System.out.println(name); 7 | // problem 2 8 | String text = " to lower case "; 9 | text = text.replace(" " , "_"); 10 | System.out.println(text); 11 | 12 | //problem 3 13 | String letter = "dear <|name|> , thanks a lot" ; 14 | letter = letter.replace("<|name|>" , "aman"); 15 | System.out.println(letter); 16 | 17 | // problem -- WAP to detect a double and triple strings 18 | 19 | String myString = "this string contains double and triple spaces"; 20 | System.out.println(myString.indexOf(" ")); 21 | System.out.println(myString.indexOf(" ")); 22 | 23 | //problem -- WA TO FORMAT THE LETTER USING SEQUENCE CHARACTER 24 | 25 | String letters = "Desr Aman,\n\tThis is a message from your future self . " + 26 | "\n\t I request you to study hard as possible as you can ." + 27 | " \n\tOther you will face a lot of problems ." + 28 | "\n Thanks" ; 29 | System.out.println(letters); 30 | 31 | 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /variables_datatypes.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | public class variables_datatypes { 3 | public static void main(String[] args){ 4 | // write a java program to add to number 5 | System.out.println("enter the two nnumbers to add"); 6 | Scanner sc = new Scanner(System.in); 7 | System.out.println("enter the ffirst number"); 8 | int num1 = sc.nextInt(); 9 | System.out.println("eenter the second number"); 10 | int num2 = sc.nextInt(); 11 | // int num1 = 6 ; 12 | // int num2 = 10; 13 | System.out.println(num1 + num2); 14 | } 15 | 16 | } 17 | --------------------------------------------------------------------------------