A salesman working in a company gets the commission on the sale done by him depending on the following condition...
how can I write a program (without using strings) to print the commission of a salesman using (if and else)??
A salesman working in a company gets the commission on the sale done by him depending on the following condition...
how can I write a program (without using strings) to print the commission of a salesman using (if and else)??
I'm new to Bash programming and I'm quite confused about the conditional statements (compared to other programming languages). I want to check if one of my variables is set. I've found out, that Bash version 4.2+ supports a new conditional expression -v (more here, scroll down to -v) which can be used to check if a variable is set. If the variable is set, I also want to check if it contains valid path to which I can cd.
So I came up with this code:
function myFunc {
if [[ -v myPathVar ]]; then
if [[ -d $myPathVar ]]; then
cd $myPathVar
# do stuff here with a variable $1 which is passed into the function
fi
fi
}
But the code leads to this error for [[ -v myVar ]] and I don't know why:
conditional binary operator expected
When I change the code to single square brackets the if check works - which confuses me a lot.
So I got multiple questions here:
if [[ -f $aFileVar ]]; then... which always worked.if statements when using double square brackets? I saw some examples where the if in front of the double square brackets was omitted and instead a && was added. Does this also work with a block of commands or only with a single command (or at least commands on the same line)?-d on a variable which may be not initialised? Or does it lead to a null pointer exception or something (like in Java)?I would also appreciate to see how this small code example could actually be written.
Even if I have some experience with other programming languages I find it quite hard to get into Bash programming. For me, it seems like there are just those man style documentations which I find hard to search for specific information (unlike for example the Android developer documentation, which has a good search, pretty nice code examples and the technical explanations are imho well written).
Another point which confuses me is the way how Bash handles function parameters. From looking at the function declaration only I could not tell if there are parameters passed to the function or not, right? There is also no possibility to name the parameters or make sure, that the user has passed in all necessary parameters, right? So:
In the given code i am using else statement outside if statement so is it correct.
for num in range(15,25):
for i in range(2,num):
if num%i ==0:
print("found a factor ",(i)," for ",num)
break
else:
print(num,"is a prime number")
I just made an account here in order to ask professionals for help. I am searching for the solution on how to do this.
I am referring to the weekdays or weekend part. If the user were to write either two, how do you assign it to numbers? Like if-else statements. if x == weekdays print("Your payment is RM 220") I know this doesn't make 100% sense, but I tried explaining as best as I could. More insight to what I am doing is basically writing up a payment. Yes, you could tell I'm just a regular high school student trying to finish up their project. Maybe I haven't learn or understand more functions..
Hi am trying to make a small money maker game, where the user enters an amount of coins and then gets the number of cents, pennies etc based on the amount the user inputs.
Now if the user puts in a fractional number i have made the console round down with the Math.Floor() method.
But i am thinking it is better to make an if statement where this only happens if the user inputs .5 and down, and rounds up if the user inputs .6 and up.
Do i now use the Contains() method and a or operator: || to achieve this? Is this a bad way to do it?
The reason i am asking about this is because i want to learn.
Ok, so I need assistance with an array, I have a 2D array that a player can move through, at the moment I'm randomly generating an entity and a player is supposed to be able to interact with it. I have one decently long if statement that tracks if the player approaches the entity however unable to increase the range at what will trigger a prompt. This if statement is long and was frustrating to wrap my head around at times but is as follows;
if(((getPlayerX() == getEntityX() - getPlayerRange()) || (getPlayerX() == getEntityX() + getPlayerRange()) || (getPlayerX() == getEntityX())) && ((getPlayerY() == getEntityY() - getPlayerRange()) || (getPlayerY() == getEntityY() + getPlayerRange()) || (getPlayerY() == getEntityY()))){
However when the range increase to two (from its default which is one), this no longer works. I want to implement this so a player with higher range can still interact with this entity. Is there an easier way to do this that might be more efficient?
Im new to uipath and coding in general. I know most of the basics from what was taught but they didnt go through how to form "condition" statements in the "if" activity. or basically any form of conditions. Where can i go about to learning them? is it a specific language?
kinda like: not Months.Contains(ExpenseMonth)
i wouldnt be able to come up with that because i dont know what is acceptable/readable to uipath studio
also regarding those calculations. where can i find more information on those? to learn more about
kinda like: (int32.Parse(row("Value").ToString) * 100 / monthlyTotal).ToString
they didnt really give me details on how to form that
so essentially, if i wasnt spoon fed with those statements, i would be stuck