Hi, can some one please help me run this code. i have another class named Course, that complied without error. Now in this code i am trying to take user inputs to find resulting gpa in a course. the following code does not compile, please help.

import java.util.*;
import javax.swing.*;

public class Result{

   ArrayList courseResult;

   
   //constructor
 public Result(courseResult cr)
    {
      courseResult= cr;
    }// end of constructor
   
   public void addCourse(){

   String name =JOptionPane.showInputDialog("Enter name of course: ");
          //downcast all strings into int float etc
   String inputMarks =JOptionPane.showInputDialog("Enter course marks: ");
           int marks = Integer.parseInt(inputMarks);
   String inputcHr =JOptionPane.showInputDialog("Enter course credit hours: ");
      int creditHr =Integer.parseInt(inputcHr);
   }


      Course c1 = new Course(name, marks, creditHr);
      courseResult.add(Course c1);
 
} //end of class

Here

String name =JOptionPane.showInputDialog("Enter name of course: ");
          //downcast all strings into int float etc
   String inputMarks =JOptionPane.showInputDialog("Enter course marks: ");
           int marks = Integer.parseInt(inputMarks);
   String inputcHr =JOptionPane.showInputDialog("Enter course credit hours: ");
      int creditHr =Integer.parseInt(inputcHr);
   }


      Course c1 = new Course(name, marks, creditHr);
      courseResult.add(Course c1);

I assume you meant

String name =JOptionPane.showInputDialog("Enter name of course: ");
          //downcast all strings into int float etc
   String inputMarks =JOptionPane.showInputDialog("Enter course marks: ");
           int marks = Integer.parseInt(inputMarks);
   String inputcHr =JOptionPane.showInputDialog("Enter course credit hours: ");
      int creditHr =Integer.parseInt(inputcHr);


      Course c1 = new Course(name, marks, creditHr);
      courseResult.add(c1);
   }

not the move of the "}" character, and the change of the add method (which would have produced a different error after you resolved the error with the "}" symbol).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.