package com.himanshu;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// // Write your code here
// System.out.println("hello world");
//
// /* Variables
// just like:
// Water - Bucket
// Masala - Box
// Lunch - LunchBox
// In Java:
// Variables are containers which stored data values
// string,int,float,char,boolean
// How to declare variables:
// syntax - <dataType> <variablename> = <values>;
// */
//
// String name = "Himanshu";
// String Channel = "Tiwari";
// System.out.print(name);
// System.out.print(name.length());
// System.out.print(name.toUpperCase());
// System.out.print(name.toLowerCase());
// System.out.println(name + " from " + Channel);
//// Some escape sequence characters in Java
// System.out.println(name + " from\" " + Channel);
// System.out.println(name + " from\\ " + Channel);
// System.out.println(name + " from\' " + Channel);
// System.out.println(name + " from\t " + Channel);
// System.out.println(name + " from\n " + Channel);
//
// System.out.println(name.contains("Himan")); /* when Your word is present then it returns True other wise False*/
// System.out.println(name.charAt(4)); /* when you type a number (4) then it returns you that which word is at no. 4*/
// System.out.println(name.endsWith("u")); /* When your word is ends with same word that you type then it returns true otherwise false*/
// System.out.println(name.startsWith("H")); /* When your word is start with same word that you type then it returns true otherwise false But be aware of Upper case and lowercase*/
// System.out.println(name.indexOf("man")); /* When your given word is present at any place then it gives their word number. if word not avialable then it gives you -1 it means not found */
// int num1 = 4, num2 = 7;
// System.out.println(Math.max(num1,num2)); /* Maximum */
// System.out.println(Math.min(num1,num2)); /* minimum */
// System.out.println(Math.sqrt(36)); /* SquareRoot */
// System.out.println(Math.cbrt(27)); /* CubeRoot */
// System.out.println(Math.abs(-36)); /* Negative Number gives Positive */
// System.out.println(Math.abs( 36)); /* Positive Number gives Negative */
// System.out.println(Math.random()); /* Any Random number between 0 and Less than 1 */
// System.out.println(4+(8-4)*Math.random()); /* it gives random no. what you want*/
// System.out.println(4+(8-4)*Math.random());
// System.out.println(4+(8-4)*Math.random());
// System.out.println(4+(8-4)*Math.random());
// int x = 45, y = 44, z = 67;
// float b = 1.2f;
// boolean isAdult = false;
//
// System.out.println(z);
// System.out.println(b);
// System.out.println(isAdult);
//
// /* Rules for constructing name variables in Java
// 1. Can contain digits, underscores, dollar signs, letters
// 2. Should begin with a letter,$ or _
// 3. Java is case sensitive language which means that
// Himanshu and himanshu are two different variables altogether.
// 4. Should not contain whitespaces
// 5. you cannot use reserve keyword from java */
//
// /*
// Two types of Java Data types:
// 1. Primitive -byte (1 byte), short (2 bytes), int (4 bytes),long (8 bytes), float(4 bytes)
// double (8 bytes), boolean (1 bit), char (2 bytes).
// 2. Non Primitive Data types or Reference Data type.
// */
//
// byte u = 56;
// System.out.println(u);
// double d = 45.7654d;
// System.out.println(d);
// char word = 'a'; /* only one word can used in char */
// System.out.println(word);
//
// /* Operators in Java
//
// Operand, Operator, Operand = Result
// 7 + 4 = 11
//
// Types of Operators in java
// Arithmetic Operators
// Assignment Operators
// Logical Operators
// Comparison Operators
// */
//// we use println to print in other line and only print ro print in same line
//
// int num1 = 56 , num2 = 45;
// num1+=5;
// num2-=7;
//
// System.out.println("The Value of num1 + num2 is ");
// System.out.println(num1 + num2);
//
// System.out.println("The Value of num1 - num2 is ");
// System.out.println(num1 - num2);
//
// System.out.println("The Value of num1 * num2 is ");
// System.out.println(num1 * num2);
//
// System.out.println("The Value of num1 / num2 is ");
// System.out.println(num1 / num2);
//
// System.out.println("The Value of num1 % num2 is ");
// System.out.println(num1 % num2);
//// Increment operator
// System.out.println(num1++);
// System.out.println(++num1);
// System.out.println(num2--);
// System.out.println(--num1);
//
// /*
// * Comparison operators
// * 1. == : Checks for equality of two values.
// * 2. != : Checks if two values are not equal.
// * 3. < : Checks for less than or not.
// * 4. > : Check for greater than or not.
// * 5. <= : Check for less than or equals to.
// * 6. >= : check for greater than or equals to.
// *
// * Logical operators
// * 1. && - Logical and operators - returns true only if both conditions are true
// * 2. || - Logical or operators - returns true only if any one conditions is true
// * 3. ! - Logical not - Reverse the result from true to false and vice versa
// */
//
// Taking user input in Java
//
// Scanner scan = new Scanner(System.in);
// System.out.println("Enter Your Age");
// int age = scan.nextInt();
// System.out.println();
// If-else Conditionals
// if (age>20){
// System.out.println("You are a adult");
// }
// else if (age>5) {
// System.out.println("you are not a kid");
// }
// else{
// System.out.println("yoa are a kid");
// }
// Switch statement in Java
// switch (age){
// case 12:
// System.out.println("you are 12 years old");
// break; /* if we don't use break then it execute all the cases*/
// case 34:
// System.out.println("you are 34 years old");
// break;
// case 54:
// System.out.println("you are 56 years old");
// break;
// default:
// System.out.println("you didn't match any of the conditions");
//
// }
// Quick Quiz: Print sunday to saturday based on numbers 1 to 7 typed by the user
// Solution
// Scanner scan = new Scanner(System.in);
// System.out.println("Enter Numbers and i'll show the day");
// int days = scan.nextInt();
//
// switch (days){
// case 1 :
// System.out.println("Today is Monday");
// break;
//
// case 2 :
// System.out.println("today is Tuesday");
// break;
//
// case 3 :
// System.out.println("Today is wednesday");
// break;
//
// case 4 :
// System.out.println("Today is Thursday");
// break;
//
// case 5 :
// System.out.println("Today is Friday");
// break;
//
// case 6 :
// System.out.println("Today is Saturday");
// break;
//
// case 7 :
// System.out.println("Today is sunday");
// break;
// }
// Loops
/*
while Loop
While(condition){
// this code will keep execute until the condition is true
}
*/
// int i = 0;
// while (i<101){
// System.out.println(i);
// i +=1;
// }
/*
Do while Loop
do{
// this code will keep execute until the condition is true
} While(condition)
*/
// int j = 0;
// do{
// System.out.println(j);
// j += 1;
// }while (j<101);
/*
For Loop
for(st1;st2;st3){ st means statement
//code to be executed
*/
// for (int i=0;i<=10;i++){
// System.out.println(i);
// }
// break = break the loop
// continue = leave given number
// Java Arrays
// int [] marks = {1,3,5,8,0};
// marks[3] = 45; // This is update marks 3
// System.out.println(marks[4]);
// System.out.println(marks[3]);
//
//// Classical way iterate an array
// for (int i=0;i<marks.length;i++){
// System.out.println(marks[i]);
// }
// System.out.println("This is For each loop");
//// For each loop
// for(int value:marks){
// System.out.println(value);
// }
//
//// Multidimensanal Array
// int [][] matrix = {{1,2,3},{4,5,6}};
// System.out.println(matrix[0][1]);
//
//// String Arrays
// String [] cars = {"Maruti","suzuki","honda","tata"};
// for (String value:cars) {
// System.out.println(value);
// }
// Try - catch - if you want to catch error then you can can use this thing in Java
// String [] cars = {"Maruti","suzuki","honda","tata"};
// try {
// System.out.println(cars[6]);
// }
// catch(Exception r){
// System.out.println(r);
// }
// System.out.println("Ram ne rawan ko mara");
float number_1, number_2;
System.out.println("Enter first number");
Scanner scan = new Scanner(System.in);
number_1 = scan.nextFloat();
System.out.println("Enter second number");
// Scanner scan2 = new Scanner(System.in);
number_2 = scan.nextFloat();
System.out.print("You have Entered ");
System.out.print(number_1);
System.out.print(" and ");
System.out.println(number_2);
String prompt = "Enter 0 for addition, 1 for " +
"subtraction, 2 for multiplication and 3 for division";
System.out.println(prompt);
int input = scan.nextInt();
switch (input){
case 0:
System.out.println("Adding these numbers");
System.out.print("The result is: ");
System.out.println(number_1 + number_2);
break;
case 1:
System.out.println("Subtracting these numbers");
System.out.print("The result is: ");
System.out.println(number_1 - number_2);
break;
case 2:
System.out.println("Multiplying these numbers");
System.out.print("The result is: ");
System.out.println(number_1 * number_2);
break;
case 3:
System.out.println("Dividing these numbers");
System.out.print("The result is: ");
System.out.println(number_1 / number_2);
break;
default:
System.out.println("Invalid input");
}
}
}