For Question 4 -> Make a custom class for the error -> class Exceptiononretry extends Exception{ @Override public String getMessage(){ return "Error"; } } In the main function-> if(i>=5){ try{ throw new Exceptiononretry(); } catch(Exceptiononretry e){ System.out.println(" "+e.getMessage()); } } For question 5 -> Using the above custom class make this function-> public static void throwexception(int i) throws Exceptiononretry{ if (i if(i>=5){ try{ throwexception(i); } catch(Exceptiononretry e){ System.out.println(" "+e.getMessage()); } }
Problem #3 can be done this way; /* Problem 3 // Write a program that allows you to keep accessing elements of an array until a valid index is given. If max retries exceed 5, print "Error". int [] marks = new int[5]; marks[0] = 50; marks[1] = 70; marks[2] = 100; marks[3] = 90; marks[4] = 10;
Scanner sc = new Scanner(System.in); boolean flag = true;
while (flag){ System.out.print("Enter valid array index: "); int user_input = sc.nextInt(); try { System.out.println(marks[user_input]); } catch (ArrayIndexOutOfBoundsException e){ System.out.println("ERROR!"); flag = false; } } System.out.println("Thanks for using this program!"); */ It makes more sense!
You haven't understood the qs. Qs me index as an input Galt (jo index out of bound) dalneka 5 max mauka deta hai....agr in 5 mauke Mei koi sahi index Dal deta hai to program exit hona chahiye Matlab further input nehi mangega program and agr sahi index dalneki kosis 5 ke upr jata hai to error show hona chahiye.
12:09 - Solution given below: // Problem 4 and 5 import java.util.Scanner; class MaxRetriesExceededException extends Exception{ @Override public String toString(){ return " MaxRetriesExceededException: "+getMessage(); } @Override public String getMessage(){ return "You have exceeded the maximum limit of 5 attempts to access the array."; } } public class PS_03_KeepAccessingAnArray { static void accessArray()throws MaxRetriesExceededException{ // declaration int index,c = 1; String [] vegetables = {"Potato","Garlic","Ginger","Tomato","Onion"}; boolean isIndexValid; do { Scanner sc = new Scanner(System.in); System.out.print("Enter an index number - "); index = sc.nextInt(); try{ System.out.print("Element at index "+index+" - "+vegetables[index]); isIndexValid = true; sc.close(); } catch(ArrayIndexOutOfBoundsException e){ System.out.println("Invalid Index. \tTry again"); isIndexValid = false; } if (isIndexValid==true) break; else if(c==5){ sc.close(); throw new MaxRetriesExceededException(); } c++;
Harry bhai, wish u aap ache hoge or kush honge apni life me Bhai me aapki webdevlopment vaali series sikh rha tha tb merko ek idea aaya bhot exclusive h m vo apse discuss krna chata hu hope vo apko psnd aaye.? M apke rply ka wait krunga thank you..
// Sir actually i start my coding journey 3 months before and this is first time i solve a question by myself. //I can't able to believe ! This is so amazing feeling. // Thank You sir , Thankyou so much... // Haa aasan aasan Qs. toh solve ho jate hai , Logic wala ye pahla tha . /*(Q3) Write a program that allows you to keep accessing an array until a valid index is given . If max retries exceed 5 , print "Error". */ import java.util.Scanner; public class vn87_PracticeSet14 { public static void main(String[] args) { int [] Sahiba = new int[5]; Sahiba[0]=5; Sahiba[1]=6; Sahiba[2]=58; Sahiba[3]=48; Sahiba[4]=16;
System.out.println("LOVE IS BEAUTIFUL THINGS FOUND IN NATURE EVER."); int i=0; while(i4) { System.out.println("You crossed the limit of 5 inputs"); System.out.println("Error"); } }
Sorry for asking in this video. I completed 61 video out of 103 in your web development playlist everything going smoothly no issue. But i want to know that after this course kya main website bna paaunga.. please reply... N thank you for uploading these amazing playlist on coding n programming. Basically i m a commerce student but i love these things so i started your course. Ang thnk uh. N love you bro keep it up
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..
class MaxTriesReachedException extends Exception{ @Override public String toString() { System.out.println("Error"); return "Tries can't be >5"; } public String getMessage(){ return "Make sure entered index is correct."; } } if(t>=5){ throw new MaxTriesReachedException(); }
12:00 - Solution Of Question Number 5 import java.util.Scanner; class Prints_an_Exception extends Exception { @Override public String toString() { return "Error! Index is out of bound..."; } @Override public String getMessage() { return "Error occured!"; } } public class PrintTheException{ public static int funtion(int val ) throws Prints_an_Exception{ if (val>5){ throw new Prints_an_Exception(); } return val; } public static void main(String[] args) { int[] arr = {10, 20, 30, 40, 50}; boolean flag=true; Scanner sc = new Scanner (System.in); int val; int i=0; while(flag && i
Harry bhai yar your teaching so helpful to me. THANK YOU. import java.util.*; class MaxRetriesException extends Exception{ public String toString(){ return "max retries is not allowed"; } } public class cwh_86_pc14 { public static void main(String[] args)throws MaxRetriesException { // try { // int a = 8; // int b = 0; // int c = a / b; // } // catch(ArithmeticException e){ // System.out.println("HaHa"); // } // catch(IllegalArgumentException e){ // System.out.println("Hehe"); // } //problem 3 boolean flag = true; int marks[] = new int[3]; marks[0] = 2; marks[1] = 3; marks[2] = 4; int i=0; while(flag && i= 5){ throw new MaxRetriesException(); //System.out.println("Error"); } } }
Time Stamp - 5:43 // Question - 3 // This will throw ArithmeticException when k is even and IllegalArgumentException when k is odd. // Manually you can change the value of k to check the output. public class javaSolution { public static void main(String[] args) { int k = 5; try { if (k%2 == 0){ int result = 10/0; } else { throw new IllegalArgumentException(); } } catch (ArithmeticException e){ System.out.println("Haha"); } catch (IllegalArgumentException e){ System.out.println("Hihi"); } } }
12:09 -Solution as given below; // Custom Exception class MaxRetries extends Exception{ @Override public String toString() { return "Max Retries Attempts to Access the variable!"; } public static void throwMaxRetriesException(int count) throws MaxRetries{ if(count==5){ throw new MaxRetries(); } } } // In main method: int [] arr={1,2,3,4,5,6,7,8,9,10}; int index,count=0; Scanner scan = new Scanner(System.in); boolean flags=true; while(flags && count
class MaxRetry extends Exception{ @Override public String toString() { return "Max retry exhaust"; } @Override public String getMessage() { return "You try to many wrong , your max retries exhaust..."; } }
class MaxRetry extends Exception{ @Override public String toString() { return super.toString(); } @Override public String getMessage() { return "Index out of Bound"; } } ---> In main method if (i>=5){ try { throw new MaxRetry(); } catch (Exception e){ System.out.println(e.getMessage()); }
Hi Harry bhaia! I want to talk to you, brother , please , bhai , I understand all the concepts of Python programming but can't be solved if you give Python programming QUIZ / Exercise 😭😭😭 , What shall I do, brother? Please help 🥺.
Problem 4 class RetryException extends Exception{ public String toString(){ return "Error"; } public String getMessage(){ return "Error"; } } public class cwh_86_ps14 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a[] = new int[5]; a[0] = 0; a[1] = 1; a[2] = 2; a[3] = 3; a[4] = 4; int i = 1; while (true) { System.out.println("Enter the value of your index"); int b = sc.nextInt(); if (i < 6) { try { System.out.println("Your value" + a[b]); } catch (ArrayIndexOutOfBoundsException e) { i++; System.out.println("You have crossed limit" + i); } } else { try { throw new RetryException(); } catch (Exception e) { System.out.println(e.getMessage()); } } } } }
kapil rana Bhai break method kyo nahi lagaya 6 number ko cross karne ke baad null bata raha hai lekin program se out nahi ho pa raha kya kar sakte hai????
in q3)whats the use of flag variable??? package CORE; import java.util.Scanner; public class PSErrors { public static void main(String[] args) { int [] arr=new int[3]; arr[0]=78; arr[1]=22; arr[2]=89; int i=0; Scanner sc=new Scanner(System.in); while(i=5){ System.out.println("ERROR :NO of attempts exceeded 5");} } }
agar ap argument me int type do kisi method k per jab ap ka user String value enter ker de to usko handle karny k liay illegalArgumentException use hoti hy
inp = input("enter code for crit") if inp=="A": code = input(" Please enter the option code for dish you would like to order (e.g. s1) ") file = open("alltime.txt", "r") total_cost = 0 # print(file.read()) while code != "done": for line in file: data = line.split("-") itemCode = data[0] itemDescription = data[1] itemPrice = float(data[2]) if itemCode == code: print(itemCode+" - "+itemDescription+" - "+str(itemPrice)) total_cost = total_cost + itemPrice code = input("enter code for more order or enter done for exit ") print("total cost of your order is ", total_cost) print('thank you for ordering here') file.close() when I type "done" it gives : IndexError: list index out of range what should I do please help me with this
Bhaiya mera gameing app mai kuch user hai jo ki kuch trick karke high score karta hai uska account ko block or unblock kaise kare.. ???video dene se acha hoga.. 🙏🙏
Problem 5 I have tried this problem by other approach. Please give me some suggestions on how to enhance it and make it better .... package com.company; import java.util.Scanner; class maxRetriesException1 extends Exception{ @Override public String getMessage() { return "Error"; } @Override public String toString() { return "Error"; } } public class L86_Ch14_PS_Q5 { public static void validArray(int i) throws maxRetriesException1{ if(i>=5){ throw new maxRetriesException1(); } } public static void main(String[] args) { boolean flag = true; int [] a = {56, 98, 51}; int ind; Scanner sc = new Scanner(System.in); int i = 0; while(flag && i
for question no. -> class maxIndex extends Exception { @Override public String toString() { return "error"; } } public class Adi { public static void main(String[] args) { // Problem 3 boolean flag = true; int [] marks = new int[3]; marks[0] = 7; marks[1] = 56; marks[2] = 6; Scanner Sc = new Scanner(System.in); int index; int i = 0; while(flag && i=5){ try { throw new maxIndex(); } catch (Exception e) { System.out.println(e); } } } }
i have been following you since 1 year , harry bhai aap apne baare me kuch to batao , like your real name , bckground Hum sabko to yehi lagta hai ek Gora Chita banda ake padha deta hai
// Problem No -->> 4 import java.security.InvalidKeyException; import java.util.InputMismatchException; import java.util.Scanner; import java.util.SimpleTimeZone; class invalidinput extends InputMismatchException { public String toString() { return "Invalid input not allowed"; } public String getMessage() { return "Please valid Number input"; } } class ZeroException extends ArithmeticException{ public String toString(){ return "you can't divide by 0"; } public String getMessage(){ return "you any number type but 0 can't be type"; } } class MaxInputException extends InputMismatchException{ public String toString(){ return "Number can't exceed 100000"; } public String getMessage(){ return "ls enter a number 100000 || b>100000) throw new MaxInputException(); System.out.println("Enter the operation sign: "); op=sc.next().charAt(0); switch(op) { case '+': sol=a+b; break; case '-': sol=a-b; break; case '/': if(b==0) throw new ZeroException(); else sol=a/b; break; case '*': if( a>7000 || b>7000 ) throw new MaxMultiplierReachedException(); else sol=a*b; break; default: throw new ZeroException(); } System.out.println("The ans is: "+sol); } }
Harry Bro👍 your great men in this Earth coders journey Because of you, we coders are getting to learn a lot.god always blessings you....🙏🙏🙏🙏🙏🙏🙏
tum log kya har videos mai yehi likte ho ya kuch padte bhi ho?
I appreciate you for making coding easier for me!!!
For Question 4 ->
Make a custom class for the error ->
class Exceptiononretry extends Exception{
@Override
public String getMessage(){
return "Error";
}
}
In the main function->
if(i>=5){
try{
throw new Exceptiononretry();
}
catch(Exceptiononretry e){
System.out.println("
"+e.getMessage());
}
}
For question 5 ->
Using the above custom class make this function->
public static void throwexception(int i) throws Exceptiononretry{
if (i
if(i>=5){
try{
throwexception(i);
}
catch(Exceptiononretry e){
System.out.println("
"+e.getMessage());
}
}
Thanks..! It helped me a lot....🤗
Thanks bro ❤❤❤
one question why do you extend Exception class ? what is the need I am bit confuse cant we do without extend ?
@@nainagupta4949 then only you can create a custom exception class, inshort creating a subclass from a parent class(Exception) which is in-built.
@@nainagupta4949 to write a custom exception class you need to extend it from exception class.
Problem #3 can be done this way;
/* Problem 3
// Write a program that allows you to keep accessing elements of an array until a valid index is given. If max retries exceed 5, print "Error".
int [] marks = new int[5];
marks[0] = 50;
marks[1] = 70;
marks[2] = 100;
marks[3] = 90;
marks[4] = 10;
Scanner sc = new Scanner(System.in);
boolean flag = true;
while (flag){
System.out.print("Enter valid array index: ");
int user_input = sc.nextInt();
try {
System.out.println(marks[user_input]);
}
catch (ArrayIndexOutOfBoundsException e){
System.out.println("ERROR!");
flag = false;
}
}
System.out.println("Thanks for using this program!");
*/
It makes more sense!
You haven't understood the qs.
Qs me index as an input Galt (jo index out of bound) dalneka 5 max mauka deta hai....agr in 5 mauke Mei koi sahi index Dal deta hai to program exit hona chahiye Matlab further input nehi mangega program and agr sahi index dalneki kosis 5 ke upr jata hai to error show hona chahiye.
12:09 - Solution given below:
// Problem 4 and 5
import java.util.Scanner;
class MaxRetriesExceededException extends Exception{
@Override
public String toString(){
return "
MaxRetriesExceededException: "+getMessage();
}
@Override
public String getMessage(){
return "You have exceeded the maximum limit of 5 attempts to access the array.";
}
}
public class PS_03_KeepAccessingAnArray {
static void accessArray()throws MaxRetriesExceededException{
// declaration
int index,c = 1;
String [] vegetables = {"Potato","Garlic","Ginger","Tomato","Onion"};
boolean isIndexValid;
do {
Scanner sc = new Scanner(System.in);
System.out.print("Enter an index number - ");
index = sc.nextInt();
try{
System.out.print("Element at index "+index+" - "+vegetables[index]);
isIndexValid = true;
sc.close();
}
catch(ArrayIndexOutOfBoundsException e){
System.out.println("Invalid Index.
\tTry again");
isIndexValid = false;
}
if (isIndexValid==true)
break;
else if(c==5){
sc.close();
throw new MaxRetriesExceededException();
}
c++;
}while(c
it's working bro, thanks !!
Harry bhai, wish u aap ache hoge or kush honge apni life me
Bhai me aapki webdevlopment vaali series sikh rha tha tb merko ek idea aaya bhot exclusive h m vo apse discuss krna chata hu hope vo apko psnd aaye.?
M apke rply ka wait krunga thank you..
🤔🤔
???
Problem 4-
if(i>=5){
System.out.println("Error");
try{
throw new MaxRetriesException();
}
catch(Exception e){
System.out.println("Exception:"+e);
}
}
Nice one brother i solved the same ☺️
HARRY BHAI ABHI JAVA COLLECTION FRAMEWORK TAK PAUCHNE K LIYE KITNE VIDEOS LGENGEY ?
class maxRetries extends Exception{
@Override
public String getMessage() {
return "Max Retries reached";
}
@Override
public String toString() {
return "5 Retries";
}
}
try {
if (i>=5){
throw new maxRetries();
}
}
catch (maxRetries m){
System.out.println(m);
System.out.println(m.getMessage());
}
Wrong
EXCEPTION CLASS:
class MaxRetriesException extends Exception{
@Override
public String toString() {
return "Max Retries Error";
}
@Override
public String getMessage() {
return "You have reached max tries,you cannot proceed further";
}
}
Method:
public static void getArrayElementUntilLimitReached() throws MaxRetriesException{
//Problem 3-:
int []arr={1,2,3};
int i;
int index;
Scanner sc=new Scanner(System.in);
for(i=1;i
Thank u bro
this course is very nice sir. I understand every thing very easily.
Harry Bhai !!! Why You Stopped Making Videos on DSA
Bahut sahi kaam kar rahe ho bhai!
12:36
class MyOwnException extends Exception{
@Override
public String toString() {
return "Invalid Input";
}
@Override
public String getMessage() {
return "Error";
}
}
public class HybridCalculator {
public static void main(String[] args){
java.util.Scanner sc = new java.util.Scanner(System.in);
int j = 0;
int[] arr = new int[5];
arr[0] = 1;
arr[1] = 2;
arr[2] = 3;
arr[3] = 4;
arr[4] = 5;
while (j= arr.length) {
try {
throw new MyOwnException();
} catch (Exception e) {
System.out.println(e.toString());
j++;
if (j == 5) {
System.out.println(e.getMessage());
}
}
} else System.out.println(arr[n]);
}
}
}
If you throw MyOwnException class in try block than what about if the user input index is right?? It throws only exceptions not correct values see
Please make a video on functional programming , procedural programming and object oriented programming and their difference......
I hope u cross million subs❤️
Not million but unlimited million.
Can you please upload all the handwritten notes at one place other than that all things are awesome 👏👍
Sir will u teach complete data structure and algorithm in java
Right
yes sir will u??
Question -4
import java.util.*;
class Q_3{
public static void main(String args[]){
Scanner in = new Scanner(System.in);
int a[]=new int[5];
a[0]=0;
a[1]=1;
a[2]=2;
a[3]=3;
a[4]=4;
int i=1;
while(true){
System.out.println("Enter index ");
int b=in.nextInt();
if(i
Thanks bro. It helped me
Thoda sa wait aur 1million subs
Thank you Harry bhai , You are the best programmer in the world and you explain clearly all the stuff in the coding.
Hatts off Harry bhai🤗
1M soon🦄
Harry bhai app ak teligram group banao jisme hum sab discussion krenge
// Sir actually i start my coding journey 3 months before and this is first time i solve a question by myself.
//I can't able to believe ! This is so amazing feeling.
// Thank You sir , Thankyou so much...
// Haa aasan aasan Qs. toh solve ho jate hai , Logic wala ye pahla tha .
/*(Q3) Write a program that allows you to keep accessing an array until a valid index is given .
If max retries exceed 5 , print "Error".
*/
import java.util.Scanner;
public class vn87_PracticeSet14
{
public static void main(String[] args)
{
int [] Sahiba = new int[5];
Sahiba[0]=5;
Sahiba[1]=6;
Sahiba[2]=58;
Sahiba[3]=48;
Sahiba[4]=16;
System.out.println("LOVE IS BEAUTIFUL THINGS FOUND IN NATURE EVER.");
int i=0;
while(i4)
{
System.out.println("You crossed the limit of 5 inputs");
System.out.println("Error");
}
}
}
}
Bhai ye to whi btaya hai Q-4th aur 5th bhi karo
Sorry for asking in this video. I completed 61 video out of 103 in your web development playlist everything going smoothly no issue. But i want to know that after this course kya main website bna paaunga.. please reply...
N thank you for uploading these amazing playlist on coding n programming. Basically i m a commerce student but i love these things so i started your course. Ang thnk uh. N love you bro keep it up
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 ek video is par bhi bna do ki aap ne coding ki starting kaise ki , you are legend from many of us and we will get to know something.
Big fans sir plz upload how to crack password and on mobile or PC camera by using python plz sir plz🙏🙏🙏
class MaxTriesReachedException extends Exception{
@Override
public String toString() {
System.out.println("Error");
return "Tries can't be >5";
}
public String getMessage(){
return "Make sure entered index is correct.";
}
}
if(t>=5){
throw new MaxTriesReachedException();
}
Present sir 👌🏻❤❤👌🏻❤👌🏻👌🏻❤❤👌🏻
Sir, please make a tutorial on a project in java
Love You harry Bhai❤❤❤❤.
When finish java course? How many chapters left?
Sir, please make a playlist on OPENCV in Python,please ,please ,please.
12:00 - Solution Of Question Number 5
import java.util.Scanner;
class Prints_an_Exception extends Exception {
@Override
public String toString() {
return "Error! Index is out of bound...";
}
@Override
public String getMessage() {
return "Error occured!";
}
}
public class PrintTheException{
public static int funtion(int val ) throws Prints_an_Exception{
if (val>5){
throw new Prints_an_Exception();
}
return val;
}
public static void main(String[] args) {
int[] arr = {10, 20, 30, 40, 50};
boolean flag=true;
Scanner sc = new Scanner (System.in);
int val;
int i=0;
while(flag && i
Sir please bring Series of C# because it help alot
Harry bhai yar your teaching so helpful to me. THANK YOU.
import java.util.*;
class MaxRetriesException extends Exception{
public String toString(){
return "max retries is not allowed";
}
}
public class cwh_86_pc14 {
public static void main(String[] args)throws MaxRetriesException
{
// try {
// int a = 8;
// int b = 0;
// int c = a / b;
// }
// catch(ArithmeticException e){
// System.out.println("HaHa");
// }
// catch(IllegalArgumentException e){
// System.out.println("Hehe");
// }
//problem 3
boolean flag = true;
int marks[] = new int[3];
marks[0] = 2;
marks[1] = 3;
marks[2] = 4;
int i=0;
while(flag && i= 5){
throw new MaxRetriesException();
//System.out.println("Error");
}
}
}
Thanks a lot sir 🔥 🔥 🔥
Time Stamp - 5:43
// Question - 3
// This will throw ArithmeticException when k is even and IllegalArgumentException when k is odd.
// Manually you can change the value of k to check the output.
public class javaSolution {
public static void main(String[] args) {
int k = 5;
try {
if (k%2 == 0){
int result = 10/0;
} else {
throw new IllegalArgumentException();
}
} catch (ArithmeticException e){
System.out.println("Haha");
} catch (IllegalArgumentException e){
System.out.println("Hihi");
}
}
}
Bro java Applet or awt controls pr video bnaao
Bro kya html or css sa android app develop kar sak ta hai please reply .
12:09 -Solution as given below;
// Custom Exception
class MaxRetries extends Exception{
@Override
public String toString() {
return "Max Retries Attempts to Access the variable!";
}
public static void throwMaxRetriesException(int count) throws MaxRetries{
if(count==5){
throw new MaxRetries();
}
}
}
// In main method:
int [] arr={1,2,3,4,5,6,7,8,9,10};
int index,count=0;
Scanner scan = new Scanner(System.in);
boolean flags=true;
while(flags && count
Harry bhai problem 3 ki while loop m agr flag n use kre to bi program shi se run ho rha h to flag k kya rule h
Thank you sir ji
Thank you harry bhai
Those who are happy for this course like plz 😜😜😜😜😜
sir please typing speed tezz karna par aik video banady.....
plz make one vedios for commers students how to make a software engineer
plz bahiya plz
Harry bhai will you plz make flutter tutorials playlist
wah harry ji wah
How many more videos will be there in this course?
class MaxRetry extends Exception{
@Override
public String toString() {
return "Max retry exhaust";
}
@Override
public String getMessage() {
return "You try to many wrong , your max retries exhaust...";
}
}
Thank You
Please make a video on python kivy and kivy languages for mobile application
Thanks bro you are awsome your videos are soo helpful
How much syllabus left in this courses? 4 months go.
Harry Bhai, abhh toh MEAN OR MERN par videos upload krdoh
class MaxRetry extends Exception{
@Override
public String toString() {
return super.toString();
}
@Override
public String getMessage() {
return "Index out of Bound";
}
}
---> In main method
if (i>=5){
try {
throw new MaxRetry();
}
catch (Exception e){
System.out.println(e.getMessage());
}
Right.
hmm nice, 6/9
harry bhai please make a tutorial video on dsa in java
Pls SQL padhai dijiye Harry Ji
nice video sir
@Aviral Sonker hi
Harry bhai Ethical hacking ke roadmap par video banao
*please*
Sir your videos are too good,right now i am learning C language from your videos
Thank u harry bhai for efforts
Harry bhai database pr video banao na
Awesome bhai
Can some1 explain me why did we use flag in problem 3 even without flag we can only use indes for 5 times then what was its use!????
We can also specify like this....
//This should be used In while loop//
if(i
Hi Harry bhaia! I want to talk to you, brother , please , bhai , I understand all the concepts of Python programming but can't be solved if you give Python programming QUIZ / Exercise 😭😭😭 , What shall I do, brother? Please help 🥺.
Harry bhai op 🔥🔥🔥🔥
If you provide 'a' as an input in "Q3" , then the programme not run properly . Why it is So ? I Hope anybody will answer it .
Problem 4
class RetryException extends Exception{
public String toString(){
return "Error";
}
public String getMessage(){
return "Error";
}
}
public class cwh_86_ps14 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a[] = new int[5];
a[0] = 0;
a[1] = 1;
a[2] = 2;
a[3] = 3;
a[4] = 4;
int i = 1;
while (true) {
System.out.println("Enter the value of your index");
int b = sc.nextInt();
if (i < 6) {
try {
System.out.println("Your value" + a[b]);
} catch (ArrayIndexOutOfBoundsException e) {
i++;
System.out.println("You have crossed limit" + i);
}
}
else {
try {
throw new RetryException();
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}
}
}
kapil rana Bhai break method kyo nahi lagaya 6 number ko cross karne ke baad null bata raha hai lekin program se out nahi ho pa raha kya kar sakte hai????
Bro you add break in else conditions also
Because while loops continue execute
very good video
bhai mujhe rust programming language sikhna he kya app sikhaoge pls.
in q3)whats the use of flag variable???
package CORE;
import java.util.Scanner;
public class PSErrors {
public static void main(String[] args) {
int [] arr=new int[3];
arr[0]=78;
arr[1]=22;
arr[2]=89;
int i=0;
Scanner sc=new Scanner(System.in);
while(i=5){
System.out.println("ERROR :NO of attempts exceeded 5");}
}
}
bhai dart pr bi course bnao pllz
Sr ma android app download krta hn or hr bar stroge kam bta ha kuion please help me how many requirements stroge for download please🙏🙏🙏🙏🙏🙏🙏
sir please complete the django serise please
sir please complete my request
Hey harry bhai I am your big fan please make one video on turtle module in python
please koi explain kr do illegal argument exception hota kya haa aur vo exception occur krane ke liye iss wale program me kya arguments pass krani haa
agar ap argument me int type do kisi method k per jab ap ka user String value enter ker de to usko handle karny k liay illegalArgumentException use hoti hy
Please go with collection framework
It's true go with collection Framework also it damm difficult for me also to understand. Please
Harry bhai please go with Java framework also
Please sir go with collection Framework.
Yes bro it's appreciated if you go with collection framework
Harry bhai make videos on odoo
Harry bhai will soon reach 1 million subscribers
Who want Harry bhai to come live on UA-cam
inp = input("enter code for crit")
if inp=="A":
code = input(" Please enter the option code for dish you would like to order (e.g. s1)
")
file = open("alltime.txt", "r")
total_cost = 0
# print(file.read())
while code != "done":
for line in file:
data = line.split("-")
itemCode = data[0]
itemDescription = data[1]
itemPrice = float(data[2])
if itemCode == code:
print(itemCode+" - "+itemDescription+" - "+str(itemPrice))
total_cost = total_cost + itemPrice
code = input("enter code for more order or enter done for exit
")
print("total cost of your order is ", total_cost)
print('thank you for ordering here')
file.close()
when I type "done" it gives : IndexError: list index out of range
what should I do please help me with this
Sir DART LANGUAGE ke lie bhi kuch btao....
Haan
Ismai flag variable agr na use krein to bhi chalega
Bhaiya mera gameing app mai kuch user hai jo ki kuch trick karke high score karta hai uska account ko block or unblock kaise kare.. ???video dene se acha hoga.. 🙏🙏
Harry bhai 👋👋
Hello bro! are u able to upload the video of 3d game development
sir notes are not downloading after video no. 79. and chapter 14's practice set also not downloading please check it.
Question-2
import java.util.*;
class Q_2{
public static void main(String arg[]){
int a;
Scanner in = new Scanner(System.in);
try{
System.out.println("Enter value");
a=in.nextInt();
System.out.println("Result :"+a/0);
}
catch(IllegalArgumentException e){
System.out.println("HaHa");
}
catch(ArithmeticException e){
System.out.println("HeHe");
}
catch(InputMismatchException e){
System.out.println(" Hey i am illegal");
}
}
}
Problem 5
I have tried this problem by other approach. Please give me some suggestions on how to enhance it and make it better ....
package com.company;
import java.util.Scanner;
class maxRetriesException1 extends Exception{
@Override
public String getMessage() {
return "Error";
}
@Override
public String toString() {
return "Error";
}
}
public class L86_Ch14_PS_Q5 {
public static void validArray(int i) throws maxRetriesException1{
if(i>=5){
throw new maxRetriesException1();
}
}
public static void main(String[] args) {
boolean flag = true;
int [] a = {56, 98, 51};
int ind;
Scanner sc = new Scanner(System.in);
int i = 0;
while(flag && i
why have you used flag?? while(i
for question no. ->
class maxIndex extends Exception
{
@Override
public String toString() {
return "error";
}
}
public class Adi {
public static void main(String[] args) {
// Problem 3
boolean flag = true;
int [] marks = new int[3];
marks[0] = 7;
marks[1] = 56;
marks[2] = 6;
Scanner Sc = new Scanner(System.in);
int index;
int i = 0;
while(flag && i=5){
try {
throw new maxIndex();
} catch (Exception e)
{
System.out.println(e);
}
}
}
}
Akhilesh Yadav 2GB RAM wala laptop maximum kis limit tak upgrade kar sakte
Please sir start ethical hacking course
Bhai sagar bhai ke me sirf 6 7 videos hi hen
Yes deeksha i am with you
Please tell how to change language of pyttsx3 in python,
I want to change language of my Jarvis
i have been following you since 1 year , harry bhai aap apne baare me kuch to batao , like your real name , bckground
Hum sabko to yehi lagta hai ek Gora Chita banda ake padha deta hai
Make a QNA video after reaching 1M
// Problem No -->> 4
import java.security.InvalidKeyException;
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.SimpleTimeZone;
class invalidinput extends InputMismatchException {
public String toString() {
return "Invalid input not allowed";
}
public String getMessage() {
return "Please valid Number input";
}
}
class ZeroException extends ArithmeticException{
public String toString(){
return "you can't divide by 0";
}
public String getMessage(){
return "you any number type but 0 can't be type";
}
}
class MaxInputException extends InputMismatchException{
public String toString(){
return "Number can't exceed 100000";
}
public String getMessage(){
return "ls enter a number 100000 || b>100000)
throw new MaxInputException();
System.out.println("Enter the operation sign: ");
op=sc.next().charAt(0);
switch(op)
{
case '+':
sol=a+b;
break;
case '-':
sol=a-b;
break;
case '/':
if(b==0)
throw new ZeroException();
else
sol=a/b;
break;
case '*':
if( a>7000 || b>7000 )
throw new MaxMultiplierReachedException();
else
sol=a*b;
break;
default:
throw new ZeroException();
}
System.out.println("The ans is: "+sol);
}
}
5:37 illegal Argument kaise aige
Kya input dene se illegal Argument aige.
Sir please btao ???
bhai print karte waqt kuch illegal dalega usse kehte hai illrgal Arguments