Sir plzz help me mere sath ek problem ho rha hai jb mai inspect mai jaa kar media use kr rha hu CSS mai toh sb shi hai jaise hi browser minimize krta hu or same width pr lata hu toh image kat jata hai height mai plzz insta pe v msg kya hu plzz sir I m totally confused kaise shi karu khi vi tutorial nhi mil rha app hi help kr skte hai
Upload all series for everyone . Bhai ma pakistani hon but ek na ek din ma ap sy milny zaroor aayon ga. Mera nam yad rakhna ma atleast 10 sal bad milon ga. Love you bro jo kr rahy ho karty raho. OR ye comment ma ap ki har video ma kron ga kisi ma tu reply aay ga na..
Sir pls upload video on C++, Android Development and Java in simultaneously. So that there will be Balance between students learning Java, C++,etc. Pls make more videos on Machine Learning and Artificial intelligence 🙏
Exercise 6 : Custom Calculator CODE - - - import java.util.Scanner; class Calculator2 extends Exception { public Calculator2(String message) { super(message); } @Override public String toString() { return "Invalid input Exception"; } // @Override // public String getMessage() { // return "Invalid input Exception"; // } } public class CalculatorException { public static int add(int a, int b) throws Calculator2 { if (a > 10000 || b > 10000) { throw new Calculator2("Max input Exception: input should not be greater than 10000"); } return a + b; } public static int multiply(int a, int b) throws Calculator2 { if (a > 7000 || b > 7000) { throw new Calculator2("Max input Exception: input should not be greater than 7000"); } return a * b; } public static float divide(int a, int b) throws Calculator2 { if (a > 7000 || b > 7000) { throw new Calculator2("Max input Exception: input should not be greater than 7000"); } if (b == 0) { throw new ArithmeticException("Cannot divide by zero Exception"); } return (float) a / b; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Choose between the following options:"); System.out.println("1. Addition"); System.out.println("2. Multiplication"); System.out.println("3. Division"); int ch = sc.nextInt(); switch (ch) { case 1: System.out.println("Enter number 1 and number 2:"); int a1 = sc.nextInt(); int b1 = sc.nextInt(); try { int res = add(a1, b1); System.out.println("The result is " + res); } catch (Calculator2 e) { System.out.println(e.getMessage()); } break; case 2: System.out.println("Enter number 1 and number 2:"); int a2 = sc.nextInt(); int b2 = sc.nextInt(); try { int res = multiply(a2, b2); System.out.println("The result is " + res); } catch (Calculator2 e) { System.out.println(e.getMessage()); } break; case 3: System.out.println("Enter number 1 and number 2:"); int a3 = sc.nextInt(); int b3 = sc.nextInt(); try { float res = divide(a3, b3); System.out.println("The result is " + res); } catch (Calculator2 | ArithmeticException e) { System.out.println(e.getMessage()); } break; default: System.out.println("Invalid option"); break; } sc.close(); // It closes the Scanner object(it's a good practice). } }
package fundamentals; import java.util.Scanner; class InvalidInputException extends Exception{
public String toString() { return "InvalidInputException, enter a valid operator"; } } class MaxInputException extends Exception{
public String toString() { return "MaxInputException, enter a valid exception"; } } class MaxMultiException extends Exception{
public String toString() { return "MaxMultiException, enter a valid exception"; } } class DivideByZeroException extends Exception{
public String toString() { return "DivideByZeroException, enter a valid exception"; } } public class CustomCalculator { public static void main(String[] args) throws MaxMultiException, InvalidInputException, DivideByZeroException, MaxInputException {
Scanner sc = new Scanner(System.in); System.out.println("Enter value a:"); int a= sc.nextInt(); System.out.println("Enter value b:"); int b= sc.nextInt(); System.out.print("Enter value of operator:(+, -, *, /):"); char operator = sc.next().charAt(0);
float a, b, res; char choice, ch; Scanner S = new Scanner(System.in);
do { // prepare menu for the user to see multiple operations. System.out.println("Main Menu: "); System.out.println(" 1 Addition"); System.out.println(" 2 Subtraction"); System.out.println(" 3 Division"); System.out.println(" 4 Multiplication"); System.out.println(" 5 Exit");
// enter the choice System.out.print("Enter your choice: ");
choice = S.next().charAt(0);
switch (choice) { case '1': System.out.print("Enter two numbers: "); a = S.nextFloat(); b = S.nextFloat(); res = a + b; System.out.println("Result: " + res); break;
case '2': System.out.print("Enter two numbers: "); a = S.nextFloat(); b = S.nextFloat(); res = a - b; System.out.println("Result: " + res); break;
case '3': System.out.println("Enter two numbers: "); a = S.nextFloat(); b = S.nextFloat(); res = a / b; System.out.println("Result: " + res); break;
case '4': System.out.print("Enter two numbers: "); a = S.nextFloat(); b = S.nextFloat(); res = a * b; System.out.println("Result : " + res); break;
case '5': System.exit(0); break; default: System.out.println("Invalid Choice"); break; } } while (choice != 5); } }
Accepted //Made by Satvik Mittal //Purely made in VS Code import java.util.InputMismatchException; import java.util.Scanner; class InvalidInputException extends InputMismatchException{ @Override public String toString() { return "Not a valid operation"; } @Override public String getMessage() { return "Pls enter a valid operation"; } } class ZeroException extends ArithmeticException{ @Override public String toString() { return "Cannot divide by 0"; } @Override public String getMessage() { return "Enter a number other than 0"; } } class MaxInputException extends InputMismatchException{ @Override public String toString() { return "Number can't exceed 100000"; } @Override public String getMessage() { return "Pls enter a number 7000"; } @Override public String getMessage() { return "Pls enter a number
can you help me ..??????????? in my console CORS policy in chrome browser error occur ..can you help me how to overcome it ..or may suggest a tutorial video for CORS policy ...
/*Hello Harry sir, I am watching this course from starting, I saw this video today and accept the challenge and here is my answer*/ package com.masaaledaarCalculator; import java.util.Scanner; class InvalidInput extends Exception{ @Override public String toString(){ return "Operator is invalid"; } } class MaxInputException extends Exception{ @Override public String toString(){ return "Input can't be greater than 1 lakh"; } } class MaxMultiplierException extends Exception{ @Override public String toString() { return "Input can't be greater than 7 thousand in multiplication"; } } public class code extends Exception{ public static void operatorCheck(String opr) throws InvalidInput { if (opr.equals("+") || opr.equals("-") || opr.equals("*") || opr.equals("/")) return; throw new InvalidInput(); } public static double add(int x,int y) throws MaxInputException { if (x>100000||y>100000) throw new MaxInputException(); System.out.println("The value of "+x+" + "+y+" is : "); return x+y; } public static double subtract(int x,int y) throws MaxInputException { if (x>100000||y>100000) throw new MaxInputException(); System.out.println("The value of "+x+" - "+y+" is : "); return x-y; } public static double multiply(int x,int y) throws MaxMultiplierException { if (x>7000||y>7000) throw new MaxMultiplierException(); System.out.println("The value of "+x+" * "+y+" is : "); return x*y; } public static double divide(int x,int y) throws MaxInputException,ArithmeticException { if (x>100000||y>100000) throw new MaxInputException(); System.out.println("The value of "+x+" / "+y+" is : "); return x/y; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter the operator(only +,-,*,/ are allowed): "); String opr = sc.next(); try { operatorCheck(opr); } catch (Exception e){ System.out.println(e); return; } System.out.println("Enter the first number : "); int x = sc.nextInt(); System.out.println("Enter the second number : "); int y = sc.nextInt(); if (opr.equals("+")){ try{ System.out.println(add(x,y)); } catch (Exception e){ System.out.println(e); } } else if (opr.equals("-")){ try{ System.out.println(subtract(x,y)); } catch (Exception e){ System.out.println(e); } } else if (opr.equals("*")){ try{ System.out.println(multiply(x,y)); } catch (Exception e){ System.out.println(e); } } else { try{ System.out.println(divide(x,y)); } catch (Exception e){ System.out.println(e); } } } } /* Thank you Harry sir for providing such an amazing course at 0 cost; Hoping that you will reply soon and give me a shoutout*/
Challenge Excepted And Alhamdulillah done Allah ka fazal se package com.companey; import java.util.Scanner; import java.util.concurrent.ExecutionException; class InvalidInput extends Exception{ @Override public String toString(){ return "Invalid input exception / Exeption"; } @Override public String getMessage(){ return "Why you are entering 8 , 9 "; } } class MaxInput extends Exception{ @Override public String toString(){ return "Max Input greater then, 100000"; } @Override public String getMessage(){ return "why you are using greater than 1lac value"; } } class MaxMultiplierReached extends Exception{ @Override public String toString(){ return " Max Multiplier Reached"; } @Override public String getMessage(){ return "why you are using above value of 7000"; } } class CantDivByZero extends Exception{ @Override public String toString(){ return "Divided by / Zero Exception"; } @Override public String getMessage(){ return "Why your are entering Zero for division!"; } } class DivLaterValue extends Exception{ @Override public String toString(){ return "dive by value is big"; } @Override public String getMessage(){ return "why your are entering div by value in here"; } } class CostumeCalculator{ public void add(int a, int b) /*throws MaxInput, InvalidInput*/ { try { if (a
Note: Here MaxMultiplierReachedException occurs if the result of multiplication reached above 700000. Which is different from the one asked in the question, only done so to make it look somewhat realistic. import java.util.Scanner; class MaxInputException extends Exception{ @Override public String toString(){ return "Max Input Exception occured: Inputs must be less or equal to 100000"; }
@Override public String getMessage(){ return "Max Input Exception occured: Inputs must be less or equal to 100000"; } } class InvalidInputException extends Exception{ @Override public String toString(){ return "Invalid Input Exception occured: Operand Specified must be one of them: +, -, *, /"; }
@Override public String getMessage(){ return "Invalid Input Exception occured: Operand Specified must be one of them: +, -, *, /"; } } class DivideByZeroException extends Exception{ @Override public String toString(){ return "Divide By Zero Exception occured: Denominator of the division can not be Zero(0)"; }
@Override public String getMessage(){ return "Divide By Zero Exception occured: Denominator of the division can not be Zero(0)"; } } class MaxMultiplierReachedException extends Exception{ @Override public String toString(){ return "Max Multiplier Reached Exception occured: The result of multiplication reached above 700000"; }
@Override public String getMessage(){ return "Max Multiplier Reached Exception occured: The result of multiplication reached above 700000"; } } class CalculatorUsingCustomExceptions{
public static int div(int x,int y) throws DivideByZeroException{ if(y==0){ throw new DivideByZeroException(); } return x/y; }
public static int mul(int x,int y) throws MaxMultiplierReachedException{ int result=x*y; if(result>700000){ throw new MaxMultiplierReachedException(); } return result; }
public static void main(String args[]){ Scanner sc=new Scanner(System.in); String operand; int a; int b; while(true){ System.out.println("Enter first number:"); a=sc.nextInt();
System.out.println("Enter second number:"); b=sc.nextInt(); if(a>100000||b>100000){ try{ throw new MaxInputException(); }catch(Exception e){ System.out.println(e); continue; } }
System.out.println("Press + for Addition Press - for Subtraction Press / for Division Press * for Multiplication press q to quit"); operand=sc.next();
switch(operand){ case "+":{ System.out.println("Sum="+(a+b)); break; } case "-":{ System.out.println("substraction="+(a-b)); break; } case "*":{ try{ System.out.println("multplication="+mul(a,b)); }catch(Exception e){ System.out.println(e); } break; } case "/":{ try{ System.out.println("Division="+div(a,b)); }catch(Exception e){ System.out.println(e); } break; } case "q":case "Q":{ System.exit(0); } default:{ try{ throw new InvalidInputException(); }catch(Exception e){ System.out.println(e); } break; }
harry bhai ek request hai ek video banaiye jquery mobile par mene youtube par bahut sari video dekhi par jquery mobile ki video hindi me sahi tarike se nahi mili.
//Custum calculator as per your instructions class InvalidInputException extends Exception{ @Override public String toString() { return "Cannot divide 8 and 9"; } @Override public String getMessage() { return "I am get message"; } } class CannotDivideZeroException extends Exception{ @Override public String toString() { return "Cannot divide by zero"; } @Override public String getMessage() { return "I am get message"; } } class MaxInputException extends Exception{ @Override public String toString() { return "Your input is greater than 1000 not allowed"; } @Override public String getMessage() { return super.getMessage(); } } class MaxMultiplyReached extends Exception{ @Override public String getMessage() { return "Not allowed of any multiplication greater than 7000"; } } class custumCalculator{ double add(double a,double b) throws InvalidInputException,MaxInputException{ if(a>1000||b>1000){ throw new MaxInputException(); } if(a==8 || b==9){ throw new InvalidInputException(); } return a+b; } double subtract(double a,double b) throws MaxInputException { if(a>1000||b>1000){ throw new MaxInputException(); } return a-b; } double multiply(double a,double b)throws MaxInputException,MaxMultiplyReached{ if(a>7000||b>7000){ throw new MaxMultiplyReached(); } if(a>1000||b>1000){ throw new MaxInputException(); } return a*b; } double divide(double a,double b) throws CannotDivideZeroException,MaxInputException{ if(a>1000||b>1000){ throw new MaxInputException(); } if(b==0){ throw new CannotDivideZeroException(); } return a/b; } } public class Custum_calculator { public static void main(String[] args) throws InvalidInputException,CannotDivideZeroException,MaxInputException,MaxMultiplyReached { custumCalculator cc=new custumCalculator(); // cc.add(8,9); // cc.divide(8,1200); //cc.divide(32,0); cc.multiply(600,7001); } }
package Projects.Projects; import java.util.*; class MaxMultiplierException extends Exception { public String toString() { return super.toString() + " Input Greater than 7000"; } public String getMessage() { return super.getMessage() + " Input Greater than 7000"; } } public class Custom_Calculator { public static void main(String[] args) { Scanner sc = new Scanner(System.in); /* * You have to create a custom calculator with the following operations : * 1. × Multiplication * 2. ÷ Division * 3. + Addition * 4. - Subtraction * which throws the following exceptions : * 1. Invalid Input Exception * 2. Cannot divide by 0 exception * 3. MaxInputException if any input is greater than 1000 * 4. MaxMultiplier Exception - Don''t allow any multiplication input to be greater than 7000 * */ System.out.println("\t\t\t\tCUSTOM CALCULATOR "); System.out.println("The operations This calculator can perform are : "); System.out.println("1. (A)ddition (+)"); System.out.println("2. (S)ubtraction (-)"); System.out.println("3. (M)ultiplication(×)"); System.out.println("4. (D)ivision (÷)"); System.out.println("5. (E)xit "); char c = ' '; while(c != 'e' && c != 'E') { System.out.println("Enter the First Alphabet of the operation you want to perform : "); c = sc.next().charAt(0); System.out.println(); switch(c){ case 'A' : case 'a' : System.out.println("Enter the total number of figures for which you want the sum : "); int a; try { a = sc.nextInt(); } catch(InputMismatchException ime) { System.out.println("There was an Error."); a = sc.nextInt(); } double[] arr = new double[a]; for(int x = 0; x < a ;x++) { System.out.println("Enter a number : "); try { arr[x] = sc.nextDouble(); } catch(InputMismatchException Ime) { System.out.println("There was an error."); System.out.println("Enter a number : "); try { arr[x] = sc.nextDouble(); } catch(InputMismatchException IME) { System.out.println("There was an error."); System.out.println("Enter a number : "); arr[x] = sc.nextDouble(); } } } double sum = 0; for(int x = 0; x < a; x++) { sum += arr[x]; } System.out.print("Sum of " ); for(int x = 0;x
Harry Bhai DSA k play list me video dalo I have already finished tree insertion and deletion.....but few topics are still remaining to upload! Bye the way thanks for all your struggles in making playlist DSA playlist 🔥
//here is the answer: //before main method- import java.util.Scanner; class divide_by_zero extends Exception{ @Override public String getMessage() { return "Suggestion:Please select any other number"; } @Override public String toString() { return "Error:The divisor given is zero"; } } class invalid_input_error extends Exception{ @Override public String getMessage() { return "Suggestion:Please choose funtion among-> - + * /"; } @Override public String toString() { return "Error:Invalid function entered"; } } class value_limit_reached extends Exception{ @Override public String toString() { return "Error:Value can not be larger than 100000"; } @Override public String getMessage() { return "Suggestion:Please enter value less 100000"; } } class multilayer_limit_reached extends Exception{ @Override public String toString() { return "Error:Multiplication value can not be larger than 7000";} @Override public String getMessage() { return "Suggestion:Please select value less than 7000"; } } // after main method.. System.out.println("The Calculator:Exercise 6"); System.out.println("Type: + for add - for subtract * for multiply / for divide"); Scanner input=new Scanner(System.in); //funtion System.out.println("Enter the function"); String function=input.next(); //numerical value System.out.println("enter number 1"); int num1=input.nextInt(); System.out.println("enter number 2"); int num2=input.nextInt(); switch (function){ case "/" -> { if (num2 == 0) {try{ throw new divide_by_zero();} catch (Exception a){ System.out.println(a.toString()); System.out.println(a.getMessage()); } } else {System.out.println("the result is " + (num1 / num2));} } case "+"-> { if (num1>=100000 | num2>=100000){ try{ throw new value_limit_reached(); } catch (Exception a){ System.out.println(a.toString()); System.out.println(a.getMessage()); } } else {System.out.println("the result is " + (num1 + num2));} } case "-"->{ if (num1>=100001 | num2>=100001){try{ throw new value_limit_reached();} catch (Exception a){ System.out.println(a.toString()); System.out.println(a.getMessage()); } } else {System.out.println("the result is " + (num1 - num2));} } case "*"->{if (num1>=7001 | num2>=7001){ try{ throw new multilayer_limit_reached(); } catch (Exception a){ System.out.println(a.toString()); System.out.println(a.getMessage()); } } else {System.out.println("the result is " + (num1 * num2));}} default -> {try { throw new invalid_input_error(); } catch (Exception a){ System.out.println(a.toString()); System.out.println(a.getMessage()); } } } //thnx for this course and second answer!!!!!!
1:18 - Ye bhi ho jaata hai kabhi kabhi 😅🤦♂️
Mere saath not responding hota hai 😂😂😂
Edit: :O I am first replier even after refresh
😂😂
Sir plzz help me mere sath ek problem ho rha hai jb mai inspect mai jaa kar media use kr rha hu CSS mai toh sb shi hai jaise hi browser minimize krta hu or same width pr lata hu toh image kat jata hai height mai plzz insta pe v msg kya hu plzz sir I m totally confused kaise shi karu khi vi tutorial nhi mil rha app hi help kr skte hai
Funny to see😅😅
Plzzz repky
6:31 I have seen every video of this java playlist and waiting for the next chapter
I have watch whole playlist till this video a big thankyou to teach us Salute to u . U are great harry bhai
I am watching this playlist from the very beginning sir :)
Challenges are always accepted, cause I got a good teacher ❤
THANK YOU! For making such a excellent course for free
I have watching whole playlist .😍😍
Challenge accepted 👍
Mene abhi tak ki saari videos dekhi hai java ki 🥳
Mene starting se yaha tak sare videos dekhe Harry Bhaiya.
Hello Harry bhaiya, please make a video on "creating a Blogger template"
you are my saviour in lockdowns
Watching from video no 1... Java me Bhot maja arha..he..
Maine ap ke sare vidio dhekhe hai bahut Maja sekhneko bhi Milla hame thank you
Challenege Accepted & I have watched the videos from starting...
Challenge Accepted.
Thanks Harry Bhaiya
Upload all series for everyone .
Bhai ma pakistani hon but ek na ek din ma ap sy milny zaroor aayon ga.
Mera nam yad rakhna ma atleast 10 sal bad milon ga.
Love you bro jo kr rahy ho karty raho.
OR ye comment ma ap ki har video ma kron ga kisi ma tu reply aay ga na..
Sir pls upload video on C++, Android Development and Java in simultaneously.
So that there will be Balance between students learning Java, C++,etc.
Pls make more videos on Machine Learning and Artificial intelligence 🙏
Learnt all videos from brginning.
Sir congrats for 1 million
Sir you are great helping so much in learning computer languages
maine dekh rha suru se
and challenge accepted
First like and view from my side .... yaaaay
Exercise 6 : Custom Calculator
CODE - - -
import java.util.Scanner;
class Calculator2 extends Exception {
public Calculator2(String message) {
super(message);
}
@Override
public String toString() {
return "Invalid input Exception";
}
// @Override
// public String getMessage() {
// return "Invalid input Exception";
// }
}
public class CalculatorException {
public static int add(int a, int b) throws Calculator2 {
if (a > 10000 || b > 10000) {
throw new Calculator2("Max input Exception: input should not be greater than 10000");
}
return a + b;
}
public static int multiply(int a, int b) throws Calculator2 {
if (a > 7000 || b > 7000) {
throw new Calculator2("Max input Exception: input should not be greater than 7000");
}
return a * b;
}
public static float divide(int a, int b) throws Calculator2 {
if (a > 7000 || b > 7000) {
throw new Calculator2("Max input Exception: input should not be greater than 7000");
}
if (b == 0) {
throw new ArithmeticException("Cannot divide by zero Exception");
}
return (float) a / b;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Choose between the following options:");
System.out.println("1. Addition");
System.out.println("2. Multiplication");
System.out.println("3. Division");
int ch = sc.nextInt();
switch (ch) {
case 1:
System.out.println("Enter number 1 and number 2:");
int a1 = sc.nextInt();
int b1 = sc.nextInt();
try {
int res = add(a1, b1);
System.out.println("The result is " + res);
} catch (Calculator2 e) {
System.out.println(e.getMessage());
}
break;
case 2:
System.out.println("Enter number 1 and number 2:");
int a2 = sc.nextInt();
int b2 = sc.nextInt();
try {
int res = multiply(a2, b2);
System.out.println("The result is " + res);
} catch (Calculator2 e) {
System.out.println(e.getMessage());
}
break;
case 3:
System.out.println("Enter number 1 and number 2:");
int a3 = sc.nextInt();
int b3 = sc.nextInt();
try {
float res = divide(a3, b3);
System.out.println("The result is " + res);
} catch (Calculator2 | ArithmeticException e) {
System.out.println(e.getMessage());
}
break;
default:
System.out.println("Invalid option");
break;
}
sc.close(); // It closes the Scanner object(it's a good practice).
}
}
Waiting for a ❤ from code with harry from months
6:31 I have seen each & every video of this java playlist
shuru se abhi takk saare videos maine dekhe haain
Lots of Love💖
Harry bhaii🔥🔥
Very helpful bhai...
Challenge accepted
I have watched the whole course from beginning and really liking ig
It*
One of the best channel 👍
Harry Bhai Please Make a Tutorial On Open Cv in Python
Hello sir,
I'm watching your video from starting till now and I will complete this playlist. (03 Feb 2022)
package fundamentals;
import java.util.Scanner;
class InvalidInputException extends Exception{
public String toString() {
return "InvalidInputException, enter a valid operator";
}
}
class MaxInputException extends Exception{
public String toString() {
return "MaxInputException, enter a valid exception";
}
}
class MaxMultiException extends Exception{
public String toString() {
return "MaxMultiException, enter a valid exception";
}
}
class DivideByZeroException extends Exception{
public String toString() {
return "DivideByZeroException, enter a valid exception";
}
}
public class CustomCalculator {
public static void main(String[] args) throws MaxMultiException, InvalidInputException, DivideByZeroException, MaxInputException {
Scanner sc = new Scanner(System.in);
System.out.println("Enter value a:");
int a= sc.nextInt();
System.out.println("Enter value b:");
int b= sc.nextInt();
System.out.print("Enter value of operator:(+, -, *, /):");
char operator = sc.next().charAt(0);
if(operator != '+' && operator != '-' && operator != '*' && operator != '/' ) {
throw new InvalidInputException();
}
else if(b==0 && operator== '/') {
throw new DivideByZeroException();
}
else if(a>100000 || b> 100000) {
throw new MaxInputException();
}
else if((a * b)>7000 ) {
throw new MaxMultiException();
}
else {
switch(operator) {
case '+': System.out.println(a + b); break;
case '-': System.out.println(a - b); break;
case '*': System.out.println(a * b); break;
case '/': System.out.println(a / b); break;
default: System.out.println("Default Case");
}
System.out.println("Execution Completed!");
}
}
}
i have seen each and every video of this playlist thankyouu sir
Thanx bro you really help me to reach my goals 😊☺️
import java.util.Scanner;
public class calculator {
public static void main(String[] args) {
float a, b, res;
char choice, ch;
Scanner S = new Scanner(System.in);
do {
// prepare menu for the user to see multiple operations.
System.out.println("Main Menu: ");
System.out.println(" 1 Addition");
System.out.println(" 2 Subtraction");
System.out.println(" 3 Division");
System.out.println(" 4 Multiplication");
System.out.println(" 5 Exit");
// enter the choice
System.out.print("Enter your choice: ");
choice = S.next().charAt(0);
switch (choice) {
case '1':
System.out.print("Enter two numbers: ");
a = S.nextFloat();
b = S.nextFloat();
res = a + b;
System.out.println("Result: " + res);
break;
case '2':
System.out.print("Enter two numbers: ");
a = S.nextFloat();
b = S.nextFloat();
res = a - b;
System.out.println("Result: " + res);
break;
case '3':
System.out.println("Enter two numbers: ");
a = S.nextFloat();
b = S.nextFloat();
res = a / b;
System.out.println("Result: " + res);
break;
case '4':
System.out.print("Enter two numbers: ");
a = S.nextFloat();
b = S.nextFloat();
res = a * b;
System.out.println("Result : " + res);
break;
case '5':
System.exit(0);
break;
default:
System.out.println("Invalid Choice");
break;
}
} while (choice != 5);
}
}
@@SadmanSakib2001 just for simple calculation
challenge accepted and completed!!!
I am with your Series 1st to last
Bhaiya please make a video on how to become a ethical hacker Or cyber security expert.
✔ done thanxx sir 🥰
Thank you sir ji
Solution of this question using simple oops concepts.
class InputException extends Exception{
@Override
public String toString()
{
return "Invalid input";
}
}
class MultipleException extends Exception
{
@Override
public String toString()
{
return "Invalid input for multiplication";
}
}
class DivisionException extends Exception
{
@Override
public String toString() {
return "Can not divide by zero";
}
}
class Calculator{
public void addition(double a, double b)
{
double c = 0;
try {
c = a + b;
if (a == 8 || b==8 || a==9 || b==9 || a>100000 || b>100000) {
throw new InputException();
}
else
System.out.println("Result after addition is: " +c);
} catch (InputException e) {
System.out.println(e.toString());
}
}
public void subtraction(double a, double b)
{
double c = 0;
try {
c = a - b;
if (a == 8 || b==8 || a==9 || b==9 || a>100000 || b>100000) {
throw new InputException();
}
else
System.out.println("Result after subtraction is:" +c);
} catch (InputException e) {
System.out.println(e.toString());
}
}
public void Multiplication(double a, double b)
{
double c = 0;
try {
c = a*b;
if (a == 8 || b==8 || a==9 || b==9) {
throw new InputException();
} else if (a>7000 || b>7000 )
{
throw new MultipleException();
} else
System.out.println("Result after multiplication is:" +c);
} catch (InputException e) {
System.out.println(e.toString());
}
catch (MultipleException e){
System.out.println(e.toString());
}
}
public void Division(double a, double b)
{
double c = 0;
try {
c = a/b;
if (a == 8 || b==8 || a==9 || b==9 || a>100000 || b>100000) {
throw new InputException();
} else if (a==0 || b==0)
{
throw new DivisionException();
} else
System.out.println("Result after division is:" +c);
} catch (InputException e) {
System.out.println(e.toString());
}
catch (DivisionException e){
System.out.println(e.toString());
}
}
}
public class Excercise_6 {
public static void main(String[] args)
{
Calculator obj=new Calculator();
obj.addition(1,100000);
obj.subtraction(7,100000);
obj.Multiplication(5,15);
obj.Division(16,3);
}
}
How much syllabus are left in this course? 4months go.
Plz. Make a videos for java advance syllabus. In details
DBMS crash course please as fast as possible
Sir please suggest me a nice budget laptop for web/app developing
Bhai plz upload java EE videos also 🙏🙏🙏🙏🙏🙏🙏
sir sql language me video banao na pls
maza ara hai harry sir
Harry bhai digital marketing par video bano
I'm in BA English
Can learning to code will help me?
And can I learn web development without maths bc I'm very bad at maths.
yes, off course
Accepted
//Made by Satvik Mittal
//Purely made in VS Code
import java.util.InputMismatchException;
import java.util.Scanner;
class InvalidInputException extends InputMismatchException{
@Override
public String toString() {
return "Not a valid operation";
}
@Override
public String getMessage() {
return "Pls enter a valid operation";
}
}
class ZeroException extends ArithmeticException{
@Override
public String toString() {
return "Cannot divide by 0";
}
@Override
public String getMessage() {
return "Enter a number other than 0";
}
}
class MaxInputException extends InputMismatchException{
@Override
public String toString() {
return "Number can't exceed 100000";
}
@Override
public String getMessage() {
return "Pls enter a number 7000";
}
@Override
public String getMessage() {
return "Pls enter a number
Best Solutions. You have explained in very simple way
It is workign , thnaks bro !!
Thank You
plz one vedios harry bahi for commerse students to how to become a software engineer plz make a vedio harry bahi plz dont ignore.
Nice 👍
Bhai 1m hone wale hai😁😁
Thanks a lot sir 🔥 🔥 🔥
Accounting ka video bhi banao plz🙏🏻🙏🏻
Herry bhi Arduino tutorial series per video banao
Challenge Accepted. I watched all till now
DONE BROTHER
Sir ji data structures kab tak khatam hoga??
I mean abhi main wo kar raha hu aur exam aane vale hain to about kitna baki hoga ??
challenge accepted and also completed in one go
Sir how many more topics are left?? Pls reply 😭😭😭😭😭😭🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
DracWound has accepted it
Challenge accepted
I am watching this play list's videos from starting
Sir Advance Java bhi karaoge
Please make tutorial on kivy after this one
Yeah, I want this , Please bhai make a playlist on this
can you help me ..??????????? in my console CORS policy in chrome browser error occur ..can you help me how to overcome it ..or may suggest a tutorial video for CORS policy ...
did it
thank s
/*Hello Harry sir,
I am watching this course from starting,
I saw this video today and accept the challenge and here is my answer*/
package com.masaaledaarCalculator;
import java.util.Scanner;
class InvalidInput extends Exception{
@Override
public String toString(){
return "Operator is invalid";
}
}
class MaxInputException extends Exception{
@Override
public String toString(){
return "Input can't be greater than 1 lakh";
}
}
class MaxMultiplierException extends Exception{
@Override
public String toString() {
return "Input can't be greater than 7 thousand in multiplication";
}
}
public class code extends Exception{
public static void operatorCheck(String opr) throws InvalidInput {
if (opr.equals("+") || opr.equals("-") || opr.equals("*") || opr.equals("/")) return;
throw new InvalidInput();
}
public static double add(int x,int y) throws MaxInputException {
if (x>100000||y>100000) throw new MaxInputException();
System.out.println("The value of "+x+" + "+y+" is : ");
return x+y;
}
public static double subtract(int x,int y) throws MaxInputException {
if (x>100000||y>100000) throw new MaxInputException();
System.out.println("The value of "+x+" - "+y+" is : ");
return x-y;
}
public static double multiply(int x,int y) throws MaxMultiplierException {
if (x>7000||y>7000) throw new MaxMultiplierException();
System.out.println("The value of "+x+" * "+y+" is : ");
return x*y;
}
public static double divide(int x,int y) throws MaxInputException,ArithmeticException {
if (x>100000||y>100000) throw new MaxInputException();
System.out.println("The value of "+x+" / "+y+" is : ");
return x/y;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the operator(only +,-,*,/ are allowed): ");
String opr = sc.next();
try {
operatorCheck(opr);
}
catch (Exception e){
System.out.println(e);
return;
}
System.out.println("Enter the first number : ");
int x = sc.nextInt();
System.out.println("Enter the second number : ");
int y = sc.nextInt();
if (opr.equals("+")){
try{
System.out.println(add(x,y));
}
catch (Exception e){
System.out.println(e);
}
}
else if (opr.equals("-")){
try{
System.out.println(subtract(x,y));
}
catch (Exception e){
System.out.println(e);
}
}
else if (opr.equals("*")){
try{
System.out.println(multiply(x,y));
}
catch (Exception e){
System.out.println(e);
}
}
else {
try{
System.out.println(divide(x,y));
}
catch (Exception e){
System.out.println(e);
}
}
}
}
/* Thank you Harry sir for providing such an amazing course at 0 cost;
Hoping that you will reply soon and give me a shoutout*/
A big shoutout👏🏻
Challenge Excepted
And Alhamdulillah done
Allah ka fazal se
package com.companey;
import java.util.Scanner;
import java.util.concurrent.ExecutionException;
class InvalidInput extends Exception{
@Override
public String toString(){
return "Invalid input exception / Exeption";
}
@Override
public String getMessage(){
return "Why you are entering 8 , 9 ";
}
}
class MaxInput extends Exception{
@Override
public String toString(){
return "Max Input greater then, 100000";
}
@Override
public String getMessage(){
return "why you are using greater than 1lac value";
}
}
class MaxMultiplierReached extends Exception{
@Override
public String toString(){
return " Max Multiplier Reached";
}
@Override
public String getMessage(){
return "why you are using above value of 7000";
}
}
class CantDivByZero extends Exception{
@Override
public String toString(){
return "Divided by / Zero Exception";
}
@Override
public String getMessage(){
return "Why your are entering Zero for division!";
}
}
class DivLaterValue extends Exception{
@Override
public String toString(){
return "dive by value is big";
}
@Override
public String getMessage(){
return "why your are entering div by value in here";
}
}
class CostumeCalculator{
public void add(int a, int b) /*throws MaxInput, InvalidInput*/ {
try {
if (a
Note: Here MaxMultiplierReachedException occurs if the result of multiplication reached above 700000. Which is different from the one asked in the question, only done so to make it look somewhat realistic.
import java.util.Scanner;
class MaxInputException extends Exception{
@Override
public String toString(){
return "Max Input Exception occured: Inputs must be less or equal to 100000";
}
@Override
public String getMessage(){
return "Max Input Exception occured: Inputs must be less or equal to 100000";
}
}
class InvalidInputException extends Exception{
@Override
public String toString(){
return "Invalid Input Exception occured: Operand Specified must be one of them: +, -, *, /";
}
@Override
public String getMessage(){
return "Invalid Input Exception occured: Operand Specified must be one of them: +, -, *, /";
}
}
class DivideByZeroException extends Exception{
@Override
public String toString(){
return "Divide By Zero Exception occured: Denominator of the division can not be Zero(0)";
}
@Override
public String getMessage(){
return "Divide By Zero Exception occured: Denominator of the division can not be Zero(0)";
}
}
class MaxMultiplierReachedException extends Exception{
@Override
public String toString(){
return "Max Multiplier Reached Exception occured: The result of multiplication reached above 700000";
}
@Override
public String getMessage(){
return "Max Multiplier Reached Exception occured: The result of multiplication reached above 700000";
}
}
class CalculatorUsingCustomExceptions{
public static int div(int x,int y) throws DivideByZeroException{
if(y==0){
throw new DivideByZeroException();
}
return x/y;
}
public static int mul(int x,int y) throws MaxMultiplierReachedException{
int result=x*y;
if(result>700000){
throw new MaxMultiplierReachedException();
}
return result;
}
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
String operand;
int a;
int b;
while(true){
System.out.println("Enter first number:");
a=sc.nextInt();
System.out.println("Enter second number:");
b=sc.nextInt();
if(a>100000||b>100000){
try{
throw new MaxInputException();
}catch(Exception e){
System.out.println(e);
continue;
}
}
System.out.println("Press + for Addition
Press - for Subtraction
Press / for Division
Press * for Multiplication
press q to quit");
operand=sc.next();
switch(operand){
case "+":{
System.out.println("Sum="+(a+b));
break;
}
case "-":{
System.out.println("substraction="+(a-b));
break;
}
case "*":{
try{
System.out.println("multplication="+mul(a,b));
}catch(Exception e){
System.out.println(e);
}
break;
}
case "/":{
try{
System.out.println("Division="+div(a,b));
}catch(Exception e){
System.out.println(e);
}
break;
}
case "q":case "Q":{
System.exit(0);
}
default:{
try{
throw new InvalidInputException();
}catch(Exception e){
System.out.println(e);
}
break;
}
}
}
}
}
thanku so much sirrr
Present sir ❤👌🏻❤👌🏻❤👌🏻
why should i use try-catch when i can create this code by simple if else ???
Harry bhai 👋👋
Hi bro, if learn python programming 3.7.1 version it's ok or not .
Can you please make h series on Vue.js tutorial...
Bhai
Android development course apke channel kar complete h ya nahi
harry bhai ek request hai ek video banaiye jquery mobile par mene youtube par bahut sari video dekhi par jquery mobile ki video hindi me sahi tarike se nahi mili.
Sir I want to ask you .why the Indian web developers are not developing app like WhatsApp in such privacy concern issues.
Sir please answer it .
Students comment below ❤️🙏👍
Hi
Sir you have all the knowledge and resources
So why can’t you make app like WhatsApp
Chat app for India .is it impossible for you to do that
I saw all from beginning
Accepted
Gurudev please continue DS algo series...
CHALLENGE ACCEPTED and COMPLETED.
//Custum calculator as per your instructions
class InvalidInputException extends Exception{
@Override
public String toString() {
return "Cannot divide 8 and 9";
}
@Override
public String getMessage() {
return "I am get message";
}
}
class CannotDivideZeroException extends Exception{
@Override
public String toString() {
return "Cannot divide by zero";
}
@Override
public String getMessage() {
return "I am get message";
}
}
class MaxInputException extends Exception{
@Override
public String toString() {
return "Your input is greater than 1000 not allowed";
}
@Override
public String getMessage() {
return super.getMessage();
}
}
class MaxMultiplyReached extends Exception{
@Override
public String getMessage() {
return "Not allowed of any multiplication greater than 7000";
}
}
class custumCalculator{
double add(double a,double b) throws InvalidInputException,MaxInputException{
if(a>1000||b>1000){
throw new MaxInputException();
}
if(a==8 || b==9){
throw new InvalidInputException();
}
return a+b;
}
double subtract(double a,double b) throws MaxInputException {
if(a>1000||b>1000){
throw new MaxInputException();
}
return a-b;
}
double multiply(double a,double b)throws MaxInputException,MaxMultiplyReached{
if(a>7000||b>7000){
throw new MaxMultiplyReached();
}
if(a>1000||b>1000){
throw new MaxInputException();
}
return a*b;
}
double divide(double a,double b) throws CannotDivideZeroException,MaxInputException{
if(a>1000||b>1000){
throw new MaxInputException();
}
if(b==0){
throw new CannotDivideZeroException();
}
return a/b;
}
}
public class Custum_calculator {
public static void main(String[] args) throws InvalidInputException,CannotDivideZeroException,MaxInputException,MaxMultiplyReached {
custumCalculator cc=new custumCalculator();
// cc.add(8,9);
// cc.divide(8,1200);
//cc.divide(32,0);
cc.multiply(600,7001);
}
}
Bhai app bolethe ki stock market pe series laoge
package Projects.Projects;
import java.util.*;
class MaxMultiplierException extends Exception {
public String toString() {
return super.toString() + " Input Greater than 7000";
}
public String getMessage() {
return super.getMessage() + " Input Greater than 7000";
}
}
public class Custom_Calculator {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
/*
* You have to create a custom calculator with the following operations :
* 1. × Multiplication
* 2. ÷ Division
* 3. + Addition
* 4. - Subtraction
* which throws the following exceptions :
* 1. Invalid Input Exception
* 2. Cannot divide by 0 exception
* 3. MaxInputException if any input is greater than 1000
* 4. MaxMultiplier Exception - Don''t allow any multiplication input to be greater than 7000
* */
System.out.println("\t\t\t\tCUSTOM CALCULATOR
");
System.out.println("The operations This calculator can perform are : ");
System.out.println("1. (A)ddition (+)");
System.out.println("2. (S)ubtraction (-)");
System.out.println("3. (M)ultiplication(×)");
System.out.println("4. (D)ivision (÷)");
System.out.println("5. (E)xit
");
char c = ' ';
while(c != 'e' && c != 'E') {
System.out.println("Enter the First Alphabet of the operation you want to perform : ");
c = sc.next().charAt(0);
System.out.println();
switch(c){
case 'A' :
case 'a' :
System.out.println("Enter the total number of figures for which you want the sum : ");
int a;
try {
a = sc.nextInt();
}
catch(InputMismatchException ime) {
System.out.println("There was an Error.");
a = sc.nextInt();
}
double[] arr = new double[a];
for(int x = 0; x < a ;x++) {
System.out.println("Enter a number : ");
try {
arr[x] = sc.nextDouble();
}
catch(InputMismatchException Ime) {
System.out.println("There was an error.");
System.out.println("Enter a number : ");
try {
arr[x] = sc.nextDouble();
}
catch(InputMismatchException IME) {
System.out.println("There was an error.");
System.out.println("Enter a number : ");
arr[x] = sc.nextDouble();
}
}
}
double sum = 0;
for(int x = 0; x < a; x++) {
sum += arr[x];
}
System.out.print("Sum of " );
for(int x = 0;x
grt work bro
Harry Bhai DSA k play list me video dalo I have already finished tree insertion and deletion.....but few topics are still remaining to upload!
Bye the way thanks for all your struggles in making playlist DSA playlist 🔥
shuru se abhi tak saare video dekhe hain
//here is the answer:
//before main method-
import java.util.Scanner;
class divide_by_zero extends Exception{
@Override
public String getMessage() {
return "Suggestion:Please select any other number";
}
@Override
public String toString() {
return "Error:The divisor given is zero";
}
}
class invalid_input_error extends Exception{
@Override
public String getMessage() {
return "Suggestion:Please choose funtion among->
-
+
*
/";
}
@Override
public String toString() {
return "Error:Invalid function entered";
}
}
class value_limit_reached extends Exception{
@Override
public String toString() {
return "Error:Value can not be larger than 100000";
}
@Override
public String getMessage() {
return "Suggestion:Please enter value less 100000";
}
}
class multilayer_limit_reached extends Exception{
@Override
public String toString() {
return "Error:Multiplication value can not be larger than 7000";}
@Override
public String getMessage() {
return "Suggestion:Please select value less than 7000";
}
}
// after main method..
System.out.println("The Calculator:Exercise 6");
System.out.println("Type:
+ for add
- for subtract
* for multiply
/ for divide");
Scanner input=new Scanner(System.in);
//funtion
System.out.println("Enter the function");
String function=input.next();
//numerical value
System.out.println("enter number 1");
int num1=input.nextInt();
System.out.println("enter number 2");
int num2=input.nextInt();
switch (function){
case "/" -> {
if (num2 == 0) {try{
throw new divide_by_zero();}
catch (Exception a){
System.out.println(a.toString());
System.out.println(a.getMessage());
}
}
else {System.out.println("the result is " + (num1 / num2));}
}
case "+"-> {
if (num1>=100000 | num2>=100000){
try{
throw new value_limit_reached();
}
catch (Exception a){
System.out.println(a.toString());
System.out.println(a.getMessage());
}
}
else {System.out.println("the result is " + (num1 + num2));}
}
case "-"->{
if (num1>=100001 | num2>=100001){try{
throw new value_limit_reached();}
catch (Exception a){
System.out.println(a.toString());
System.out.println(a.getMessage());
}
}
else {System.out.println("the result is " + (num1 - num2));}
}
case "*"->{if (num1>=7001 | num2>=7001){
try{
throw new multilayer_limit_reached();
}
catch (Exception a){
System.out.println(a.toString());
System.out.println(a.getMessage());
}
}
else {System.out.println("the result is " + (num1 * num2));}}
default -> {try {
throw new invalid_input_error();
}
catch (Exception a){
System.out.println(a.toString());
System.out.println(a.getMessage());
}
} }
//thnx for this course and second answer!!!!!!
Bhot shi bhai bhot effort Dale he 👌👏
sir jii data structure wali playlist complete kr do plzzz...
Done....
kya java ki tutorial over ho gai hai 113 video par?
Bro plzzz accounting padhao 🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
Sir when we will get full android development playlist
Challenge Accepted sir !!
I have done this problem