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.

thanks

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.


Thanks


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

Computer.java
Code:

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;
    }
   
    @Override
    public String toString(){
        String result = "Manufacturer: " +manufacturer+
                      "\nCPU: " +processor+
                      "\nRam: " +ramSize+ "megabytes" +
                      "\nDisk: " +diskSize+ "gigabytes" +
                      "\nProcessor speed: " +processorSpeed+ "gigahertz";
        return result;
    }

}

Notebook.java
Code:

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);
       
       
    }
   
    @Override
    public String toString() {
        String result = super.toString() +
                            "\nScreen size: " +screenSize+ "inches" +
                            "\nWeight: " +weight + "pounds";
        return result;
    }
    }

Desktop.java
Code:

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){
        addComponent(Prices.MEMORY_1GB,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;
    }
}

Thanks,

Recommended Answers

All 4 Replies

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

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.

command input

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.