Results 1 to 3 of 3

Thread: Two questions!

  1. #1
    eranmc is offline Member
    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    Default Two questions!

    Hello you guys, I'm new in here.

    1. I need to program a program which receive a number from a user and finds the highest number of prime numbers below a given number. For example 11 is the highest number which is smaller than 13. Have no clue how


    2. I get 4 integer numbers, the first 2 are coefficient and the others are 2 coordinates, I need to find if the given coordinates point is below, on or above y=ax+b, the output should be like that: (x,y) is {below, on, above} the line y=ax+b
    for example the output for: 1, 0, 1, 2 (1,2) is above the line y=1x+0

    This is my FullOfErrors code, how you'll help me:

    public class Ex2 {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt(); // Get coefficient a from user
    int b = sc.nextInt(); // Get coefficient b from user
    int x = sc.nextInt(); // Get coordinates x from user
    int y = sc.nextInt(); // Get coordinates y from user
    if (y == a * x + b){
    System.out.println("("+x+","+y+")" is on the line y=" a+"x+"b);
    else{
    if (y > a * x + b){
    System.out.println("("+x+","+y+")" is above the line y=" a+"x+"b);
    }
    else{
    if (y < a * x + b){
    System.out.println("("+x+","+y+")" is under the line y=" a+"x+"b);
    }
    }
    }


    Thank You!
    Last edited by eranmc; 11-09-2012 at 12:23 AM. Reason: English

  2. #2
    Kagiso is offline Member
    Join Date
    Nov 2012
    Location
    Johannesburg, South Africa
    Posts
    92
    Rep Power
    0

    Default Re: Two questions!

    friend your code is almost fine the only things you got wrong is the placement of your ""signs, try looking at your code again!!!


    jst to make this code look neater I would assign the value of a*x + b to an int variable and remove the curly braces on the if...else

  3. #3
    eranmc is offline Member
    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

Similar Threads

  1. A few GUI questions.
    By Prezza in forum New To Java
    Replies: 2
    Last Post: 10-27-2012, 09:30 PM
  2. Questions about app
    By newProgrammer in forum Android
    Replies: 0
    Last Post: 10-16-2012, 06:42 PM
  3. Questions
    By Csharks in forum New To Java
    Replies: 8
    Last Post: 01-19-2011, 05:11 AM
  4. Some Questions
    By MuslimCoder in forum New To Java
    Replies: 2
    Last Post: 02-25-2009, 05:01 PM
  5. questions for 1yr exp
    By rahaman.athiq in forum Java Servlet
    Replies: 2
    Last Post: 11-26-2008, 02:13 AM

Posting Permissions

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