Share on Google+Share on Google+

computer configuration
1 Answer(s)      7 years ago
Posted in : Java Beginners
someone posted a code but tha is not working and i am totaly new to java and i hae to submit my project
kindly help and send a working code

Create a class Computer that stores information about different types of Computers
available with the dealer. The information to be stored about a single computer is,
- Company Name
- RAM size.
- Hard Disk Capacity.
- Processor Speed.
- Processor Make.
- Price .
- Quantity of the Computers.

This class contains following methods,
- Constructor method that assigns user input values to above
mentioned variables.

- main ( ) method that creates array of 4 objects of Computer
class and that takes input for all above details from the user and
calls method to check validity of Quantity and Price values.
If all values are valid then create the objects and display the details
for all 4 toys.

- Method that checks validity of quantity and price.
If the quantity is 0 or negative then method should throw user defined
exception with appropriate message and come out of program.
Similarly if the price is 0 or negative then it should throw user defined
exception with appropriate message and come out of program.

- Method that displays all details about a single instance of Computer in the

Computer Name : IBM
RAM Size : 512 MB
Processor Make : Intel
Processor speed : 300
Quantity : 50
Total Price of Computers : 150,0000/-


View Answers

April 27, 2010 at 11:50 AM

Hi Friend,

Try the following code:

import java.util.*;
import java.text.*;

public class Computer{
String name;
int size;
int speed;
String make;
double price;
double quantity;

DecimalFormat f = new DecimalFormat("##,###");
public Computer(String n,int s,int sp,String m,double p,double q){;
public void valid(){
System.out.println("Please enter valid price");
else if((quantity==0)||(quantity<0)){
System.out.println("Please enter valid quantity ");
public void displayData(){
StringBuffer buff = new StringBuffer();
buff.append("Computer Name : "+name);
buff.append("\nRAM Size : "+size);
buff.append("\nProcessor Make : "+make);
buff.append("\nProcessor speed : "+speed);
buff.append("\nQuantity : "+quantity);
buff.append("\nTotal Price of Computers : "+f.format(quantity * price));
public static void main(String[]args){
String name;
int size;
int speed;
String make;
double price;
double quantity;
System.out.println("Enter details");
Computer data[]=new Computer[2];
Scanner input=new Scanner(;
for(int i=0;i<2;i++){
System.out.print("Computer Name: ");;
System.out.print("RAM Size: ");
System.out.print("Processor Speed: ");
System.out.print("Processor Make: ");;
System.out.print("nQuantity: ");
System.out.print("Price: ");
Computer c=new Computer(name,size,speed,make,price,quantity);
for(int i=0;i<2;i++){

Hope that it will be helpful for you.

Related Tutorials/Questions & Answers:
computer configuration - Java Beginners
computer configuration  someone posted a code but tha is not working... a working code Create a class Computer that stores information about... about a single computer is, - Company Name - RAM size. - Hard Disk Capacity
Computer Networks
Computer Networks  The IPV4 packet has arrived wtih first few hexadecimal digits as 0X45000028000100000102. How many hopes will this packet travel before being dropped
invalid configuration
configuration Exception in thread "main" java.lang.ExceptionInInitializerError... configuration at org.hibernate.cfg.Configuration.doConfigure(
computer science
computer science  Objective:Work with hash tables by creating a hash table using linear probing. I need this code in java. "" Description:Create a generic class called LinearProbingHashTable<K,V>
MySQL Configuration
MySQL Configuration      ... . The mysql configuration is included with The mysql 5.0 server and mysql also available for only window users. Introduction of configuration wizard The MySQL
Computer Networking
Computer Networking   ... a commercial activity where you were using a computer along with a printer... the sharing and exchanging facilities among the computer machines is called
Configure the configuration file
Configure the configuration file  How do I configure the configuration file
configuration files are used in Struts
configuration files are used in Struts  What configuration files are used in Struts
Computer Terminology Bug
Computer Terminology Bug  What is mean by bug in computer terminology
Computer Terminology Bug
Computer Terminology Bug  What is mean by bug in computer terminology
basic function of computer system
basic function of computer system  What is the basic function of computer system
Define computer software.
Define computer software.  How to define a computer software?   A computer software is a set of instruction that tell the computer what to do
Form Tag library configuration
In this section, you will learn about Spring form tag library and its configuration
Action Configuration - Struts
Action Configuration  I need a code for struts action configuration in XML
Computer forensic application
Computer forensic application  how to write computer forensic application using java for recovering deleted files and deleted partitions
configuration files - Java Beginners
configuration files  i have to use configuration file in my program "listing of number of files and their modified time of directory",but problem... by user, tell me what exactly is this configuration file , what are its uses and how
Hibernate dialect configuration
Hibernate dialect configuration  How to configure hibernate dialect in the Hibernate configuration file? Thanks
Steps to log4j configuration in Struts2
Steps to log4j configuration in Struts2  Hi... any tel me each step for configure log4j in struts2 application
Computer shop mangerment
Computer shop mangerment   Part A You are supposed to write a class Computer to stores the computer id, description, brand, price, speed and another... of it. Part B Develop array based java program to help a local computer shop
MySQL Configuration
MySQL Configuration      ... . The MySQL server configuration normally started during  installation process .  MySQL server configuration wizard window  The MySQL configuration wizard
Connected Limited Device Configuration
Connected Limited Device Configuration  (Q) One of the most common... the J2ME, is the Connected Limited Device Configuration. What type of device is this most suitable for, what are main limitations of this configuration and what
computer manufacture case study
computer manufacture case study  Computer Manufacturer Case Study BNM is an upcoming computer manufacturer. The company was making a mark... with standard configuration and Windows 7 as OS. The customers can also go
List of Computer Software
List of Computer Software  Hi, I am looking for the list of Computer programming languages. Provide me the list of Computer Software used these days... for different purposes. See the List of Computer software. Thanks
xml configuration file - JDBC
xml configuration file  Hi, Could you please tell me how to write a xml configuration file . We have mysql database in some other system. I have to access the data from different system. For this jdbc connectivity how
The input device used by computer is
The input device used by computer is  The input device used by computer is 1. Motherboard 2. Central Processing Unit 3. Keyboard 4. System Unit 5. All of the above   Answer: 2. Central Processing Unit
a computer network is referred as
a computer network is referred as  The structure of interconnecting of nodes of --- a computer network is referred as 1. Network topology 2. Internet 3. Local Area network 4. Wide Area network 5. All of these   Answer
computer - Swing AWT
computer  What is a Computer and why we should use it? I am new to this technologies so please let me know the benefits of using computer.   What you what to know about computers?Is it a software or hardware related
JDBC Configuration in Ubuntu 10.04
JDBC Configuration in Ubuntu 10.04  Hi everybody, Am using Linux Ubuntu 10.04, java jdk 1.6 and mysql 5.1 and I have trouble to load mysql connector and i have no such driver found for pleas guide me to solve
@configuration annotation in Spring 3
@configuration annotation in Spring 3  doesn't make code tight coupling..? if we keep that in IOC in XML form, its deployment free for some kind of change management right?.   Please visit the following link: http
Could not parse configuration: hibernate.cfg.xml
Could not parse configuration: hibernate.cfg.xml  Hi, I am getting... configuration: hibernate.cfg.xml at org.hibernate.cfg.Configuration.doConfigure... version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration
Java Spring Hibernate Struts Training Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized


Advertisement null