[Solved] Why does the program give me a different result when I use if statement [duplicate]

In an if else-if statement you put multiple conditions to evaluate the result. The following is how the statements will work in your case: if(row==1||row==n||row==2*n-1) cout<<“*”; //if true then put * or if false then move down else if (col==1&&row<n||col==n&&row>n) cout<<“*”; // if the first is false and the 2nd one is true then put … Read more

[Solved] How can i used nested while loop ? in java

In your outer while loop you need this: overtime = 0; if (hoursWorked>8) overtime = (hoursWorked-8)*(rateOfPay*1.5) – (hoursWorked-8)*rateOfPay; // Calculate OVERTIME HOURS sets the overtime to zero for each iteration, and you’ll have to subtract the normal rate for overtime hours (otherwise you add them twice) and then you’ll have to add the overtime to … Read more

[Solved] Javascript – loops [closed]

Suppose there are n people attending this quiz, the # of the winner is x. So the sum of people entering before the winner is the sum of 1+…+(x-1), the sum of people entering after the winner is the sum of (x+1)+…+n. Here we have 1+…+(x-1) = (x+1)+…+n, which derives to (x*(x-1))/2 = ((x+n+1)*(n-x))/2. Simplifying … Read more

[Solved] why is it showing error . Like I thought the third loop will end and it will enter the first loop but didn’t else showed an exception

just replace the condition of the there loops with 26. Now the exception index out of bound will not occur public class SuggestingAppNames { public static void main(String[] args) { System.out.println(“the possible outcomes are”); String a = “A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z”; String d[] = a.split(“,”); String b = “A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z”; String e[] = b.split(“,”); String c = “A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z”; String … Read more

[Solved] Appeding different list values to dictionary in python

Maybe use zip: for a,b,c in zip(scores,boxes,class_list): if a >= 0.98: data[k+1] = {“score”:a,”box”:b, “class”: c } ; k=k+1; print(“Final_result”,data) Output: Final_result {2: {‘score’: 0.98, ‘box’: [0.1, 0.2, 0.3, 0.4], ‘class’: 1}} Edit: for a,b,c in zip(scores,boxes,class_list): if a >= 0.98: data[k+1] = {“score”:a,”box”:b, “class”: int(c) } ; k=k+1; print(“Final_result”,data) 9 solved Appeding different list … Read more