Java: read 2 integers and compute their sum
Solved
momar mbengue
Posted messages
9
Status
Member
-
papisco51 Posted messages 1 Status Member -
papisco51 Posted messages 1 Status Member -
Hello,
I am a beginner in programming.
I would like to write a program that reads two integers and performs the sum. But I have a problem with the function call "Claver.lireInt()".
Please help me.
Thanks for all.
I am a beginner in programming.
I would like to write a program that reads two integers and performs the sum. But I have a problem with the function call "Claver.lireInt()".
Please help me.
Thanks for all.
2 answers
Here is a pg responding to your question
I use " int a=TextWindow.readInt();" instead of "Claver.lireInt()". Here the "a" is an example
public class somme{
public static void main (String args[]){
TextWindow.printLine("give an integer a");
int a=TextWindow.readInt();
TextWindow.printLine("give an integer b");
int b=TextWindow.readInt();
int resultat= (a+b);
TextWindow.prinLine("the result of the sum of the 2 chosen numbers="+resultat);
}
}
You can run it, if it doesn't work display another message see you soon
I use " int a=TextWindow.readInt();" instead of "Claver.lireInt()". Here the "a" is an example
public class somme{
public static void main (String args[]){
TextWindow.printLine("give an integer a");
int a=TextWindow.readInt();
TextWindow.printLine("give an integer b");
int b=TextWindow.readInt();
int resultat= (a+b);
TextWindow.prinLine("the result of the sum of the 2 chosen numbers="+resultat);
}
}
You can run it, if it doesn't work display another message see you soon
Hi
I don't know this class (Keyboard), nor its method..
Now it's certainly a class that was created as part of a school project..
So what's really your problem?? Calling the method or how to retrieve the "int"?? I suppose this method returns this "int" to you?? Do you have any documentation on this class?
Chouba,
Pochard d'assaut..
I don't know this class (Keyboard), nor its method..
Now it's certainly a class that was created as part of a school project..
So what's really your problem?? Calling the method or how to retrieve the "int"?? I suppose this method returns this "int" to you?? Do you have any documentation on this class?
Chouba,
Pochard d'assaut..