|
really thank you for answering me the question is: Write a function calculates allowing to perform an operation on two numbers according to a given operator.
|
|
|
|
|
No, that's not a question. That's your homework assignment.
Nobody here is going to do your homework for you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Well you have still not explained what is wrong with the code you have already written.
|
|
|
|
|
From my vantage point, this does not satisfy the "according to a given operator" requirement. I think your instructor is looking for a routine that could handle inputs like:
print(foo(1, 2, "+"));
print(foo(6, 3, "/"));
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Really thank you for answering me. but my instructor had already given me this indication. but like I told you I really can't. if you can give me more details that would do me a lot of good. Thank you for answering me.
|
|
|
|
|
olivier Dakouri wrote: ...but like I told you I really can't. Really can't what?
Take the code you've (supposedly) written, merge the four functions into one, and in that single function, separate each operation with a series of if/elseif statements. The third argument of this function is what the if/elseif statements will key off of.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
hello I tried myself but I can not add the other calculations (multiplication, subtraction, division). like i said i am really a beginner. Really thank you for answering me.
void main() {
print(calcul(12, 10));
}
int calcul(int a, int b) {
return a + b;
}
|
|
|
|
|
To repeat what you has already been suggested, you need a third parameter to your function which specifies the type of calculation.
int calculate(int param1, int param2, char operator)
{
int result = 0;
if (operator == '+')
result = param1 + param2;
else if (operator == '-')
return result
}
int sum = calculate(10, 23, '+');
So you just need to write the code for the other operations.
|
|
|
|
|
Really thank you for your help I didn't know where to start. If you have any documentation that can help me understand better I am willing to study it thank you again.
|
|
|
|
|
You seem to be following a model that many people follow these days, which is trying to run before you can walk. If you do not understand the basics then you will always struggle. Go to Dart programming language | Dart[^] and follow some of the tutorials.
|
|
|
|
|
Good evening
Write a numberElementsPairs function that returns the number of even elements in a list of integers.
Example
var list = [1, 2, 3, 5, 7, 8]
var result = numberElementsPairs (list)
here is my solution
void main() {
nombreElementsPairs(List) {
var list = [1, 2, 3, 5, 7, 8];
var nombreElementsPairs = 0;
var a;
var resultat = 0;
for (a in (list)) {
if (a % 2 == 0) {
resultat = a % 2;
}
}
return resultat;
}
print('le nombre pair est $nombreElementsPairs(List)');
}
but it does not pass
|
|
|
|
|
olivier Dakouri wrote: ...returns the number of... I take this to mean the "count" of something.
olivier Dakouri wrote: if (a % 2 == 0) { While this is indeed checking the "even-ness" of a number...
olivier Dakouri wrote: resultat = a % 2; This is not counting anything. You should be incrementing a counter-type variable with each even number found.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
There are a number of things wrong.
1. The nombreElementsPairs function is inside the main function; it should be a separate block.
2. The list of numbers is supposed to be a parameter passed in to the function, but you ignore that and create a new local list.
3. You create the counter nombreElementsPairs but never refer to it again.
4. You test every element of the list to see if it is even, and if it is you set the resultat variable to zero. Note, that you previously initialised resultat to zero, so if all elements of the list are odd, it will still be zero at the end.
5. The return value of the function is resultat which will always be zero, which is not the count of anything.
6. The print statement does nothing useful.
As I already suggested, you should go to the Dart website and work through the tutorials, so you get to understand how to structure your program logically.
|
|
|
|
|
I was able to stop it from automatically coming up with the location of where my Wifi service is (which for some reason is about 350 miles away), and added a few cities, and selected one of the cities, but then when I got out of the app and back to the Android desktop (or whatever it's called), I get one of the other cities in the list of cities. And I don't feel like having to reboot.
modified 18-Jul-21 20:31pm.
|
|
|
|
|
Have you seen this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
modified 13-Oct-21 8:13am.
|
|
|
|
|
There is always some difference in the position of my controls in the simulated screen and the split view (Visual Studio 2019). Which one is correct? How can I make them similar?
https://s4.uupload.ir/files/107153-1_j5q.png[^]
|
|
|
|
|
hello I want to know how to retrieve the data from an API and display this data in an array for example if I have an array that contains the users how to form an array with their name, first name, city etc ... put the values that I retrieved from an API in react native
please help me with full example
|
|
|
|
|
im aziz plss sir html cods plss sir
|
|
|
|
|
This site does not provide code to order, even if you had managed to describe the code you're demanding, or managed to use proper words instead of "text speak".
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
I am trying to get GSM data into the android studio. However, this data must not come through the server. Basically, sending the data from GSM module from Arduino to android application without including any type of server such as Firebase. Need help
|
|
|
|
|
You need some form of connection between the two devices. You can then use TCP/IP sockets to communicate. Google will find plenty of samples.
|
|
|
|
|
Want to order a clone of Clubhouse from app development company. How much it would cost ?
|
|
|
|
|
Ask the company that will do the development for a quote.
We can't say "It'll be $xxx" becuase we have no idea where the dev company is, what its hour rate works out at, or how long they think it will take to produce.
And I have multiple hourly rate "charge bands" based on experience with that company and how good they are actually paying ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I do not have any programming background, but I would like to train to become a Hybrid mobile app developer from scratch. What languages and technologies do I need to learn and how can I access this training? Thank You All
|
|
|
|