Results 1 to 3 of 3
  1. #1
    Based Elliott is offline Member
    Join Date
    Mar 2014
    Posts
    11
    Rep Power
    0

    Default Need Help - Code Not Working

    Hello there, I'm quite new to learning java and I just wrote this to try and test out what I've learned. It works perfectly in the Eclipse console but after compiling it and running it I get this:

    Need Help - Code Not Working-nfmjjn.png

    Here is the code:
    Java Code:
    import java.util.Scanner;
    public class Formula {
    	
    	static Scanner sc = new Scanner(System.in);
    	
    	public static void main(String[] args) {
    		double a; 
    		double b;
    		double c;
    		
    		System.out.print("Type a value for A: "); 
    		a = sc.nextDouble();
    		System.out.print("Type a value for B: ");
    		b = sc.nextDouble(); 
    		System.out.print("Type a value for C: ");
    		c = sc.nextDouble();
    		
    		double part1 = b * (-1);
    		double part2 = (b * b) - (4 * a * c);
    		double part3 = Math.sqrt(part2);
    		double half = (part1 - part3) / (2 * a);
    		double otherHalf = (part1 + part3) / (2 * a);
    		
    		System.out.print("The solutions are " + half + "and " + otherHalf);
    		
    	}
    
    }
    Last edited by Based Elliott; 03-05-2014 at 01:17 AM.

  2. #2
    Kucerakjm is offline Member
    Join Date
    Mar 2014
    Posts
    1
    Rep Power
    0

    Default Re: Need Help - Code Not Working

    Your code is fine, your command is not due to the input being case sensitive.

  3. #3
    Based Elliott is offline Member
    Join Date
    Mar 2014
    Posts
    11
    Rep Power
    0

Similar Threads

  1. non working code :S
    By walsby14 in forum New To Java
    Replies: 6
    Last Post: 07-17-2012, 09:52 PM
  2. Working On Code
    By maximumammo in forum New To Java
    Replies: 6
    Last Post: 04-04-2012, 05:11 PM
  3. Replies: 1
    Last Post: 03-25-2012, 04:40 AM
  4. Replies: 2
    Last Post: 01-04-2011, 05:30 AM
  5. JNI: Why this code not working?
    By playwin2 in forum Advanced Java
    Replies: 5
    Last Post: 11-25-2008, 02:12 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •