Results 1 to 6 of 6
Thread: Java help! cannot find symbol
- 02-15-2012, 06:03 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 13
- Rep Power
- 0
Java help! cannot find symbol
Hi!..im getting cannot find symbol when i try to compile the file and it gives 7 errors...not sure what i am doing wrong...please help me
HealthProfileTest.java:41: cannot find symbol
symbol : variable Convert
location: class HealthProfileTest
double pHeight = Convert.ToDouble(in.nextLine());
Java Code:import java.util.Scanner; import javax.swing.*; public class HealthProfileTest { public static void main(String[] args) { // Welcome message Scanner in = new Scanner(System.in); System.out.println("Welcome to the Health Profile!"); System.out.println("Please enter your information when prompted.\n"); // Promt and obtain user input System.out.println("First name: "); String fName = in.nextLine(); System.out.println("Last name: "); String lName = in.nextLine(); System.out.println("Gender: "); String pGender = in.nextLine(); System.out.println("Year of birth: "); int year = Convert.ToInt32(in.nextLine()); System.out.println("Month of birth: "); int month = Convert.ToInt32(in.nextLine()); System.out.println("Day of birth: "); int day = Convert.ToInt32(in.nextLine()); System.out.println("Height in meters: "); double pHeight = Convert.ToDouble(in.nextLine()); System.out.println("Weight in kilos: "); double pWeight = Convert.ToDouble(in.nextLine()); // Create a HealthProfile object HealthProfile myHealthProfile = new HealthProfile(fName, lName, pGender, year, month, day, pHeight, pWeight); // Print the information from object myHealthProfile System.out.println("\nInformation inserted to your health profile:"); System.out.println("Name: \t\t\t{0} {1}", myHealthProfile.FirstName, myHealthProfile.LastName); System.out.println("Gender: \t\t{0}", myHealthProfile.Gender); System.out.println("Date of birth: \t\t{0}-{1:00}-{2:00}", myHealthProfile.BirthYear, myHealthProfile.BirthMonth, myHealthProfile.BirthDay); System.out.println("Height: \t\t{0}", myHealthProfile.Height); System.out.println("Weight: \t\t{0}", myHealthProfile.Weight); // Call method PersonAge to calculate the persons age System.out.println("\nWe will now print out your age, BMI, maximum heart " + "rate \nand target heart rate range:"); System.out.println("Your age: \t\t\t{0}", myHealthProfile.PersonAge()); System.out.println("Your BMI: \t\t\t{0}", myHealthProfile.BodyMassIndex()); System.out.println("Your maximum heart rate: \t{0}", myHealthProfile.MaxRate()); System.out.println("Your target heart rate range: \t{0} to {1}", myHealthProfile.MinTarget(), myHealthProfile.MaxTarget()); System.out.println ("\n\nBMI VALUES\nUnderweight:\tless than 18.5\nNormal:\tbetween 18.5 and 24.9"); System.out.println ("\nUnderweight:\tless than 18.5"); System.out.println ("Normal:\t\tbetween 18.5 and 24.9"); System.out.println("Overweight:\tbetween 25 and 29.9"); System.out.println ("Obese:\t\tbetween 30 or greater"); } }
- 02-15-2012, 06:17 PM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: Java help! cannot find symbol
Where is Convert defined?
It's not in this class, or any import...
- 02-15-2012, 06:25 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 13
- Rep Power
- 0
Re: Java help! cannot find symbol
so you are saying that Im missing Convert in here ??? not sure what you mean
- 02-15-2012, 06:29 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: Java help! cannot find symbol
You can't just make up things in Java.
A Convert class or a variable called Convert that is of a class that has the methods you are calling needs to exist.
So, where is it?
That's what the compiler is asking.
- 02-15-2012, 06:37 PM #5
Member
- Join Date
- Feb 2012
- Posts
- 13
- Rep Power
- 0
Re: Java help! cannot find symbol
it is right here
int year = Convert.ToInt32(in.nextLine());
-
Re: Java help! cannot find symbol
No, it's not. You're trying to use a Convert class in that line, but this does not mean that you have a Convert class to use somewhere. Again, you can't make stuff up and hope it will work. You either are missing some library from your instructor or your assumptions on how Java works are way off and you'll need to check out the introductory tutorials.
Similar Threads
-
cannot find symbol, (java:5)
By simco99 in forum New To JavaReplies: 2Last Post: 01-18-2012, 08:26 PM -
FileRead.java:79: cannot find symbol
By xx__rose in forum New To JavaReplies: 1Last Post: 05-09-2010, 04:06 AM -
java:34:cannot find symbol
By MissyMadi in forum New To JavaReplies: 5Last Post: 11-09-2008, 06:53 PM -
cannot find symbol symbol :constructor Error. Please help! =(
By KalEl in forum New To JavaReplies: 9Last Post: 10-18-2008, 08:26 PM -
cannot find symbol symbol : class Item location: package platypos.services.order
By officialhopsof in forum New To JavaReplies: 3Last Post: 05-01-2008, 08:30 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks