10.17 LAB: Step counter - exceptions A pedometer treats walking 2,000 steps as walking 1 mile. Write a steps To Miles() method that takes the number of steps as an integer parameter and returns the miles walked as a double. The stepsToMiles() method throws an Exception object with the message "Exception: Negative step count entered." when the number of steps is negative. Complete the main() method that reads the number of steps from a user, calls the stepsToMiles() method, and outputs the returned value from the stepsToMiles () method. Use a try-catch block to catch any Exception object thrown by the steps To Miles() method and output the exception message. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: System.out.printf("%.2f", yourValue); Ex: If the input of the program is: 5345 the output of the program is: 2.67 Ex: If the input of the program is: -3850 the output of the program is: Exception: Negative step count entered.
Q: (b) The following is the state diagram of a Turing machine M1 with inputalphabet {0, 1} and accept…
A: (i) Sequence of configurations of M1 on the input string 01, starting with initial configuration…
Q: Can you help me with this problem because I am struggling, can you explain it step by step in detail…
A: 2. Formulating the Language: USELESS_TMWe can define a language called USELESS_TM that captures this…
Q: Imagine that we have to execute 102 instructions using a 5-stage pipeline architecture…
A:
Q: Start by designing a class called Account. This class contains the following private or hidden data…
A: Pythonclass Account: def __init__(self, acct_num, owner, balance): self.acct_num =…
Q: Test 4: Toy graph, adjacency list (0/2) Test failed!
A: It seems there's a test failure related to a toy graph represented as an adjacency list. Without…
Q: Calculate the technical complexity factor by answering all required questions and carefully stating…
A: F1 Reliable backup and recovery: How critical is it to have a reliable backup and recovery system in…
Q: What does the UPDATE command do in mySQL? Why is it important?
A: The UPDATE command in MySQL is used to modify the existing records in a table. It is one of the most…
Q: Use and discuss one of the hashing tools that can be used in Windows or Kali Linux in MARS. Hashcalc…
A: The question is asking for a detailed explanation of one of the hashing tools that can be used in…
Q: Why is the ability to manipulate data important in MySQL?
A: The ability to manipulate data in MySQL is crucial for several reasons. MySQL is a relational…
Q: The WalkingBoard class represents a board with a figure standing on position x,y. Each position also…
A: The objective of the question is to create a class 'WalkingBoard' in Java that represents a board…
Q: Which action is not necessary for gaining a thorough understanding of a technical text?…
A: The objective of the question is to identify which action is not necessary for gaining a thorough…
Q: Draw the flow graph notation for the code. I need a flow graph that contains a start node and a…
A: The Control Flow Graph (CFG) for the Sieve of Eratosthenes algorithm, as depicted in the diagram,…
Q: Which is not a reason why finding structured data on the Web is difficult? A Websites may use…
A: The question is asking us to identify the statement that is not a reason why finding structured data…
Q: Consider a system with the following specifications: 46-bit virtual address space Page size: 8 KB…
A: Given information:Virtual address space: 46 bitsPage size: 8 KB (which is 2^13 bytes)Page table…
Q: Consider the equation x+x+x+x=50. How many different solutions does this equation have if all the…
A: Step 1:
Q: And code and Input a complete line 10 times using a Scanner and saving the line as a String. The…
A: import java.util.ArrayList; import java.util.Scanner; public class Course { String name;…
Q: I am having trouble creating a turing machine with the question that I need help with, The turing…
A: I can guide you through creating a Turing machine in JFLAP for computing the quotient and remainder…
Q: I am having a hard time with this. Please, provide me with the solution . in C++
A: This is quite a comprehensive project! Let's break it down step-by-step. Part 1: Map ADT using…
Q: With the numbers that are given, please make the graph that is also shown in the picture. Please…
A: To create the graph shown in the picture using MATLAB, we need to first define the data points and…
Q: Show that the graphs contains a Hamiltonian cycle
A: The graph consists of 16 vertices labeled from 'a' to 'p'.Vertices 'a' to 'd' form the outer square…
Q: Please solve the following problem. Quiz = Pass Quiz = Fail AI = Fail 0.1 0.2 AI = Pass…
A: To understand the probability of a student passing the AI course while failing the quiz and the…
Q: Design the pseudocode using arrays for a program. It allows a user to enter 10 numbers, then…
A: The objective of the question is to design a pseudocode that uses arrays to store 10 numbers entered…
Q: operating systems principles Homework. Please help me with question 2, thanks!
A: In order to provide a solution to point 2, which is whether the request of p1 may be granted based…
Q: Draw the parse tree for the following sequence of declarations using the given grammar:…
A: To draw the parse tree for the given sequence of declarations using the specified context-free…
Q: Trying to write SQL statements for these shown here and having issues with them working. Explanation…
A: Let's go through each of the SQL tasks provided in your image one by one, writing the necessary SQL…
Q: Derivate, substitute and present the pattern, where F(0) = 0 and F(1) = 1.
A: Step 1: DERIVATIONStep 2: CHARACTERISTIC EQUATIONStep 3: SOLVE FOR ROOTSStep 4: GENERAL SOLUTIONStep…
Q: b. Problem 2. Again, create an array of 30 random numbers that range between 1 and 100. And again,…
A: The objective of the question is to create a function that uses binary search to find a number in an…
Q: Please assist me with these questions. I need help with creating JavaScript code for the flowcharts…
A: It seems like you're requesting assistance with creating JavaScript code based on provided…
Q: Solve the attached
A: The question is not clear //The answer above is the detailed solution of the given problem…
Q: Algorithm Design: A palindrome is a nonempty string over some alphabet that reads the same forward…
A: Approach to solving the question with detailed explanation: To design an efficient algorithm to find…
Q: 2.7 The "divide and average" method, an old-time method for approximating the square root of any…
A: The objective of the question is to implement the 'divide and average' method for approximating the…
Q: Given the following logic function: F = x’y’z’ + xyz + xy’z + x’yz’ Simplify the logic function.…
A:
Q: e. Problem 5. Devise a function that receives a string and computes how many asterisks are in the…
A: The objective of the question is to create a recursive function that counts the number of asterisks…
Q: What does the INSERT command do in mySQL? Why is it important?
A: The INSERT command in MySQL is used to add new rows of data to a table in a database. It is a…
Q: Answer each of the following questions. You do not need to give the final numeric value. 1. (2.5…
A: 1. To guarantee that there are at least 5 balls of the same color, we need to consider the…
Q: Solve the following queries in SQL. For each query, you need to specify the SQL and show the result…
A: Approach to solving the question:This query uses a combination of filtering and sorting clauses in…
Q: Sectors vs Clusters: Define sectors and clusters in the context of file storage. Discuss the…
A: Detailed Explanation: Sectors:- Sectors are the smallest addressable units on a storage device, such…
Q: Can you Fix this error in the following image Require Import Coq.Lists.List.Import ListNotations.…
A: The corrected code provided includes the necessary imports, definitions, and proofs for a LinkedList…
Q: Please help me with this. Illustrate a total of 3-10 webpages using wireframes. Now the webpage to…
A: Sure, I can help you with that. Here are 3 wireframes depicting a document editor with a wide range…
Q: context and packages Question 3 (2 points) = Listen Which of the following is NOT correct for a…
A: Approach to solving the question: Detailed explanation: Examples: Key…
Q: For a keyword search query with two keywords, a Steiner tree algorithm is not necessary to find the…
A: The objective of the question is to identify an alternative algorithm to the Steiner tree algorithm…
Q: List and explain the three methods that can be used to measure the performance of the network. And…
A: The objective of the question is to understand the three methods that can be used to measure the…
Q: Dynamic Programming: What is the main difference between the Longest Common Subsequence (LCS) and…
A: Main Difference Between LCS and Longest Common SubstringThe main difference between the Longest…
Q: Note: Please refer to the image. As some parts require the use of matlab code and some are…
A: (a) Using the Integral Test to determine convergence:- The series we are considering is: ∑n=1∞n61-…
Q: If we have a mapping to a data source that has not yet been tested which semantics are we likely to…
A: The question is asking about the semantics that are likely to be used for mapping to a data source…
Q: 9. Use a table to express the values of F(x, y, z) = x+yz of these Boolean functions.
A: Step 1: given expression f(x,y,z)=xzˉ+yˉz This Boolean expression incorporates three types of…
Q: Construct the SLR parser for the following grammar. | S → BB BCB/D D→ g Check whether the above set…
A: Given the grammar:S → BB B → cB/D D → g Augmented Grammar:S' → S S → BB B → cB/D D → g Compute…
Q: An experiment is performed and four events (A, B, C, and D) are defined over the set of all possible…
A: Recall that two events are said to be independent if the condition below holds.…
Q: Please do fast and add explanation don't use ai otherwise i give wrong feedback
A: Approach to solving the question:Begin by understanding the concept of the k-d tree data structure,…
Q: Download the PA1-Create-Topology.ps1 file to the C:\Scripts folder. • On you VMHost machine, open…
A: To complete the performance assessment instructions, follow these steps:1. **Plan IP Addressing:**…
Write the full LabProgram.java
Step by step
Solved in 2 steps with 1 images
- Java Foundations: Please provide a basic exception program. Do not use input, output. Write the Java code for the following: Write the InvalidGradeException class that will be used below Write the Java program that reads an integer grade from a user and checks that it is valid (between 0 and 100). If it is invalid an InvalidGradeException will be thrown, stating what the invalid grade is. This will be caught in the main( ) method which will write a message about the invalid grade. If the grade is valid, it is written to the monitor.Subject: Object Oriented PrgrammingLanguage: Java ProgramTopic: Exception Define a new exception, called ExceptionLineTooLong, that prints out the error message "The strings is too long". Write a program that reads phrase and throws an exception of type ExceptionLineTooLong in the case where a string is longer than 80 characters. EXAMPLE: Input:The quick brown fox jumped over the lazy dogs. Output:The quick brown fox jumped over the laze dogs. ANOTHER EXAMPLE: Input:The quick brown fox jumped over the lazy dogs. The quick brown fox jumped over the lazy dogs.The quick brown fox jumped over the lazy dogs. The quick brown fox jumped over the lazy dogs.The quick brown fox jumped over the lazy dogs. The quick brown fox jumped over the lazy dogs.The quick brown fox jumped over the lazy dogs. The quick brown fox jumped over the lazy dogs.The quick brown fox jumped over the lazy dogs. The quick brown fox jumped over the lazy dogs.The quick brown fox jumped over the lazy dogs. The quick…Java Foundations: Please provide a basic exception code. Do not use input, output. Please provide code and explain. Thank you. Write the Java code for the following: Write the InvalidGradeException class that will be used below. Write the Java program that reads an integer grade from a user and checks that it is valid (between 0 and 100). If it is invalid an InvalidGradeException will be thrown, stating what the invalid grade is. This will be caught in the main( ) method which will write a message about the invalid grade. If the grade is valid, it is written to the monitor.
- Write a Month class that holds information about the month. Write exception classes for the following error conditions:• A number less than 1 or greater than 12 is given for the month number.• An invalid string is given for the name of the month.Modify the Month class so that it throws the appropriate exception when either of these errors occurs. Demonstrate the classes in a program.Q1 (Creating Custom Exception Class) Write a Password class that stores a password string. Passwords must contain at least seven alpha-numeric characters, with at least one letter and one digit. Also write an InvalidPasswordException class that extends Exception. The Password constructor should throw an InvalidPasswordException, which should report an appropriate message based on a given string (e.g. if the string contains no digits, the exception should report this fact). Write a GUI program to prompt the user to enter a password and report an InvalidPasswordException if an invalid password is entered. Please teach and help me how to deisgn the program based on the two files given .Some sample screenshots are shown below: InvalidPasswordException.java public class InvalidPasswordException extends Exception{ public InvalidPasswordException (String errMsg){ super(errMsg); } } Password.java public class Password {private String passwordstr; public…JAVA PROGRAM Probloem: Define a new exception, called ExceptionLineTooLong, that prints out the error message "The strings is too long". Write a program that reads phrase and throws an exception of type ExceptionLineTooLong in the case where a string is longer than 80 characters. First Example:Input:The quick brown fox jumped over the lazy dogs.Output:The quick brown fox jumped over the lazy dogs. Second Example:Input: The quick brown fox jumped over the lazy dogs. The quick brown fox jumped over the lazy dogs.The quick brown fox jumped over the lazy dogs. The quick brown fox jumped over the lazy dogs.The quick brown fox jumped over the lazy dogs. The quick brown fox jumped over the lazy dogs.The quick brown fox jumped over the lazy dogs. The quick brown fox jumped over the lazy dogs.The quick brown fox jumped over the lazy dogs. The quick brown fox jumped over the lazy dogs.The quick brown fox jumped over the lazy dogs. The quick brown fox jumped over the lazy dogs.The quick brown…
- Complete the following tasks: Write an exception handler to catch ValueError and output 'float(): Input is not a float.' Write an exception handler to catch OverflowError and output 'math.pow(): result of 5 raised to the power of ', followed by x_value and ' is too large.'1-Write a JAVA program that reads an array from input file and invokes twodifferent methods Sort and Max ,that sorts the elements of the array and findsthe Max element and writes out the resulted array in to output file . Usetwo interfaces for methods and throw Exception Handling for Out Of Boundindex for the array.Implement function getPercentage that takes two inputs : grade and totalGrade and outputs the gradepercentage as follows: percentage = (grade/total grade)*100 . (Assume a student can not get a grade above 100%) Define your own exception classes: 1. DivideByZeroException as a derived class of Standard Library class runtime_error, that is used to detect division by zero run time error. 2. NegativeNumberException as a derived class of Standard Library class logic_error, that is used to detect if the user entered a negative number as a grade. 3. InvalidGradeException as a derived class of Standard Library class logic_error, that is used to detect if a user entered an invalid input (grade greater than total grade). Use the above exception classes after implementing them to apply exception handling for your getPercentage function.
- PYTHON: A pedometer treats walking 2,000 steps as walking 1 mile. Write a steps_to_miles() function that takes the number of steps as a parameter and returns the miles walked. The steps_to_miles() function throws a ValueError object with the message "Exception: Negative step count entered." when the number of steps is negative. Complete the main() program that reads the number of steps from a user, calls the steps_to_miles() function, and outputs the returned value from the steps_to_miles() function. Use a try-except block to catch any ValueError object thrown by the steps_to_miles() function and output the exception message. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print('{:.2f}'.format(your_value)) Ex: If the input of the program is: 5345 the output of the program is: 2.67 Ex: If the input of the program is: -3850 the output of the program is: Exception: Negative step count entered.X1155: Throwing an Exception The method below takes in a String parameter representing a username. It should throw an Exception if the username is less than 3 characters long. The method correctly throws the exception, but something is still missing. Fix the problem. Your Answer: Feedback 1 public String validateUser (String userName) 2|{ 3 45 6 7 8|} 9 if (userName.length() < 3) { throw new Exception("userName is too short"); } return userName; Check my answer! Reset Your feedback will appear here when you check your answer.Java Foundations: Please provide basic exception program. Do not use input, output. Thank you. Write the Java code for the following: Write the Java program that reads an integer grade from a user in main( ), then calls the checkGrade method (passing it the grade that was just read in) to check that it is valid (between 0 and 100). if the checkGrade method determines that the grade is invalid, it generates an InvalidGradeException but does not deal with it. the main( ) method deals with the exception by writing a message about the invalid grade.. If the grade is valid, it is written to the monitor.