Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4084468
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:26:36+00:00 2026-05-20T18:26:36+00:00

I am trying to terminate a program if the if statement returns that the

  • 0

I am trying to terminate a program if the if statement returns that the file does not exist. At the moment the method is

public static void calcMarks() 
  {
      String Assessment1 = null, Assessment2 = null, Assessment3 = null;
      int mark1 = 0,mark2 = 0,mark3 = 0,sum = 0;
       try {
       File doc = new File ("marks.txt");
       if(!doc.exists())
       {
        System.out.println ("Marks.txt Does Not Exist");
        System.exit(); 
       }
       if(!marks.exists())
       {
         System.out.println ("TotalMarks.txt Does Not Exist");
         System.exit(); 
       }
       Scanner input = new Scanner(doc);
         while (input.hasNext()){
          Assessment1 = input.next();
          mark1 = input.nextInt();
          Assessment2 = input.next();
          mark2 = input.nextInt();
          Assessment3 = input.next();
          mark3 = input.nextInt();

        }  
      input.close();
      sum = mark1 + mark2 + mark3;
      System.out.println(Assessment1 + " "  +mark1  +"\n"+  Assessment2  + " "+mark2 +"\n"+  Assessment3  + " "+mark3+ "\n" + "Total" +""+ "=" + sum);
    }
    catch (FileNotFoundException ex) {
      System.err.println("File has not been found");
    } 

     }

but on the System.exit(); is the if statement, I get the error exit(int) in Jaba.lang.system. cannot be applied to ()

I have no idea what that means

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:26:37+00:00Added an answer on May 20, 2026 at 6:26 pm

    You need to pass the return value in the exit() method.
    Optimally, you should have System.exit( 0 );.

    You can read this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement a server-client socket program in Java that can support multiple
I have a program (that I did not write) which is not designed to
I have a program that I'm trying to distribute with py2app. When I run
I've been trying to write a program in C++ that will monitor running processes
Source class Program { static void Main(string[] args) { var fw = new FileSystemWatcher(@M:\Videos\Unsorted);
I was wondering if I have a program that creates another process, does that
I am trying to call terminate function. [I think this function gets called when
I'm trying to write a program which, at some point, needs to invoke an
I have the following JavaScript program saved in a file pre.js : var pre
I'm currently using a loop that repeats itself every few milliseconds in my program.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.