Many if statements refactor c++

So, i have this piece of code.

enum {ENUM_ONE, ENUM_TWO}; if (Value_x == 1) {     if (BoolType)     {         if (!FindStuff(ENUM_ONE))         {             AddStuff(ENUM_ONE, 0, 0, 0, 0, 0, 0);         }     }     else     {         if (FindStuff(ENUM_ONE))         {             RemoveStuff(ENUM_ONE);         }     } }  if (Value_x == 2) {     if (BoolType)     {         if (!FindStuff(ENUM_TWO))         {             AddStuff(ENUM_TWO, 0, 0, 0, 0, 0, 0);         }     }     else     {         if (FindStuff(ENUM_TWO))         {             RemoveStuff(ENUM_TWO);         }     } } 

I want to shorten this code, here i pasted only two if statements. But i have 30 if staements like this.

How i can optimize those if’s ? I don’t want to write 30 if like those.

Working with multiple If statements, data validation and multiple sheets in Google Sheets

I’m working on a spreadsheet and could really use some help. I’m trying to populate cells in a main worksheet with cells from another worksheet within the spreadsheet.

Currently I’m planning on having a dropdown using data validation in A1 to select which sheet to view, and populate it based on what is selected.

In the populated sheets the code in A2 looks somewhat like this

=IF(REGEXMATCH(A1,"SheetA), SheetA!A2, IF(REGEXMATCH(A1,"SheetB"), SheetB!A2)) 

Currently this works flawlessly for the first if statement, but not for the second. My understanding was that the if function in google sheet was formated like this


Anyone care to help me out with this?

BMI calculator in python using if statements

i am a beginner in the python language and i wrote a bmi calculator and i am wondering if there are any improvements i could make to the code? This is the code below: print('Enter your weight in kilo:') weightInKilo = float(input())

print('Enter your height in feet:')

heightInFeet = float(input())

heightInMeter = heightInFeet * 12 * 0.025

bodyMassIndex = weightInKilo / (heightInMeter ** 2)

if bodyMassIndex < 15: print('Your BMI = ' + str(bodyMassIndex) + ' You are very severely underweight.')

elif bodyMassIndex >= 15 and bodyMassIndex <= 16 : print('Your BMI = ' + str(bodyMassIndex) + ' You are severely underweight.')

elif bodyMassIndex > 16 and bodyMassIndex <= 18.5: print('Your BMI = ' + str(bodyMassIndex) + ' You are underweight.')

elif bodyMassIndex > 18.5 and bodyMassIndex <= 25: print('Your BMI = ' + str(bodyMassIndex) + ' You are Normal(healthy weight).')

elif bodyMassIndex > 25 and bodyMassIndex <= 30: print('Your BMI = ' + str(bodyMassIndex) + ' You are overweight.')

elif bodyMassIndex > 30 and bodyMassIndex <= 35: print('Your BMI = ' + str(bodyMassIndex) + ' You are moderately obese.')

elif bodyMassIndex > 35 and bodyMassIndex <= 40: print('Your BMI = ' + str(bodyMassIndex) + ' You are severely obese.')

elif bodyMassIndex > 40: print('Your BMI = ' + str(bodyMassIndex) + ' You are very severely obese.')

input('Please press Enter to exit')


is it possible to use if-else statements in mocha’s it() function individually?

I recently started with mocha and wanted to know if we could use if else statements for conditional testing. I want to be able to use conditions in ever it() function in order to put assertions on Json data received in response to that getprojection() function call.

I have posted a code as an example to illustrate what I am trying to achieve. Any help would be appreciated. Thanks!!

var assert = require('chai').assert; var expect = require('chai').expect; var should = require('chai').should(); // var projection = require(''); var projectionsTest = require('./getProjection')        describe("Annual Tax Projection", function () {         describe("Current Year Tax - #2018", function () {             it("should return correct taxable Income", function (done) {                 projectionsTest.getProjection('params', 'params', function (projections) {                     if (grossIncome <= deductions){                         assert.deepEqual(projections[2018].taxableIncome, 0)                     }else throw new Error("There is something wrong with tax calculation")                     done(Error);                 });             });             it("should check federal tax is calculated correctly", function (done) {                 projectionsTest.getProjection('params', 'params', function (projections) {                     if (taxableIncome === 0 || taxBracket ===10){                         assert.deepEqual(projections[2018]. )                     }else                     done(Error);                 });             });         });     }) 

Identify – Two statements which can’t be true together, but can be false – from the following premises

 Among the following, there are two statements which can't be true together, but can be false together. Select the code that represents them.          Statements :        (a) All poets are dreamers.  (b) No poets are dreamers.        (c) Some poets are dreamers. (d) Some poets are not dreamers. <br>   (A) (c) and (d)   (B) (b) and (d)   (C) (a) and (d)   (D) (a) and (b) 

This is rather confusing. because (c) and (d) are essentially the same thing isn’t?

Bank Statements and the Standard Visitor Visa

I am applying for a visa for my son, not for myself. I am a British citizen, whilst my son is Bolivian. I work as a missionary with special needs kids, and my income is not a lot. It’s adequate for Bolivia (more than, actually) but low for the UK.

My bank statements aren’t great, we’ve been living off savings for the past year. Additionally, there’s a lot of robbery here, so I put all my money into a savings account that can’t be access offline, and transfer it only when necessary. So when I get income, I pull it out of the account immediately and put it in savings. But there is obviously also a lot coming out of savings. I do it for safety reasons, but it doesn’t look good when I’m trying to prove financial stability.

I also have an account with the mission here in Bolivia (and it is a registered charity in the UK) which looks way better financially, because only my rent comes out of it and it’s built up a considerable amount of money over the past year. However, it’s not a bank account, just an account with the mission.

So my question is, do I send my own bank accounts? Or do I have my mum, his grandmother, sponsor his visit? We will both be living with her, and she’s happy to do so. But I on my other post it was suggested that the application is stronger if it isn’t sponsored.

And if I were to send my own bank statements, would it help his case to state that I intend to work while in the UK? I am a registered teacher in Northern Ireland and I am registered to substitute teach.

Is Venn diagram sufficient to prove statements for two or three sets?

We know the general figure of Venn diagrams for two or three distinct sets.

There are many formulas related to two or three sets.

For example, one of Distributive Law is

$ $ A \cup (B \cap C) = (A \cup B) \cap (A \cup C).$ $

We can visualize it by using Venn Diagram, and guess that it is true.

And also, we can prove it to show that each side is contained in the other side.

It is my question. For rigorous proof, I know we should only use mathematical logic and theorem. Nonetheless, I want to check that Venn Diagram proof is also available for some easier cases.

Can Venn Diagram be one method of proof?

Can we prove that all proof by using Venn Diagram method for two or three sets is true?

If we prove that, then all statements for two or three sets can be strictly proved by using Venn Diagram.

How to show share proceeds in bank statements for UK visa

I will be applying for a visitor visa to UK in Feb 2019.In my bank statements there are entries for credit and debit of proceeds related to share transactions that I have performed during last 6 months.Since these are relatively large amounts compared to account balance, how do I explain this in my application? Do I need to attach the contract notes for those specific transactions or is there any other way? Also I shift most of my salary to my savings account, so there is only minimum balance maintained in this salary account.Do I need to show statements from both salary and savings account in this case?

Alternate to nested if statements (alternate posing of question)

Sample Data Sheet:

The end goal is to have a Month + Year show up in a single cell, based on the first instance of “New Total” being >=0.

The sheet includes sample data, and the formatting we are interacting with.

In the purple box, I want the month + year to populate, based on the first instance of “New Total” being >=0. When the formula reaches the first instance of >=0 (March in the sample data), I want it to then pull “March” from cell Q2 and concatenate with “2019” from cell “S2”. The values of “New Total” are dynamic, and will change periodically. Right now, the sample data should result in “March 2019”, but tomorrow it might change so that “February” is the first >=0 instance.


Input: Row of Numbers, looking for the first instance of “New Total” being >=0.

Output: Pull Month + Year once “New Total” has found int >=0 in specified row. Display in specified cell.

Here’s how it was done with the nested IF statements:

=IF(G15>=0,E14&" "&G14,IF(J15>=0,H14&" "&J14,IF(M15>=0,K14&" "&M14, 

How can I check SQL statements?

I’m looking for the security of sql injection.

sql = select * from where field01 = '1' AND field = 'where' example01 ('sql', 'where') 
  • The above sentence is looking to check that ‘where’ goes in once and ‘and’ goes in twice.
  • Using the function, you can see that the reserved word ‘where’ has been entered once.
  • What I’m looking for is a library or concept built around it.

Do these libraries exist? ( Of course I know of regular expressions. )

Additional questions:

  • Does the prepared statement have the functionality I’m talking about?
  • Does the DBMS procedure have the functionality I’m talking about?