Results 1 to 4 of 4
 03262009, 10:10 AM #1Member
 Join Date
 Mar 2009
 Posts
 1
 Rep Power
 0
Errors in Program (Right Triangle)
hey everyone, new to Java but I'm really really enjoying it. I'm having some issues though, and I know they are probably silly ones, but I cant seem to figure out how to fix it.
The book im using to learn gives examples of TerminalIO, but I've been using java.util.scanner. Below is a program that when entering three side lengths will tell you if the triangle is a right triangle. Here is my program:
Java Code:import java.util.Scanner; //===================================================================== public class project4_2 { //===================================================================== private static Scanner keyboard = new Scanner (System.in); //INPUT============================================================= //=============================================================== private static void main (String[] args){ double side1, side2, side3; //User Input System.out.println(" "); side1 = reader.readDouble("Enter First Side Length: "); side2 = reader.readDouble("Enter Second Side Length: "); side3 = reader.readDouble("Enter Third Side Length: "); //Compute findSideOrder(side1, side2, side3); } //PROCESSING/OUTPUT================================================= //=============================================================== private static double findSideOrder(double side1, double side2, double side3);{ if ((side1 * side1) + (side2 * side2) = (side3 * side3)) System.out.println("The Triangle is a Right Triangle"); else if ((side2 * side2) + (side3 * side3) = (side1 * side1)) System.out.println("The Triangle is a Right Triangle"); else if ((side1 * side1) + (side3 * side3) = (side2 * side2)) System.out.println("The Triangle is a Right Triangle"); else System.out.println("The Triangle is Not a Right Triangle"); } }
the error i am receiving is...
project4_2.java:15: cannot find symbol
symbol : method readDouble(java.lang.String)
location: class java.util.ScannerLast edited by SupaStudy; 03262009 at 10:16 AM. Reason: put program in code brackets
 03262009, 10:21 AM #2Member
 Join Date
 Feb 2009
 Posts
 22
 Rep Power
 0
There is no method readDouble in java.util.Scanner.
U can go for nextDouble() instead
 03262009, 10:39 AM #3Member
 Join Date
 Mar 2009
 Posts
 13
 Rep Power
 0
You should be writing the code like:
Java Code:import java.util.Scanner; //===================================================================== public class project4_2 { //===================================================================== private static Scanner reader = new Scanner (System.in); public static void main (String[] args){ double side1, side2, side3; //User Input System.out.println("Enter First Side "); side1 = reader.nextDouble(); System.out.println("Enter Second Side "); side2 = reader.nextDouble(); System.out.println("Enter Third Side "); side3 = reader.nextDouble(); //Compute findSideOrder(side1, side2, side3); } //PROCESSING/OUTPUT================================================= //=============================================================== private static void findSideOrder(double side1, double side2, double side3){ if ((Math.pow(side1, 2) + Math.pow(side2, 2)) == Math.pow(side3, 2)) System.out.println("The Triangle is a Right Triangle"); else if ((Math.pow(side3, 2) + Math.pow(side2, 2)) == Math.pow(side1, 2)) System.out.println("The Triangle is a Right Triangle"); else if ((Math.pow(side3, 2) + Math.pow(side1, 2)) == Math.pow(side2, 2)) System.out.println("The Triangle is a Right Triangle"); else System.out.println("The Triangle is Not a Right Triangle"); } }
 03262009, 10:42 AM #4Member
 Join Date
 Mar 2009
 Posts
 13
 Rep Power
 0
Similar Threads

What is the difference between Semantic Errors and Logical Errors?
By tlau3128 in forum New To JavaReplies: 3Last Post: 03082009, 01:51 AM 
Debuggin help  simple program nonstatic method errors
By RR_QQ in forum New To JavaReplies: 5Last Post: 02042009, 01:20 AM 
Triangle Sides program
By jamesov89 in forum New To JavaReplies: 6Last Post: 10062008, 03:36 AM 
Help with Errors in Inventory Program
By ljk8950 in forum AWT / SwingReplies: 3Last Post: 08082008, 11:49 PM 
3 errors and then terminate program
By hezfast2 in forum New To JavaReplies: 2Last Post: 05202008, 01:57 AM
Bookmarks