Im new to java how do i fix these errors

How to fix the 20 errors:

Repl link:

/*made by PrestonCurtis1*/
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        System.out.println("Hello world");
        System.out.println("What is your first name");
        String fname = s.nextLine();
        System.out.println("What is your last name");
        String lname = s.nextLine();
        String fullname = fname + " " + lname;
        System.out.println(fullname + " Enter first point x value");
        double x1 = s.nextDouble();
        System.out.println(fullname + " Enter first point y value");
        double y1 = s.nextDouble();
        System.out.println(fullname + " Enter second point x value");
        double x2 = s.nextDouble();
        System.out.println(fullname + " Enter second point y value");
        double y2 = s.nextDouble();
        double numerator = y2 - y1;
        double denominator = x2 - x1;
        double slope = numerator / denominator;
        System.out.println(fullname +  " your slope is " + slope);


        
        
   
    
    
    }
    
}

ive reduced it down to 1 error

this is happening because

  1. you had an extra curly brace (}) at the bottom
  2. you forgot to import the scanner
    use this:
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        System.out.println("Hello world");
        System.out.println("What is your first name");
        String fname = s.nextLine();
        System.out.println("What is your last name");
        String lname = s.nextLine();
        String fullname = fname + " " + lname;
        System.out.println(fullname + " Enter first point x value");
        double x1 = s.nextDouble();
        System.out.println(fullname + " Enter first point y value");
        double y1 = s.nextDouble();
        System.out.println(fullname + " Enter second point x value");
        double x2 = s.nextDouble();
        System.out.println(fullname + " Enter second point y value");
        double y2 = s.nextDouble();
        double numerator = y2 - y1;
        double denominator = x2 - x1;
        double slope = numerator / denominator;
        System.out.println(fullname +  " your slope is " + slope);
    }
}
2 Likes

thanks @bigminiboss that worked

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.