Question

Quick Access 熅Package Explorer 23 曰ちい▽ーロ D Volunteer,java D Volunteer Test.java 23 -ロ 貝Task List 2 public class VolunteerTest ▼申(default package) Volunteer java 4 public static void main(String[] args) Find THIS CODE MUST NOT BE CHANGED IN ANY WAY!1 JRE System Library [JavaSE-18] // The code below will be used to test the Volunteer class I/ created by the students for Lab 3 10 THIS CODE MUST NOT BE CHANGED IN ANY WAY!!! Connect Mylyn // Use constrictors to create an empty volunteer object /1 and an object containing data Volunteer volunteer1-new VonO: Volunteer volunteer2 new Volunteer Bill, Gates, 5); 12 13 14 15 16 17 18 19 20 Connect to your task and ALM tools or greate a local task Outline //Display the initial values in the objects System.out.printfC volunteer1 name issn, volunteer1.getName) System , out . printf(volunteer1 hours available is : %s%n%n, volunteer!.getHoursAvailat System.out.printf(volunteer2 name is : %sKn, volunteer2.getName()); System.out.printf(volunteer2 hours available is : %s%n%n, volunteer2.getHoursAvailat //Update the objects volunteer1.setFirstNameCMelinda; volunteer1.setLastName( Gates; volunteer1.setHoursAvailable(18); volunteer2.setHoursAvailable(7); R Problems @ Javadoc 见Declaration-Console× <terminated> VolunteerTest [Java Application] /Library)Java/JavaVirtualMachines(jdk1,8.0 102.jdk/Contents/Home/bin/java (Aug 17, 2017, 11:12:49 AM volunteer1 name is : nullnull volunteer1 hours available is0 volunteer2 name is: BillGates volunteer2 hours available is :5 volunteer1 name is :MelindaGates volunteer1 hours available is: 18 volunteer2 name is BillGates volunteer2 hours available is :7 Writabl Smart Insert 12: 22

I need help in this basic java programming. I just need a program that output this according to the original picture above.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Volunteer.java

public class Volunteer {

//instance variables

private String firstName;

private String lastName;

private int hoursAvailable;

//default parameter

public Volunteer()

{

this.firstName = null;

this.lastName = null;

this.hoursAvailable = 0;

}

//constructor with parameters

public Volunteer(String firstName, String lastName, int hoursAvailable)

{

this.firstName = firstName;

this.lastName = lastName;

this.hoursAvailable = hoursAvailable;

}

//getters

//method that returns name

public String getName()

{

return this.firstName+this.lastName;

}

//method that returns hours available

public int getHoursAvailable()

{

return this.hoursAvailable;

}

//setters

//method that sets firstname

public void setFirstName(String firstName)

{

this.firstName = firstName;

}

//method that sets lastname

public void setLastName(String lastName)

{

this.lastName = lastName;

}

//method that sets lastname

public void setHoursAvailables(int hoursAvailable)

{

this.hoursAvailable = hoursAvailable;

}

}

VolunteerTest.java

public class VolunteerTest {

public static void main(String[] args) {

// Use constructors to create an empty volunteer object

// and an object containing data

Volunteer volunteer1 = new Volunteer();

Volunteer volunteer2 = new Volunteer("Bill", "Gates", 5);

//Display the initial values in the objects

System.out.printf("volunteer1 name is : %s%n", volunteer1.getName());

System.out.printf("volunteer1 hours available is : %s%n%n", volunteer1.getHoursAvailable());

System.out.printf("volunteer2 name is : %s%n", volunteer2.getName());

System.out.printf("volunteer2 hours available is : %s%n%n", volunteer2.getHoursAvailable());

//Update the objects

volunteer1.setFirstName("Melinda");

volunteer1.setLastName("Gates");

volunteer1.setHoursAvailables(10);

volunteer2.setHoursAvailables(7);

//Display the update values in the objects

System.out.printf("volunteer1 name is : %s%n", volunteer1.getName());

System.out.printf("volunteer1 hours available is : %s%n%n", volunteer1.getHoursAvailable());

System.out.printf("volunteer2 name is : %s%n", volunteer2.getName());

System.out.printf("volunteer2 hours available is : %s%n%n", volunteer2.getHoursAvailable());

}

}

Output:

Let me know if you have any concerns with the above solution

