Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-02-2008, 01:03 PM
Member
 
Join Date: May 2008
Posts: 2
Rep Power: 0
Poor Bee is on a distinguished road
Unhappy Help please :(
Am new to java
I have a question in creating an application to declare a class called “Vehicle"
with these required details :
-Instance Member variables: VehicleNo, ModelYear, ModelName, BasicPrice, Tax
-Instance Member functions: GetValues, CalculatePrice and PrintValues.
-All the variables can be declared as private and methods can be declared as public in visibility control.
-Description for the instance member functions:
  1. GetValues() method should assign values for the member variables VehicleNo, ModelYear, ModelName ,BasicPrice and Tax,
  2. CalculatePrice() method should calculate the NetPrice as the sum of the BasicPrice and Tax.
  3. PrintValues() method should display the value of the member variables and NetPrice.

(You are required to choose the correct data type for member variables and signature for methods)

Create your main class with name Question1. The main method, you should create 2 objects of Vehicle class by using default constructor. You are required to use GetValues() method to pass the values for member variables of Vehicle class. You are then required to call the two methods (CalculatePrice(), Printvalues()) to calculate NetPrice and to display the value of member variables and NetPrice for each of the objects created.


........................

I tried to create it but there were LOTS of errors .. am bad in java
public class Vehicle
{

private int VehicleNo;
private char ModelYear;
private char ModelName;
private int BasicPrice;
private int Tax;
public void GetValues( int V,char M,char Mo,int B,int T);
{

VehicleNo=V;
ModelYear=M;
ModelName=Mo;
BasicPrice=B;
Tax=T;
}

int CalculatePrice();
{
int NetPrice;
Netprice=BasicPrice+Tax;
return(NetPrice);
}
}


.....

anyone can help ??
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 05-02-2008, 01:08 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Nice attempt pal.

Ok, what error you get there?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-02-2008, 01:10 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Code:
public void GetValues( int V,char M,char Mo,int B,int T);
This is wrong pal. Declaring a method in wrong way. Method not ending with a ; sign. It's used to terminate a statement.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-02-2008, 01:13 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
You have to learn a lot pal.

Code:
public class Vehicle {
    private int VehicleNo;
    private char ModelYear;
    private char ModelName;
    private int BasicPrice;
    private int Tax;
    
    public void GetValues( int V,char M,char Mo,int B,int T) {
        VehicleNo = V;
        ModelYear = M;
        ModelName = Mo;
        BasicPrice = B;
        Tax = T;
    }
    
    public int CalculatePrice() {
        return ( BasicPrice + Tax);
    }
}
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +2. The time now is 10:20 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org