1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Anna [14]
2 years ago
8

Consider the following method:

Computers and Technology
2 answers:
Katen [24]2 years ago
8 0

Answer:

See explaination

Explanation:

public class Main {

public static void main(String[] args) {

//execution starts from here so initializing the try block for erros

try{

Scanner keyboard = new Scanner(System.in);

System.out.print("Please enter a file name: ");

String name = keyboard.next();

//the line below throws file not found exception if the given file name is not found or unable to open

Scanner file = new Scanner(new File(name));

String line = file.nextLine();

int n = file.nextInt();

//the below print line function call throws ParameterNotAllowedException if n is zero

printLine(line, n);

}//all Exceptions potentially thrown

catch(InputMismatchException e){

System.out.println("User input type mismatch\n"+e);

}catch(FileNotFoundException e){

System.out.println("Given file name is wrong or does not match");

}catch(ParameterNotAllowedException e){

System.out.println("The n given to printLine must be more than zero");

}catch(IOException ex){

System.err.println("An IOException was caught!");

}

}

//method from above goes here.

public static void printLine(String line, int numberOfTimes) throws Exception {

if (numberOfTimes <=0)

throw new ParameterNotAllowedException("Error. invalid parameter.",numberOFTimes);

for( int i=0; i<numberOfTimes; i++)

System.out.println(line);

}

}

For the user written custom Exception ParameterNotAllowedException. We need to add an exceptional class.

Which is missing from the given info:

class ParameterNotAllowedException extends Exception

{

public ParameterNotAllowedException(String s,int n)

{

// Call constructor of parent Exception

super(s);

}

}

belka [17]2 years ago
5 0

Answer:

Check the explanation

Explanation:

public class Main {

public static void main(String[] args) {

//execution starts from here so initializing the try block for errors

try{

Scanner keyboard = new Scanner(System.in);

System.out.print("Please enter a file name: ");

String name = keyboard.next();

//the line below throws file not found exception if the given file name is not found or unable to open

Scanner file = new Scanner(new File(name));

String line = file.nextLine();

int n = file.nextInt();

//the below print line function call throws ParameterNotAllowedException if n is zero

printLine(line, n);

}//all Exceptions potentially thrown

catch(InputMismatchException e){

System.out.println("User input type mismatch\n"+e);

}catch(FileNotFoundException e){

System.out.println("Given file name is wrong or does not match");

}catch(ParameterNotAllowedException e){

System.out.println("The n given to printLine must be more than zero");

}catch(IOException ex){

System.err.println("An IOException was caught!");

}

}

//method from above goes here.

public static void printLine(String line, int numberOfTimes) throws Exception {

if (numberOfTimes <=0)

throw new ParameterNotAllowedException("Error. invalid parameter.",numberOFTimes);

for( int i=0; i<numberOfTimes; i++)

System.out.println(line);

}

}

For the user written custom Exception ParameterNotAllowedException. We need to add an exceptional class.

Which is missing from the given info:

class ParameterNotAllowedException extends Exception

{

public ParameterNotAllowedException(String s,int n)

{

// Call constructor of parent Exception

super(s);

}

}

You might be interested in
_______________________ is a short-term program, typically 30 hours long, in which a therapist, social worker, or trained probat
Semenov [28]

Answer:

Functional Family Therapy

Explanation:

According to my research on different types of therapies, I can say that based on the information provided within the question the therapy being described in this scenario is called Functional Family Therapy. This is a type of therapy aimed at young teens roughly aged 11-18 who are exhibiting violent or negative behaviors and/or substance abuse. The therapist sits down with the child, their parents, and sometimes an officer of the law in order to get to the root of the problem and come up with different solutions that may help the child feel less angry and prone to act out.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

3 0
3 years ago
Write a for loop that computes the following sum: 5+10+15+20+...+485+490+495+500. The sum should be placed in a variable sum tha
Strike441 [17]

Answer:

public class num9 {

   public static void main(String[] args) {

       int sum =0;

       int num =5;

       for(num =5; num<=500; num+=5){

           System.out.println(num);

           sum +=num;

       }

       System.out.println(sum);

   }

}

Explanation:

  • Declare and initialize the variables sum and num
  • Use a for loop with the condition for(num =5; num<=500; num+=5) Since the loop will increment by 5 and run from 5 to 500
  • Within the loop, add num to sum at each iteration
  • Print all elements on seperate lines
  • Outside the loop, print the final value of sum

Create a for loop

6 0
2 years ago
How fast is a backwards long jump in Super Mario 64?
Kamila [148]

Answer:

I honestly don't know if you're being serious or not as this was a popular thing a few years ago, there are a few videos on yt, one particularly from 2008 that answers your question pretty well.

Clipping through a loading area requires at least 400 speed. But if you're just interested in the usual speed, there are multiple glitches to make him go faster than his usual x3.5 increased running speed (which is the speed you get at the LEAST when BLJing) but it seems the average is  -200. I've seen people get up to -900 though, so.

Basically, it can vary. In a very specific area he can get max momentum of -9373, which is probably the fastest even though it's against a wall.

6 0
2 years ago
What are some signs that could help you determine that a date and time was inserted as a special object instead of
Jlenok [28]

Answer:

i) It is difficult to put the mouse pointer's insertion point in the text

ii) A gray border appear around the time and date when you point to it

Explanation:

When the date and time is pointed to or hovered using the mouse pointer, we have, that the background of the text changes to a grey border around the text when the date and time is inserted as a special object using the insert date and time button on the insert menu in the word processing application

The mouse pointer behaves different when working with some applications, and it could be difficult to place the insertion point of the mouse pointer in the  text

Therefore, the correct options are;

<em>It is difficult to put the mouse pointer's insertion point in the text and</em>

<em>A gray border appear around the time and date when you point to it.</em>

3 0
2 years ago
Anyone help pls ? Complete the code below to add css to make the background of the web page orange.
pochemuha

Answer:

In HTML file

<body style="background-color:orange;">

Or

In CSS file

body {

background-color: orange;

}

7 0
3 years ago
Other questions:
  • When you send an echo request message with the ping program, a successful attempt will return a(n) ______ message.
    8·1 answer
  • ____________________ is the premeditated, politically motivated attacks against information, computer systems, computer programs
    6·2 answers
  • 12. Noodle Tools is a website that
    8·1 answer
  • What Will Social Media Look Like in the Future?
    6·1 answer
  • What is the difference between a design pattern and a DLL?
    12·1 answer
  • Which of the following lists contains the five essential elements of a computer? Group of answer choices: 1. inputs, returns, pr
    11·1 answer
  • What read a page on website​
    15·1 answer
  • You can open a movie maker project file any time in a media player. (1 point) true false
    6·1 answer
  • Type the correct answer in the box. Spell all words correctly. Kenny is designing a document for the employee motivation campaig
    8·1 answer
  • Data security issues that must be addressed by hipaa implementation teams include:__________
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!