Add a comment
Know the answer?
Add Answer to:
I need help in this basic java programming. I just need a program that output this...
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
  • help fixing this code in JAVA SIC 7 19 11 12 src eclipse-workspace - doublesalary2/src/module-info.java -...

    help fixing this code in JAVA SIC 7 19 11 12 src eclipse-workspace - doublesalary2/src/module-info.java - Eclipse IDE HG2GP Package Explorer X B J "module-info.java X J module-info.java Outline X Assigment 1 @ 1 module doublssalary21 bill import java.util.Scanner; doublosalary2 doublasalary N 4 public class DoubleSalary I DoubleSalary > JRE System Library (JavaSE-14) M 5 public static void main(String[] args) { @ main(Stringni : void 6 Scanner sc = new Scanner(System.in); doublasalary2 System.out.print("Enter number of days: "); 8 ► JRE...

  • How do I correct this error in my code? When it got to the file type...

    How do I correct this error in my code? When it got to the file type I can only go "null" from a certain point and I'm wondering how to correct this error. Also can I get a word document on this coding strategy for this problem? How much of this am I doing correctly? The original problem description: Create a program that provides a listing of all the files in a directory. The program should be a Java application...

  • Really need help with this. This is for my Advanced Java Programming Class. If anyone is...

    Really need help with this. This is for my Advanced Java Programming Class. If anyone is an expert in Java I would very much appreciate the help. I will provide the code I was told to open. Exercise 13-3   Use JPA to work with the library checkout system In this exercise, you'll convert the application from the previous exercise to use JPA instead of JDBC to access the database. Review the project Start NetBeans and open the project named ch13_ex3_library that's...

  • Need help with this Java. I need help with the "to do" sections. Theres two parts...

    Need help with this Java. I need help with the "to do" sections. Theres two parts to this and I added the photos with the entire question Lab14 Part 1: 1) change the XXX to a number in the list, and YYY to a number // not in the list 2.code a call to linearSearch with the item number (XXX) // that is in the list; store the return in the variable result 3. change both XXX numbers to the...

  • DataSetEmployee Can you please help me the JAVA program? Here is the requirement. Rewrite DataSetBook to...

    DataSetEmployee Can you please help me the JAVA program? Here is the requirement. Rewrite DataSetBook to be DataSetEmployee. DataSetEmployee should extend ArrayList<Employee> and have no instance variables. You'll have to decide what replaces the getPages concept for getMax/getMin. As a hint, what method of Employee returns a numeric value? Make a package com.acme.midmanager. This package should contain the Manager class. Make a package com.acme.personnel. This package should contain the DataSetEmployee class. Make a package com.acme.topmanagement. This package should contain the...

  • Input hello, I need help completing my assignment for java,Use the following test data for input...

    Input hello, I need help completing my assignment for java,Use the following test data for input and fill in missing code, and please screenshot output. 1, John Adam, 3, 93, 91, 100, Letter 2, Raymond Woo, 3, 65, 68, 63, Letter 3, Rick Smith, 3, 50, 58, 53, Letter 4, Ray Bartlett, 3, 62, 64, 69, Letter 5, Mary Russell, 3, 93, 90, 98, Letter 6, Andy Wong, 3, 89,88,84, Letter 7, Jay Russell, 3, 71,73,78, Letter 8, Jimmie Wong,...

  • Please Implement this code using Java Eclipse. CIS 1068 Assignment 8 Warm Up with Objects Due:...

    Please Implement this code using Java Eclipse. CIS 1068 Assignment 8 Warm Up with Objects Due: Wednesday, March 25 70 points (+ up to 15 extra credit) The purpose of this assignment is to give you practice implementing your own classes. It also provides extra practice with arrays. Task Implement a class Task, which is used to represent a job that should be done. It should contain the following private fields: .name text description of what job should be done...

  • Java Programming The program template represents a complete working Java program with one or more key...

    Java Programming The program template represents a complete working Java program with one or more key lines of code replaced with comments. Read the problem description and examine the output, then study the template code. Using the problem-solving tips as a guide, replace the /* */ comments with Java code. Compile and execute the program. Compare your output with the sample output provided. Modify class Time2 to include a tick method that increments the time stored in a Time2 object...

  • I need help writing my main method**** Computer Science 111 Introduction to Algorithms and Programming: Java...

    I need help writing my main method**** Computer Science 111 Introduction to Algorithms and Programming: Java Programming Project #4 – Classes and Objects (20 Points) You will create 3 new classes for this project, two will be chosen from the list below and one will be an entirely new class you invent.Here is the list: Shirt Shoe Wine Book Song Bicycle VideoGame Plant Car FootBall Boat Computer WebSite Movie Beer Pants TVShow MotorCycle Design First Create three (3) UML diagrams...

  • I have Majority of the code written but I just need to implement the <,>,and =...

    I have Majority of the code written but I just need to implement the <,>,and = sign in the code. I have posted the instructions for the whole code. I will add what I have at the end. Objectives: Implement basic class concepts in Java Implement inheritance with super and sub-classes Implement basic polymorphism concepts Problem: The TARDIS has been infected by a virus which means it is up to Doctor Who to manually enter calculations into the TARDIS interface....

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
ADVERTISEMENT