Total members 11894 |It is currently Sat Nov 23, 2024 1:40 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Java Television class
Code:
//Class:           IT/215 Week Five Inventory Program 1

import java.text.NumberFormat;
import java.util.Locale;
import java.util.Scanner;

class Television {

    private String itemNumber;
    private String productName;
    private double units;



    //constructor
    public Television (String itemNumber, String productName, double units, double unitprice) {
        setItemNumber(itemNumber);
        setProductName(productName);
        setUnits(units);
        setUnitPrice(unitPrice);

    }

    //accessor methods for class variables
    public String getItemNumber () {
        return itemNumber;
    }

    public void setItemNumber (String itemNumber) {
        this.itemNumber = itemNumber;
    }

    public String getProductName () {
        return productName;
    }

    public void setProductName (String productName) {
        this.productName = productName;
    }

    public double getUnits () {
        return units;
    }

    public void setUnits (double units) {
        this.units = units;
    }

    public double getUnitPrice () {
        return unitPrice;
    }

    public void setUnitPrice (double unitPrice) {
        this.unitPrice = unitPrice;
    }

}
public class InventoryPart1 {

    public static void main (String[] args) {

        NumberFormat nf = NumberFormat. getCurrencyInstance(Locale.US);

        //create an instance of the Television class

        Television samsung = new Television ("SAMSUNG 46", "Class 6400 Series",9.3,1,599.99);

        //use the methods from class Television to output the inventory details.

        System.out.println("Item Number: " + samsung.getItemNumber());

        System.out.println("Product Name: " + samsung.getProductName());

        System.out.print("Number of Units: " + samsung.getUnits());

        System.out.print("Unit Price: " + nf.format(samsung.getUnitPrice()));

        System.out.print("Inventory______ Total:_______"+ nf.format(samsung.calculateInventoryTotal()));

     }
}

 





Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time

what is your problem with this class . i see it as simple one .

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : Java Television class
 java abstract class,concrete class and interface     -  
 Java Rectangle Class     -  
 Java Email Class     -  
 Nested classes(inner class) in java     -  
 Define class helper class to check the method existance     -  
 relationship between the Canvas class and the Graphics class     -  
 inner class that is a member of an outer class?     -  
 Define class inside another class C++     -  
 load class to applet- load frame class to applet     -  
 PHP example for a class     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com