Question

HELLO, I really need help on a java project. It involves methods and getting data from...

HELLO, I really need help on a java project. It involves methods and getting data from other classes.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
//AddNumbers.java
public class AddNumbers {
  int n1, n2;

  public AddNumbers(int n1, int n2) {
    this.n1 = n1;
    this.n2 = n2;
  }

  public int getN1() {
    return n1;
  }

  public void setN1(int n1) {
    this.n1 = n1;
  }

  public int getN2() {
    return n2;
  }

  public void setN2(int n2) {
    this.n2 = n2;
  }

  public int getSum(){
    return n1+n2;
  }
}

====================================

//TestCode.java
public class TestCode {
  public static void main(String args[]){
    AddNumbers object = new AddNumbers(3,4);
    System.out.println("Sum = "+object.getSum());
  }
}

====================================

Sum = 7

Add a comment
Know the answer?
Add Answer to:
HELLO, I really need help on a java project. It involves methods and getting data from...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hello, I need some help creating this class in Java. This is for a larger project....

    Hello, I need some help creating this class in Java. This is for a larger project. I am using Eclipse if that helps 1. Create a class named State that will store information about a state and provide methods to get, and set the data, and compare the states by several fields. a. Fields: Name, Capital City, Abbreviation, Population, Region, US House Seats b. Constructor c. Get and set methods for each field d. Compare method to compare State objects...

  • Hello, this is foer engineering economices. I really really need help with the below problem. I...

    Hello, this is foer engineering economices. I really really need help with the below problem. I will thumbs up for fast and solid work! (10 points) In 2015, a company places a manufacturing machine in service. The machine cost $20,000 from the supplier and took another $2000 for installation costs. Create a table showing the book value and MACRS depreciation amount that can be taken each year, for as many years as the machine can be depreciated. 2. Year Depreciation...

  • Hello, this is for Discrete Math. I really need help with the problem below. I promise...

    Hello, this is for Discrete Math. I really need help with the problem below. I promise to thumbs up for solid answers. Thank you very much! 4 (8 points) Use an element argument to prove that for all sets A and B if ASB , th

  • Hello, I need help writing the two methods to print a triangle shape in java. An...

    Hello, I need help writing the two methods to print a triangle shape in java. An example of the shape is as follows: 9 8 7 6 5 4 3 8 7 6 5 4 3 7 6 5 4 3 6 5 4 3 5 4 3 4 3 3 One method should be defined as "public static void printPattern(int num1, int num2, Boolean ascending)". This method will print a upper-triangle matrix-like layout filled will a sequence of integers...

  • I need some help with Java. I need to write a Java program that generates a...

    I need some help with Java. I need to write a Java program that generates a set of random strings from a given string of same length where no character is ever repeated and character belong to the original string. See example. Example Input: “Hello World” (length 9) Output: “World oHlel” (length 9)

  • Hello I need help creating a bash script for linux as shown below getting the information...

    Hello I need help creating a bash script for linux as shown below getting the information from ifconfig The script must programmatically gather and output the informationEXACTLY AS SHOWN BELOW and (not echo this and echo that). ====================================== Interface: AAA MAC Address: BB:BB:BB:BB:BB:BB IP Address: CCC.CCC.CCC.CCC Subnet Mask: DDD.DDD.DDD.DDD Received Bytes: EEEEEE ====================================== Thanks,

  • Hi I need help creating a program in JAVA. This is material from chapter 9 Objects...

    Hi I need help creating a program in JAVA. This is material from chapter 9 Objects and Classes from the Intro to JAVA textbook. Mrs. Quackenbush's Rent-A-Wreck car rental ..... Mrs. Q asked you to create a program that can help her track her growing fleet of junkers. Of course she expects you to use your best programming skills, including: 1. Plan and design what attributes/actions an automobile in a rental fleet should have (example. Track number of Trucks, SUVs,...

  • I need help with this java project and please follow the instruction below. thank Class Project...

    I need help with this java project and please follow the instruction below. thank Class Project - Parking Ticket simulator Design a set of classes that work together to simulate a police officer issuing a parking ticket. Design the following classes: •           The ParkedCar Class: This class should simulate a parked car. The class’s responsibilities are as follows: – To know the car’s make, model, color, license number, and the number of minutes that the car has been parked. •          ...

  • Hello! I have a Java homework question that I could really use some help with. I...

    Hello! I have a Java homework question that I could really use some help with. I keep getting an error, but I don't know what is wrong with my code. Thanks so much in advance! The problem is: 6.9: VowelAnalyst Design and implement an application that reads a string from the user, then determines and prints how many of each lowercase vowel (a, e, i, o, and u) appear in the entire string. Have a separate counter for each vowel....

  • Hello, I am doing a project of Apple, and need your help on following; I need...

    Hello, I am doing a project of Apple, and need your help on following; I need to find out a Risk-free rate, Risk Premium for stock and beta to calculate Required return on the stock of apple. I know how to get a beta, but I do not know how to get a Risk-free rate and Risk Premium for stock. From my research, I could get a risk-free rate, which is 10-year treasury bonds, which is 2.79%. Can you please...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT