[Solved] IT2650 Assignment13

$25

File Name: IT2650_Assignment13.zip
File Size: 178.98 KB

SKU: [Solved] IT2650 Assignment13 Category: Tag:
5/5 - (1 vote)

Step 01 Compile the following code (you can get the file from Blackboard)

I used the online compiler: https://www.jdoodle.com/online-java-compiler/

However, you can use any IDE as long as you submit code that I can compile and execute.

import java.io.*;import java.util.Scanner; public class Assignment13{ // put class definition here public static void main(String[] args){ System.out.println(A13 Written by Matt Weisfeld); Scanner console = new Scanner(System.in); // Input StringsString divisor=null, dividend=null; int x=0,y=0, counter=1; while (true) { System.out.println(
Pass + counter++ +

); System.out.print(Please enter the dividend (or x to end): ); dividend = console.nextLine();System.out.println(dividend); if (dividend.equals(x)) {System.out.println(
Program Terminated by User); break;} System.out.print(
Please enter the divisor : ); divisor = console.nextLine();System.out.println(divisor +
); x=Integer.parseInt(dividend); y=Integer.parseInt(divisor); // Put code here }

System.out.println(
Bye);

}

}

Step 02 Run the code (the output should look something like this)

Step 03 Add the code

This code accepts 2 values from the user inside of a loop, one for a dividend and one for a divisor. The loop continues until the dividend equals x.

Each time through the loop, your code must calculate the quotient (quotient =divisor/dividend) and print the result.

You must create a user defined exception called MyException. Here are the constraints:

  • Create a user defined exception called MyException.
  • Enclose the division (quotient =divisor/dividend) inside of a try/catch block.
  • Check to see if the divisor (in y inside of the code) is equal to zero.
  • If y is zero, then throw the user defined exception with the message Attempted to divide by zero!.
  • In all cases, continue with the loop.

My test data will look like this:

10

2

10

0

X

So you should make sure your code works with this data as well (but not just this data).

All that you need to turn in is your final version of A13. So upload that single file to Blackboard.

Step 04 When you run the code you will get something like the following output

Step 05 Submit the updated file to A 12.

Submit the file to Blackboard.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] IT2650 Assignment13[Solved] IT2650 Assignment13
$25