Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
java methods what do they mean by myInfo call a method?
this is what they are asking
Variable Name Variable Contents
myName = place your name here
creditsTaken = place your credits taken this semester
totalCredits = place your total amount of credits taken
GPA = place your current GPA
major = place your major
className = place the name of this class
- Call a method named myInfo PASSING the previous variables
this is what I have
public static void main(String[] args) {
String myName, Major, className;
Double creditsTaken, totalCredits, GPA;
int maxValue, addNumbers;
myName = "william";
Major = "information technology";
className = "operating Systems";
creditsTaken = 9.0;
totalCredits = 70.0;
GPA = 3.1;
maxValue = 100;
addNumbers = maxValue;
System.out.println();
System.out.println("hello my name is.... " + myName);
System.out.println("my major is.... " + Major);
System.out.println("I have completed " + totalCredits + " credits so far");
System.out.println("I am taking " + creditsTaken + " credits this semester");
System.out.println("This class name is...... " + className);
System.out.println();
System.out.println(addNumbers + 1);
3 Answers
- Magic MattLv 68 years agoFavorite Answer
What is 'maxValue' and 'addNumbers'?? There is no instructions for these variables, and they are not needed. Also, there are no instructions that say to print out the info in the variables. All it asks you to do is pass the variables to a function called 'myInfo'. This is all you need:
public static void main(String[] args) {
String myName, major, className;
Double creditsTaken, totalCredits, gpa;
myName = "william";
major = "information technology";
className = "operating Systems";
creditsTaken = 9.0;
totalCredits = 70.0;
gpa = 3.1;
myInfo(myName, major, className, creditsTaken, totalCredits, gpa);
}
- Anonymous5 years ago
If you realy need to know the internal operations of the compiler, read some compiler specific books. If you need to understand the "concept" of "calling", is just a simple set of instructions encapsulated into a name... So instead of having a very big file with a lot of lines of code, the compiler "geeks" have developed a way to put a code into a special construction called "method" and to assign the whole code you put here with a name...(it's more complex than this but I'm not going into detalils right now...). By the way if you will read enough you will find out that at the compilation time, the "name" of the method is practically "replaced" by the code contained in it...As far as calling from one method another method... is basically the same concept described above... the compiler must "find" the "name" of the method in order to replace it at the compilation time with the appropriate code... It's late and I hope I've made miself "understandable"...:)).
- KaydellLv 78 years ago
You've got everything in one method called main(). It sounds like your lesson is on creating your own methods. You are asked to create a method called myInfo(). It would be outside of main() but inside of your class definition and would look something like this:
Notice that in the declaration of myInfo, the method is declared as static. This is because we want it to be callable from main which is also static. Being a static method, it is not required to create an object to call it.
Then maybe, inside of the body of myInfo, you could print out the data rather than printing it inside of the main() method.
It seems like you would want to call the class Student or something. Really, it seems like there should be two classes, Student and Course. When you do programming in Java, it is object-oriented and your classes and objects should be like the real world that you are modeling, but like I said, I think that the point of the exercise is developing and using methods besides main()