Answer to Question #238548 in Java | JSP | JSF for Lolo

Question #238548
Program 5 – Magazine application Code the following program in Java. Only submit the source files. There will be two source files. Do not zip your project as it increases the marking time significantly. As a programmer you must be able to follow precise instructions. You will also not always get precise instructions. You must learn to ask questions and make valid deductions of what is expected. 1. Code the Magazine class according to the class diagram. 2. Code a class MagazineApp. a. This class have a main method. b. Code an array that can hold 5 Magazine objects. c. Add (hard-code) objects to this array. d. Display the array on the screen. Use the toString(). e. Remember to code a heading for the report, as well as a ending message.
1
Expert's answer
2021-09-17T11:29:45-0400
File Magazine.java

public class Magazine {
	private String name;
	private double price;
	private String editor;
	private String email;


	public Magazine() {
	}


	public Magazine(String name, double price, String editor, String email) {
		this.name = name;
		this.price = price;
		this.editor = editor;
		this.email = email;
	}


	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}


	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}


	/**
	 * @return the price
	 */
	public double getPrice() {
		return price;
	}


	/**
	 * @param price the price to set
	 */
	public void setPrice(double price) {
		this.price = price;
	}


	/**
	 * @return the editor
	 */
	public String getEditor() {
		return editor;
	}


	/**
	 * @param editor the editor to set
	 */
	public void setEditor(String editor) {
		this.editor = editor;
	}


	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}


	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}


	@Override
	public String toString() {
		return "Name: " + this.name + "\n" + "Price: " + this.price + "\n" + "Editor: " + this.editor + "\n" + "Email: "
				+ this.email + "\n";
	}
}




File MagazineApp.java

//Code a class MagazineApp.
// a. This class have a main method
public class MagazineApp {


	public static void main(String[] args) {
		// b. Code an array that can hold 5 Magazine objects.
		Magazine allMagazines[] = new Magazine[5];
		// c. Add (hard-code) objects to this array.
		allMagazines[0] = new Magazine("Allure", 35.99, "Peter Smith", "Allure@gmail.com");
		allMagazines[1] = new Magazine("Elle", 25.99, "Mary Clark", "Elle@gmail.com");
		allMagazines[2] = new Magazine("Health", 56.99, "Mike Johnson", "Health@gmail.com");
		allMagazines[3] = new Magazine("InStyle", 23.99, "Julia Rob", "InStyle@gmail.com");
		allMagazines[4] = new Magazine("Marie Claire", 25.99, "Mary Smith", "MarieClaire@gmail.com");
		// d. Display the array on the screen. Use the toString().
		// e. Remember to code a heading for the report, as well as a ending message.
		System.out.println("All magazines:");
		for (int i = 0; i < 5; i++) {
			System.out.println(allMagazines[i].toString());
		}


	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS