Need a little help writing a program that will create a Television object with S
ID: 3651423 • Letter: N
Question
Need a little help writing a program that will create a Television object with Sony as the manufacturer, 52 as the screen size, and $1299.00 as the price. This program should call the disPlayInfo() method to display information about the tevevision, change the price to $999.00 by using the setPrice() method, and the call the displayInfo() method again.Use the below pseudocode, to create the program
// Proram name: Vicent Johnson
// Purpose: develop a class to help in tracking inventory for TVs
// Variables include manufacturer, screen diagonal size (in inches),
// retail price (in dollars and cents)
// Author: Paul Addison
// Date last modified: 07-Oct-2012
public class TVInventoryTracker {
private String manufactorer;
private int diagonalSize;
private float retail;
public TVInventoryTracker(String manufactorer, int diagonalSize,
float retail) {
this.manufactorer = manufactorer;
this.diagonalSize = diagonalSize;
this.retail = retail;
}
public void setPrice(float price){
this.retail = price;
}
public void displayInfo(){
System.out.println("TVInventoryTracker [manufactorer=" + manufactorer
+ ", diagonalSize=" + diagonalSize + ", retail=$" + retail + "]");
}
Explanation / Answer
public class TVInventoryTracker { private String manufactorer; private int diagonalSize; private double retail; public TVInventoryTracker(String manufactorer, int diagonalSize, double d) { this.manufactorer = manufactorer; this.diagonalSize = diagonalSize; this.retail = d; } public void setPrice(Double price){ this.retail = price; } public void displayInfo(){ System.out.println("TVInventoryTracker [manufactorer=" + manufactorer + ", diagonalSize=" + diagonalSize + ", retail=$" + retail + "]"); } public static void main(String[] args) { //TVInventoryTracker("Sony",52,1299.00); TVInventoryTracker TI=new TVInventoryTracker("sony", 52, 1299.00); TI.displayInfo(); TI.setPrice(999.00); TI.displayInfo(); } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.