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]
3 years ago
8

Consider the following method:

Computers and Technology
2 answers:
Katen [24]3 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]3 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
Please Help ASAP!!
Maurinko [17]

Answer:

in the page layout view

Explanation:

7 0
3 years ago
Read 2 more answers
Complete function PrintPopcornTime(), with int parameter bagOunces, and void return type. If bagOunces is less than 2, print "To
Ludmilka [50]

Answer:

#include <iostream>

using namespace std;

void PrintPopcornTime (int bagOunces){

   if (bagOunces < 2){

       cout << "Too small"<<endl;

   }

   else if (bagOunces > 10){

       cout << "Too large"<<endl;

   }

   else{

       cout << bagOunces*6 <<" seconds"<<endl;

   }

}

int main(){

   PrintPopcornTime(7);

   

   return 0;

}

Explanation:

Create a function called PrintPopcornTime that takes one parameter, bagOunces

Check the bagOunces using if-else structure. If it is smaller than 2, print "Too small". If it is greater than 10, print "Too large". Otherwise, calculate and print 6*bagOunces followed by " seconds".

Call the function in the main function with parameter 7. Since 7 is not smaller than 2 or not greater than 10, "42 seconds" will be printed.

4 0
3 years ago
"Which hash algorithm's primary design feature is two different and independent parallel chains of computation, the results of w
Galina-37 [17]

Answer:

Option C i.e., RIPEMD is the correct option for the following question.

Explanation:

Because RIPEMD is the algorithm that is used for the hash primary design characteristic which has two independent and unlike parallel chains of the calculation and computation and the outputs of which are then linked to the process at the end. It is also used for the safe process of replacing the 128-bit hash method.

Other options are wrong because these are not related to the following statement.

5 0
3 years ago
Directions: Fill in the blanks with the appropriate word in each statement below.
mart [117]

Answer:

sbysgscd CD CD vdhdudiididjehgegeueuheve gf hdgowincobwbciehidgwdgiwigwdigxifqugwljvwvwxi2dvwvwxixwvwxvqvwivqi

xwv2digwxivwiw

wxvixbowowxowcohwco2ch2od

odhowhowcowcohwxohwdowdjeciwr

hiwdodwobwdvqoo230ie

9qhowwdhwdigwdoieexohxiefbeoc

hwdhefgdegedogex

Explanation:

9hwx9hex9hexobeb8xgx9jcr

jd2oh2ih2xi2dd2oxivqsg8xwohjgwxohdeohwxihwdoeciwxgiweiguofyoe5u5ew46w57lrroyvyreiyfe1ei2ei2idxwdooydyofpiwigpwxwduo1zuo1dif3o4y

2hupv2rxou2xu2du2d

ou1svxiexuowvouqdip2dpwcuowd2u

qxigqedouovqudipgqipwgipcwpi2di2ipegpi2efpi2dipe2ip1dgxip2ce1piecg1peix1ou2co2dpu1ecgip1eip1deg1euouoeupdeuofour68ditsoysrs27ro457uoeigpexupgeip3dpiwdguof<em>o</em><em>y</em><em>i</em><em>y</em><em>y</em><em>i</em><em>d</em><em>i</em><em>y</em><em>u</em><em>f</em><em>u</em><em>o</em><em>u</em><em>o</em><em>d</em><em>y</em><em>i</em><em>d</em><em>y</em><em>o</em><em>u</em><em>o</em><em><u>o</u></em><em><u>u</u></em><em><u>u</u></em><em><u>p</u></em><em><u>w</u></em><em><u>d</u></em><em><u>9</u></em><em><u>d</u></em><em><u>e</u></em><em><u>d</u></em><em><u>i</u></em><em><u>w</u></em><em><u>g</u></em><em><u>i</u></em><em><u>p</u></em><em><u>2</u></em><em><u>s</u></em><em><u>o</u></em><em><u>u</u></em><em><u>2</u></em><em><u>s</u></em><em><u>g</u></em><em><u>9</u></em><em><u>2</u></em><em><u>3</u></em><em><u>u</u></em><em><u>g</u></em><em><u>o</u></em><em><u>1</u></em><em><u>3</u></em><em><u>u</u></em><em><u>e</u></em><em><u>f</u></em><em>c</em><em>i</em><em>d</em><em>y</em><em>i</em><em>d</em><em>5</em><em>7</em><em>g</em><em>d</em><em>q</em><em>i</em><em>g</em><em>e</em><em>o</em><em>b</em><em>x</em><em>r</em><em>i</em><em>1</em><em>e</em><em>i</em><em>y</em><em>f</em><em>2</em><em>i</em><em>p</em><em>e</em><em>c</em><em>h</em><em>k</em><em>c</em><em>y</em><em>i</em><em>d</em><em>o</em><em>u</em><em>x</em><em>t</em><em>u</em><em>x</em><em>u</em><em>o</em><em>c</em><em>z</em><em>i</em><em>y</em><em>c</em><em>y</em><em>i</em><em>y</em><em>y</em><em>i</em><em>y</em><em>i</em><em>y</em><em>2</em><em>i</em><em>d</em><em>y</em><em>i</em><em>g</em><em>x</em><em>y</em><em>i</em><em>y</em><em>i</em>yiydiyyiiyciyc2ouvyidyiyidydyidiyf7uo2vu1e

8 0
3 years ago
Write the ARMv8 instructions for the following c code. Assume that the argumentsare stored in X0 onward in the order they are pr
klio [65]

Answer:

labelAdd:

add x0, x0, x1

mov pc, lr

Explanation:

  • Create a method called labelAdd.
  • Store the result in x0 by adding the value in the registers x0, x1.
  • Return to caller.
3 0
3 years ago
Other questions:
  • Research the disadvantages of the computer and explain them.​
    15·1 answer
  • The programs that provide the infrastructure and hardware control necessary for the computer and its peripheral devices are call
    11·1 answer
  • Which of the following color palettes for the BackColor and ForeColor properties contains colors that are guaranteed to be displ
    8·1 answer
  • Assume that ip , jp , and tp have all been declared to be pointers to int and that result has been declared to be an array of 10
    13·1 answer
  • How to do this PLEASE HELP 80 points!
    15·1 answer
  • Each device attached to your computer comes with a special program called a(n ________ that enables the device and operating sys
    15·1 answer
  • Who watches Riverdale ? if you do can we be friends(pLEASE DON'T DELETE) and also who is your fav character from Riverdale
    8·2 answers
  • In addition to benchmark testing, performance measurements, called _____, can monitor the number of transactions processed in a
    8·1 answer
  • (Print distinct numbers) Write a program that reads in integers separated by a space in one line and displays distinct numbers i
    8·1 answer
  • Jobs that use math and science to solve problems involving the design and development of technologies can be found in the what c
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!