Question:
I NEED JAVA HELP PLEASE?
2010-02-05 11:24:52 UTC
I have a part of java midterm due at the end of the week. unfortunately i have to get surgery on my knee tomorrow and i need some help doing this. I have been missing class because of my knee and i am way behind. Below if part of the problem i need solved. THANK YOU! I asked for an extension but he would not give me one.

//Name:
//Date:

public class MyMathLab
{//open class
public static void main(String args [])
{//open main method

//1.) declare two user defined variables of type int named myNumA, and myNumB




//2.) declare and assign the literal value of 10 to a user defined variable of type byte named myLittleNum



//3.) declare a user defined variable of type int to store the results of the math equation and name it myResult


//4.) declare a String named printOut



//5.) assign literal values to the myNumA and myNumB variables


//6.) assign a value to the myResut value using an addition statement --> add myNumA and myNumB


//7.)assign the text to the String named printOut --> "The value of myResult = "



//8.) call the print method found in the System class in the java.lang.* to print out the values of the printOut and myResult


//9.) print out a line between the print statement above
System.out.println("________________…

//----------------------------------…
//10.) assign new values to the variables myNumA, myNumB, myLittleNum




//11.) assign a value to myResult by multiplying myNumA and myNumB and then subtract myLittleNum --->DON'T FORGET PARENTHESES



//12.) assign a new String value to the variable printOut -- state what you are printing out i.e. the result of multiplying and subtracting



//13.) call the print method found in the System class in the java.lang.* to print out the values printOut and myResult



//print out a line between the print statement above
System.out.println("________________…

//----------------------------------…

//14.)UNCOMMENT OUT THE System.out.println( ); WHEN YOU GET ALL THE STEPS ABOVE WORKING
//use the System.out.println statement to do the math (not very clear and not a good idea)
//System.out.println((((myNumA + myNumB)+myLittleNum)*3));


}


}
Three answers:
Alan
2010-02-05 11:47:34 UTC
Your test doesn't really say, but it's generally a good idea to declare variables private. You can take out the word private everywhere you see it in my answers and it will work, though. Just generally not as secure.



1. private int myNumA, myNumB;

2. private byte myLittleNum = 10;

3. private int myResult;

4. private String printOut;

5. myNumA = 5;

myNumB = 4;

6. myResult = myNumA + myNumB;

7. printOut = "The value of myResult =";

8. System.out.print(printOut + myResult);

9. System.out.println();

10. myNumA = 6;

myNumB = 7;

myLittleNum = 3;

11. myResult = myNumA * myNumB - myLittleNum;

Note: you don't need parentheses. Order of Operations dictates it will evaluate as (myNumA * myNumB) - myLittleNum

12. printOut = "The new result is ";

13. System.out.print(printOut + myResult);

To print a line again, just use:

System.out.println();

14. Remove the "//" from the last line of text you gave.
?
2016-05-31 02:32:46 UTC
For all answers behind your each question you need to go through Java Specifications that were designed when the Java language developers first came up with the idea... Do a google search for Java specification and go through it. I am sure it'll answer to all your WHY's!!!
Aero
2010-02-05 11:32:29 UTC
Add the following:



getThis(string) or exit(String args[]);

public System.set;

if (this) continue[]+=1;

System.out.printIn(%s);

goto(getThisLine-1)) {

select * buffer.true(EXEC);

set.void.buffer+=1; //set true

else exit(String args[]);

if (this).gotoThisLine-1)!=String args[] && !array

dec(^); // return false;

System.out.printIn((((myNumA + myNumB)+myLittleNum)*3));



Should work now.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...