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
Gekata [30.6K]
3 years ago
11

HELP PLS TIME LIMIT HERE

Computers and Technology
1 answer:
Novosadov [1.4K]3 years ago
7 0
I do it immediately, so it don’t effect my assignments or grades.
You might be interested in
Create a brief program that demonstrates use of a Java exception. For example, you could use InputMismatchException and ask the
HACTEHA [7]

Answer:

Here is the program that demonstrates the use of JAVA exception:

import java.util.Scanner;  //to accept input from user

public class Main {  //class name

   public static void main(String[] args) {  //start of main method

      Scanner input = new java.util.Scanner(System.in);  //creates Scanner class object to accept input from user

       int number1 = 0;  //stores the first integer value

       int number2 = 0;  //stores the second integer value

       while(true) {  //keeps looping until user enters integer value

           System.out.println("Enter 2 integers to perform addition: "); //prompts user to enter two integer values

           try {  //defines a chunk of code to check for errors        

               number1 = input.nextInt(); //reads input integer 1

               number2 = input.nextInt(); //reads input integer 2                  

               break;             }  

           catch (java.util.InputMismatchException e) { // defines a code chunk to execute if an error occurs in the try code chunk

              System.out.println("Input must be an integer "); //displays this message if user enters anything other than an integer value

              input.nextLine();              }         }  // reads input from user again until user enters both integer type values

       System.out.println("The sum is: " + (number1+number2));      }  } //if user enters 2 integers then computes and displays the sum of two integer values

Explanation:

The program uses InputMismatchException exception and asks the user to input two integers and computes the sum of two integers if user enters  integers otherwise an exception InputMismatchException is thrown and a error message Input must be an integer is displayed to the user if they input a string of letters instead o f integer values. Here while loop is used which keeps executing until user enters both the integer values. After the user enters correct values, the sum of the two integers are computed and result is displayed on output screen. The screenshot of program and its output is attached.

Another program asks the user to input an integer and the program executes correctly if they enter an integer but exception InputMismatchException is thrown with an error message that is is displayed to the user if they input a string of letters. Here is the program:

import java.util.Scanner;

public class Main {

   public static void main(String[] args) {

       Scanner input = new java.util.Scanner(System.in);

       int number1 = 0;          

       while(true) {

           System.out.println("Enter an integer value: ");        

           try {

               number1 = input.nextInt();  

               break;             }  

           catch (java.util.InputMismatchException e) {

              System.out.println("Input must be an integer ");

              input.nextLine();             }        }  

       System.out.println("The program executed correctly!");  } }

7 0
3 years ago
Create your own array of strings. Call the array anything you like as long as it is a valid variable name. The list should conta
Finger [1]

Answer:

alphabets = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

newList = []

N = 3

for i in range(N):

   newList.append(alphabets[i] * 3)

print(newList)

Explanation:

  • Initialize the alphabets.
  • Use a for loop to append three alphabets to new list.
  • Finally print the new list.
5 0
4 years ago
What technology provides secure access to websites
wlad13 [49]

The technology is HTTPS or Hypertext Transfer Protocol Secure

6 0
3 years ago
Read 2 more answers
A circuit is supplied with 30 VDC and contains three resistors connected in series. The value or R1 is 80 , the value of R2 is 1
Llana [10]
One approach to solving this is to first calculate the current the will flow through all three resistors:

The total resistance is R1+R2+R3 = 5280

I = V/R = 30/5280 ≈ 5,682 mA

Then the drop across R2 = I*R2 = 5,7mA * 1000 ≈ 5.682 V.

So this is based on the fact that V=I*R and there is one current running in the entire chain, ie., it is the same through each resistor.
6 0
4 years ago
python (Financial application: compute the future investment value) Write a function that computes a future investment value at
love history [14]

Answer:

def future_investment_value(investment, monthly_interest_rate, years):

   print("Years\tFuture Value")

   print("- - - - - - - - - - -")

   for i in range(1, years+1):

       future_value = investment * ((1 + monthly_interest_rate) ** (12 * i))

       print(i, "\t\t", format(future_value, ".2f"))

investment = float(input("Enter the invesment amount: "))

interest = float(input("Enter the annual interest rate: "))

year = int(input("Enter the year: "))

future_investment_value(investment, interest/1200, year)

Explanation:

Inside the function:

- In the for loop that iterates through the years, calculate the future value using the formula and print the results

Then:

- Ask the user for the investment, annual interest rate, and year

- Call the function with the given inputs

6 0
3 years ago
Other questions:
  • Which of the following can you use to attach external hardware devices to a computer?
    11·2 answers
  • In the output at the command line from a router that reads - ip ospf message-digest-key 1 md5 CISCO-123 - what does the CISCO-12
    15·1 answer
  • Among the rights you have as a user of computing resources is the right to​ _______.
    12·2 answers
  • A wide variety of apps are available to customize devices, which category of app does word processing software falls into?
    10·1 answer
  • Which of the following are agricultural industry clusters? Human population systems, computer technoloy biotechnology or food pr
    9·1 answer
  • Which elements are in the Sort dialog box? Check all that apply.
    9·1 answer
  • 2. A host computer with an IP address of 172.16.29.155 using a subnet mask of 255.255.255.0 and a gateway of 172.16.29.1 pings a
    7·1 answer
  • How many ways do advertisers determine target audiences ??????
    15·1 answer
  • What sort of negative outcomes are possible for this type of risk?
    14·2 answers
  • In what ways are computers being used to improve our quality of life
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!