Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-24-2007, 05:36 PM
zoe zoe is offline
Member
 
Join Date: Jul 2007
Posts: 40
zoe is on a distinguished road
Error: cannot find symbol constructor
Hi, my problem: it says it cannot find symbol constructor BMIndexCalculator (int, double, double) for my application.

i am trying to make an instance of my BMIndexCalculator class and call the start method in my BMIndexCalculatorMain class. Below is the code, maybe someone can help? BMIndex and BMIndexCalculator compile cleanly, just the problem with BMIndexCalculatorMain.
I'm trying to make a body mass index calculator. i really have no idea what to do now.

Class : BMIndexCalculatorMain
Code:
//Description: Makes an instance of the BMIndexCalculator class and contains a start method. */ import javax.swing.*; import java.util.*; import java.text.*; /**define main class & method*/ class BMIndexCalculatorMain { //Main method public static void main (String [] args) { int age; double weight, height; double recWeight; /**Use DecimalFormat to change number of decimal places displayed*/ DecimalFormat df = new DecimalFormat("0"); BMIndexCalculator calc = new BMIndexCalculator (age, weight, height); /**Display input values and computed results using JOptionPane*/ //Displays the results //Convert height in inches to centimeters recWeight = ((height*2.54) - 100) + age%10 * 0.90; JOptionPane.showMessageDialog (null, "The recommended weight for your height and age is: " + df.format(recWeight*2.2) + " lbs"); }}
Class : BMIndexCalculator
Code:
// Description: Does I/O, uses an instance of the BMIndex class, contains a start method. * */ import javax.swing.*; import java.util.*; import java.text.*; /**define main class & method*/ class BMIndexCalculator { //Main method public static void main(String [] args) { /**Get the four input values*/ //Get the four input values int age; double weight, height, bMI; String inputStr; inputStr = JOptionPane.showInputDialog (null, "Enter your Age: "); age = Integer.parseInt(inputStr); inputStr = JOptionPane.showInputDialog (null, "Enter Height (cm): "); height = Double.parseDouble(inputStr); inputStr = JOptionPane.showInputDialog (null, "Enter Weight (lbs): "); weight = Double.parseDouble(inputStr); /**Use DecimalFormat to change number of decimal places displayed*/ DecimalFormat df = new DecimalFormat("0.00"); //convert weight in lbs to weight in kilograms weight = weight * 2.2; //convert height in cm to height in meters height = (height/100); BMIndex calc = new BMIndex (age, weight, height); /**Display input values and computed results using PrintStream*/ //Displays the input values and results bMI= weight/Math.pow(height, 2); System.out.println ("Weight: " + df.format(calc.getWeight()) + " kilograms."); System.out.println ("Height: " + df.format(calc.getHeight()) + " meters"); System.out.println ("BMI: " + bMI * 100); } }
Class : BMIndex
Code:
//Description: Generic BMIndex class that calculates the Body Mass Index and has no I/O. */ import javax.swing.*; import java.text.*; class BMIndex { //Data members /**Data members*/ private int age; private double weight; private double height; //Constructor /**Constructor*/ public BMIndex (int inputage, double inputweight, double inputheight) { setAge (inputage); setWeight(inputweight); setHeight(inputheight); } //Set age /**@param sets age, weight, height*/ public void setAge (int inputage) { age = inputage; } //Set weight public void setWeight(double inputweight) { weight = inputweight; } //Set height public void setHeight (double inputheight) { height = inputheight; } /**@return returns age, weight, height*/ //Return age public int getAge () { return age; } //Return weight public double getWeight () { return weight; } //Returns height public double getHeight () { return height; } }
Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-24-2007, 10:24 PM
Senior Member
 
Join Date: Jul 2007
Posts: 130
cruxblack will become famous soon enough
U didn't create a constructor for this input parameter in ur BMIndexCalculator
Code:
BMIndexCalculator calc = new BMIndexCalculator (age, weight, height);
Btw, why use so many main method?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Cannont find symbol Constructor" error Welsh New To Java 7 01-25-2008 02:12 AM
Programm Error: cannot find symbol Help? junix New To Java 2 12-10-2007 07:30 AM
cannot find symbol class error po0oker New To Java 5 10-31-2007 04:52 PM
Error: cannot find symbol silvia New To Java 1 08-07-2007 07:39 AM
Error: cannot find symbol cachi AWT / Swing 1 08-06-2007 10:12 PM


All times are GMT +3. The time now is 10:55 AM.


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