Hey guys I am still learning how to use simple java. I want to try to do this program which i found in some book, but i cant seem to get how to started. They say its a beginners program, but i found it quite difficult on how to start.

can someone please give me some way to start the code, so i can at least look and learn.


Here are the instructions for this java program:

Create a pricing system for a company that makes individualized computers, such as you might see on a Website. There are two kinds of computers: notebooks and desktop computers. The customer can select the processor speed, the amount of memory, and the size of the disk drive. The customer can also choose either a CD drive (Cd rom, cd-rw), a DVD drive, or both. For notebooks, there is a choice of screen size. Other options are a modem, a network card, or a wireless network. You should have a abstract class Computer and subclasses Desktop and Notebook. Each subclass should have methods for calculating the price of a computer, given the base price plus the cost of the different options. You should have methods for calculating memory price, hard drive price, and so on. There should be a method to calculate shipping cost.


Here is the most i Could get for this program. I am missing main class and having trouble with rest


public class Computer {

private String manufacturer;
private String processor;
private double ramSize;
private int diskSize;
private double processorSpeed;

    public Computer(String man, String processor, double ram, int disk, double procSpeed){
        manufacturer = man;
        this.processor = processor;
        ramSize = ram;
        diskSize = disk;
        processorSpeed = procSpeed;

    public double computePower(){
        return ramSize * processorSpeed;
    public double getRamSize(){
        return ramSize;
    public double getprocessorSpeed(){
        return processorSpeed;
    public int getDiskSize(){
        return diskSize;
    public String toString(){
        String result = "Manufacturer: " +manufacturer+
                      "\nCPU: " +processor+
                      "\nRam: " +ramSize+ "megabytes" +
                      "\nDisk: " +diskSize+ "gigabytes" +
                      "\nProcessor speed: " +processorSpeed+ "gigahertz";
        return result;



public class Notebook extends Computer {
    private static final String DEFAULT_NB_MAN = "MyBrand";
    private double screenSize;
    private double weight;

    public Notebook (String man, String proc,int ram, int disk, double procSpeed, double screen, double wei){
        super(man, proc, ram, disk, procSpeed);
        screenSize = screen;
        weight = wei;
    public Notebook( String proc, int ram, int disk, double procSpeed, double screen, double wei ){
        this(DEFAULT_NB_MAN, proc, ram, disk, procSpeed, screen, wei);
    public String toString() {
        String result = super.toString() +
                            "\nScreen size: " +screenSize+ "inches" +
                            "\nWeight: " +weight + "pounds";
        return result;


public class Desktop extends Computer{
    private int basePrice = 500;
    private int totalPrice = 0;

    public void addComponent(int price, int amount){
        totalPrice += price*amount;   
    public void addMemory(int amount){
    public int getPrice() {
        return basePrice + totalPrice;

    public static class Prices{
        public static int MEMORY_1GB = -1;
        public static int DISK_1GB = -1;
        public static int PROCESSOR_2GHZ = -1;
        public static int PROCESSOR_4GHZ = -1;


Edited by acash229: n/a

7 Years
Discussion Span
Last Post by acash229

> which i found in some book
That book being your course book and the problem being homework. Why not just say that?

Edited by Ezzaral: n/a


Yes i Need help though. I have gotten this far but cant finish it


Well first you need to create an input system where you will get your values.

What do you plan to use?? GUI?? command input?? HTML??

do that 1st and i basing from your code, i think it is almost complete.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.