Questions
I need to create an exception handler with the following code I have below public class...

I need to create an exception handler with the following code I have below

public class Time {

/**

* Properties Declared;

*/

private int hours;

private int minutes;

private int seconds;

/*

* Default Constructor

*/

public Time()

{

hours = 0;

minutes = 0;

seconds = 0;

}

/**

* Parameterized Contructor throws BadTimeException in any case that

* there should be an error

* @param h

* @param m

* @param s

*/

public Time(int h, int m, int s) throws BadTimeException

{

hours = h;

minutes = m;

seconds = s;

if (h < 0 || m < 0 || s < 0 )

{

throw new BadTimeException("Error time can not be negatiive");

}

if(h > 24 || m > 60 || s > 60 )

{

}

}

public void helperMethod()

{

if(this.seconds > 59)

{

this.seconds = (this.seconds % 60);

this.minutes += 1;

}

if(this.minutes > 59)

{

this.minutes = (this.minutes % 60);

this.hours += 1;

}

}

/**

*

* @return

*/

public int getHours() {

return hours;

}

/**

*

* @return

*/

public int getMinutes()

{

return minutes;

}

/**

*

* @return

*/

public int getSeconds()

{

return seconds;

}

/**

* Copy Constructor

* @param originalObject

*/

public Time(Time originalObject)

{

hours = originalObject.hours;

minutes = originalObject.minutes;

seconds = originalObject.seconds;

}

/**

*

*/

public String toString()

{

String time = "";

String h, m, s;

if(hours < 10)

h = "0" + hours;

else

h = hours + "";

if(minutes < 10)

m = "0" + minutes;

else

m = minutes + "";

if(seconds < 10)

s= "0" + seconds;

else

s= seconds + "";

time = h + ":" + m + ":" + s;

return time;

}

/**

*

* @param hours

* @return

* @throws BadTimeException

*/

public Time later(int newHours) throws BadTimeException

{

return new Time(hours + newHours, this.minutes, this.seconds);

}

/**

*

* @param hours

* @param minutes

* @return

* @throws BadTimeException

*/

public Time later(int newHours, int newMinutes) throws BadTimeException

{

return new Time(hours + newHours, minutes + newMinutes, seconds);

}

/**

*

* @param hours

* @param minutes

* @param seconds

* @return

* @throws BadTimeException

*/

public Time later(int newHours, int newMinutes, int newSeconds) throws BadTimeException

{

return new Time(hours + newHours, minutes + newMinutes, seconds + newSeconds);

}

}

For example if I have 189 secs it should recognize it as an error and fix it by calling the helper method and instead should be 3 minutes and 9 seconds and the same thing with minutes ex 120 mins is 2 hours, but for hours it should just be dropped after the 1 day that is made for example 37 hours just becomes 13 hours. the exceptions handler should call a helper method that will fix the properties to make sense

In: Computer Science

*VISUAL BASIC* Construct and instantiate an array of strings called afcSouth that contains the following information...

*VISUAL BASIC* Construct and instantiate an array of strings called afcSouth that contains the following information separated by commas (as team, wins, losses, and ties). You realize now that you need to compute a winning percentage (namely (wins+.5*ties)/(wins + losses+ties)) for these teams.  Use this array to create a structure afcSouthTeam consisting of types string, integer, integer, integer, and double. Write a for loop that will cycle through the array to populate this structure with the actual data.

In: Computer Science

Write a Python program to implement a form of a Roman numeral calculator. We are using...

Write a Python program to implement a form of a Roman numeral calculator. We are using the purely additive form of Roman numerals. By that, we mean that a number is simply the sum of its digits; for example, 4 equals IIII, in our additive notation. This means that we are NOT using IV for 4. Each Roman numeral must start with the digit of highest value and ends with the digit of smallest value. That is 9 is VIIII and NOT IIIIV. Your program continually (in a loop) inputs 2 Roman numbers and an arithmetic operator and prints the result of the operation as a Roman number. The values of the Roman digits (upper case letters only) are as follows:

Roman Digit Value of Roman Digit I 1 V 5 X 10 L 50 C 100 D 500 M 1000 So, the Roman number MMVIIII represents 2009. The arithmetic operators that your program must recognize in the input are +, -, *, and //. These should perform the Python integer operations of addition, subtraction, multiplication, and division, respectively. Your program must loop, processing 2 Roman numbers with an operator, finishing when end of file is reached. You do not have to ensure that the input is in purely additive form, that is, digits are followed only by digits of the same or lower value. Your program does NOT have to check for this. You can assume that only positive numbers will be entered as input and you don't have to check for negative numbers. If the result is negative, you must print out a minus sign followed by the absolute value of the result printed as a Roman Numeral. See the sample runs below. If the result is zero, print the word "zero". --------------------------------------

In: Computer Science

1- Create a class called Point that has two instance variables, defined as private, as follows:...

1- Create a class called Point that has two instance variables, defined as private, as follows: An x coordinate and a y coordinate of type integer.

a) Write two constructors for the Point class as follows: A default constructor that sets the class instance variables to zero and a constructor that receives two integer values and sets the instance variables to them.

b) Write the set and get methods for the Point class to set and return the values of its instance variables.

c) Write a toString() method for the Point class that prints the class name (Point) and the value of its instance variables.


2- Create three classes called Circle, Rectangle and Square with the following properties:

- The Circle class has two instance variables – a position of type Point (the class that you just created above) and a radius of type double. The instance variables position and radius specify the position of the center and radius of the circle, respectively.

- The Rectangle class has three instance variables – a position of type Point  (the class that you just created above), a length and a width of type double. The instance variables position, length and width specify the position of the top left corner, length and width of the rectangle, respectively.

- The Square class has two instance variables – a position of type Point (the class that you just created above) and a length  of type double. The instance variables position and length specify the position of the top left corner and length of the square, respectively.

For each of the Circle, Rectangle andSquare classes do the following:

a) Define the instance variables as private.

b) Write two constructors for each class as follows: A default constructor that sets the instance variables to zero and a constructor that receives values for the instance variables and sets them.

c) Write the set and get methods for each class to set and return the values of their instance variables. For example, one of the get methods would return a Point.

d) Write a toString() method for each class that prints the class name (Circle, Rectangle or Square) and the value of its instance variables.

e) Write two methods called getPerimeter() and getArea() for each class, which calculate and return the perimeter and area of the class, respectively. For example, the getArea() method of the Square class returns the area of the Square object.


3- Test the above classes by writing a class called GeometricTest.java that does the following:

- Creates instances of the Circle, Rectangle and Square classes as follows:

- Circle: positioned at x = 7, y = 3 and the radius = 4.5.

- Rectangle: positioned at x = 3, y = -1 and the length = 4.0 and width = 6.0.

- Square: positioned at x = 5, y = 8 and the length = 2.0.

- Prints each of the above objects.

- Changes the length of the Square object to 5.0.

- Prints the perimeter and area of each of each of the above objects.

- Compares the x coordinates of the Square and Rectangle classes and prints a message specifying which one of them has a larger x coordinate.

In: Computer Science

Project 1 - 24 hour to 12 hour conversion write in c++ Write a program that...

Project 1 - 24 hour to 12 hour conversion

write in c++

Write a program that converts from 24-hour notation to 12-hour notation. For example, it should convert 14:25 to 2:25 PM. The input is given as two integers. There should be at least three functions, one for input, one to do the conversion, and two for output (one for 12-hour time and another for 24-hour time). Record the AM/PM information as a value of type char, ‘A’ for AM and ‘P’ for PM. Thus, the function for doing the conversions will have a call-by-reference formal parameter of type char to record whether it is AM or PM. (The function will have other parameters as well.) Include a loop that lets the user repeat this computation for new input values again and again until the user says he or she wants to end the program.

Each iteration of the loop will process 3 inputs:

  1. Hour of current time
  2. Minute of current time
  3. Whether or not to continue the loop

You mustimplement 4 functions. You are notpermitted to change the name or signature of these functions; the testing framework is going to directly call the functions. The three functions and their signatures are (use the signatures as a hint for how to implement this!):

  1. get_input(int &hour, int &minute)- function sets the hour and minute based on user input
  2. convert_to_12_hour(int &hour, char &am_pm);- function converts the hour to 12-hour notation and sets AM/PM
  3. print_24_hour_time(int hour, int minute)- function outputs the 24-hour time.
  4. print_12_hour_time(int hour, int minute, char am_pm)- function outputs the 12-hour time.

Sample execution:

Enter the hour in 24-hour format: 9
Enter the minute in 24-hour format: 13
The time in 24-hour format is 09:13
The time in 12-hour format is 09:13AM
Continue? (y/n): y

Enter the hour in 24-hour format: 12
Enter the minute in 24-hour format: 55
The time in 24-hour format is 12:55
The time in 12-hour format is 12:55PM
Continue? (y/n): y

Enter the hour in 24-hour format: 14
Enter the minute in 24-hour format: 05
The time in 24-hour format is 14:05
The time in 12-hour format is 02:05PM
Continue? (y/n): n

In: Computer Science

a) Fill out the following table with the values in R0 and R1 after each instruction...

a) Fill out the following table with the values in R0 and R1 after each instruction is executed. Please use hexadecimal. The first line is completed for you. (4 pts)

Address

Instruction

R0

R1

010016

1110 0001 1111 1100

00FD16

000016

010116

0001 0010 0011 1101

010216

0011 0011 1111 0100

010316

0101 0010 0110 0000

010416

0010 0001 1111 0110

b) Explain what the instruction at each of the following addresses does. (4 pts)

  • Address 010116:
  • Address 010216:
  • Address 010316:
  • Address 010416:

c) What is the value stored in PC when the instruction at address 010216 is executed? (1 pt)

In: Computer Science

what can Caribbean governments do to encourage companies to adopt eCommerce strategies ? please be detailed...

what can Caribbean governments do to encourage companies to adopt eCommerce strategies ?

please be detailed and add references!!

In: Computer Science

Write a C, C++ or Java program to implement each of the following functions. For each...

Write a C, C++ or Java program to implement each of the following functions. For each function, use a long long datatype for all integer variables and a double datatype for all decimal variables. Permutations(N,X): This function returns the number of ways X objects can be drawn from N objects in a particular order. Combinations(N,X): This function returns the number of ways X objects can be drawn from N objects ignoring the order in which the objects are drawn. Binomial(N,P,X): This function returns the binomial distribution probability of having X successes in N independent trials, where P is the probability of a success in each trial. Use the above functions in one or more main programs to solve the following problems:

1. A department contains 20 employees. The manager is going to randomly draw 4 employees and give each one a prize. a. How many ways can the 4 employees be drawn if the order in which they are drawn matters (i.e. the prizes have different values)? b. How many ways can the 4 employees be drawn if the order in which they are drawn does not matter (i.e. all prizes have the same value)?

2. A munitions warehouse contains 50 bombs, of which 3 are defective (6%). A sample of 10 bombs is drawn and tested. What is the probability that the sample will contain at most 1 defective bomb?

3. Suppose that the same warehouse contains a "very large" number of hand grenades, of which 7.5% are defective. A sample of 15 grenades is drawn and tested. What is the probability that the sample will contain at most 2 defective grenades?

Sample output for this problem (including some unnecessary debugging information):

Check for correctness of functions: permutations: P(10,4) = 5040 (should be 5040) combinations: C(10,4) = 210 (should be 210) binomial: b(2, 12, 0.06) = 0.127975 (should be 0.127975) Ways of presenting different prizes to 4 of 20 employees: 116280 Ways of presenting the same gifts to 4 of 20 employees: 4845 Probability of at most one faulty bomb in sample size 10: 0.902041 Probability of more than one faulty bomb: 0.097959 The sum of these probabilities is: 1.000000 (should be 1.0) Probability of at most two faulty hand grenades in 15: 0.902602 Turn in the source code listing for each function. For each of the solved problems, turn in the source code for the main program(s). Clearly indicate through in-line commenting the sections of code used to solve each problem. The program should also generate output clearly displaying the solutions to each problem.

In: Computer Science

Define the term below:-              A computer network The public switched telephone network Packet switching radio network...

Define the term below:-             

  1. A computer network
  2. The public switched telephone network
  3. Packet switching
  4. radio network
  5. A television network
  6. A message.
  7. A sender
  8. medium,
  9. A communications protocol
  10. Digital or analog channel
  11. Baseband
  12. Transmission media
  13. A computer network
  14. Return Channel
  15. Uplink or downlink channel
  16. Broadcast channel
  17. multiple channels

In: Computer Science

A company gave a user the permission to read file1 because he is the accountant manager...

A company gave a user the permission to read file1 because he is the accountant manager of the company. What is the type of this access control model: a) Role based control b) Network access control (NAC) c) Mandatory access control (MAC) d) Discretionary access control (DAC)

In: Computer Science

For the following C++ code, identify the 10 errors and rewrite the code using the space...

For the following C++ code, identify the 10 errors and rewrite the code using the space provided below. Do not write a new program just add, remove or change the characters/words that make the code incorrect. #include "iostream> using namespace std: class Line { public: Line( double L ) [ setLength(L); } void setLength( double L ) { length = L } double getLength( void ) { return length; } private= double length; }; int main() { double len; cout >> "How long is this line? " cin >> len; Line = line(len); Line *LPtr = line; cout << "Length of line : " << LPtr.getLength() << endl; }

In: Computer Science

Using Python: Write a program that takes a user-inputted integer and prints out the value of...

Using Python:

Write a program that takes a user-inputted integer and prints out the value of pi to the number of decimal places specified by the integer. For example, if the inputted integer is '2' your program should print '3.14'.

Hints:

  • Python's math package includes a constant for pi (as pi). We have imported pi for you in the example code below.
  • The format string syntax for rendering a floating point value to N decimal places is {:.Nf}. The example code below prints pi to 10 decimal places.
  • You will first need to assemble a format string, and then print your result using that format string.

SAMPLE CODE:

from math import pi

# Example input() statement
n = int(input('Please enter an integer: '))

format_string = '{:.10f}'

# Replace this with your own print statement
print(format_string.format(pi))

In: Computer Science

Instructions:DevelopaprogramnamedMakeStudentsthat  Reads student data from Readme.txt and creates student instances o usetheStudentclassprovidedforthelab  Saves student...

Instructions:DevelopaprogramnamedMakeStudentsthat

  •  Reads student data from Readme.txt and creates student instances

    o usetheStudentclassprovidedforthelab

  •  Saves student instances in an array list

  •  Displays the size of the list

  •  Iterates through the list displaying students one student per line, as in:

    for (Student s: myList) { System.out.println(s);

    }

    new File("Readme.txt")).useDelimiter(",");

    Then to get each token we can use f.next() or f.nextBoolean()
    Note that student gender is of type char, and that char value can be obtained using

    f.next().charAt(0)

    YoumustusetheStudentclassgivenalongwiththislab. ThisversionofStudentissimpler than the one in the text – this version makes no reference to the Subject class (not needed for this lab).

    Your BlueJ project will include

    Readme.txt, Student.java, and MakeStudents.java

    SubmitMakeStudents.javatotheemailcorrespondingtoyourlabsectionwithsubject Lab 10

Copy the student data provided for this lab to Readme.txt. The data comprises comma-

separated values for fields: first name, last name, gender and active.

Previously we have used the Scanner class with its default delimiter of whitespace. In this

lab, use the Scanner class with comma as the delimiter:

Scanner f = new Scanner

------------------------------------------------------

public class Student {

// class fields

private static int lastId;

// instance fields

private int id;

private String firstName;

private String lastName;

private char gender;

private boolean active;

// first constructor, no arguments

public Student(){

id = nextId();

// default values for a student:

firstName = "unknown";

lastName = "unknown";

gender = '?';

active = false;

}

// second constructor, four arguments

public Student (String firstName, String lastName, char gender, boolean active){

id = nextId();

//

// when parameters and fields have the same

// name they are distinquished this way:

// a field name alone refers to the parameter

// a field name prefixed with "this."

// refers to an object's fields.

this.firstName = firstName;

this.lastName = lastName;

this.gender = gender;

this.active = active;

}

private int nextId(){

// increment lastId and return the new value

// to be used for the new student.

return ++lastId;

}

public int getId(){

return id;

}

public static int getLastId(){

return lastId;

}

public String getFirstName(){

return firstName;

}

public String getLastName(){

return lastName;

}

public char getGender(){

return gender;

}

public boolean isActive(){

return active;

}

public void setLastId(int newLastId){

lastId = newLastId;

}

// no setter for the student's id field

// public void setId(int newId){

// id = newId;

// }

public void setFirstName(String newFirstName){

firstName = newFirstName;

}

public void setLastName(String newLastName){

lastName = newLastName;

}

public void setGender(char newGender){

gender = newGender;

}

public void setActive(boolean newActive){

active = newActive;

}

public String toString(){

return id+" "+firstName+" "+lastName;

}

public boolean equals(Student s){

return id == s.id;

}

}

---------------------------------------------------------

Readme.txt

Harry,Potter,m,true,Albus,Dumbledore,m,true,Serverus,Snape,m,true,Rubeus,Sirius,m,true,Hermione,Granger,f,true,Ron,Weasley,m,true,Draco,Malfoy,m,true,Luna,Lovegood,f,true,Regulus,Black,m,true,Neville,Longbottom,m,true,Nymphadora,Tonks,f,true,Remus,Lupin,m,true,Fleur,Delacour,f,true,Dolores,Umbridge,f,true,Gellert,Grindelwald,m,true

In: Computer Science

What domain expertise specific information is collected and organized during the problem definition step of a...

What domain expertise specific information is collected and organized during the problem definition step of a data mining spiral?

In: Computer Science

Marcia wants to keep track of each of her customers and their orders. Ultimately, she wants...

Marcia wants to keep track of each of her customers and their orders. Ultimately, she wants to notify them that their clothes are ready via email. Suppose that you have designed a database for Marcia’s Dry Cleaning that has the following tables:

CUSTOMER (CustomerID, FirstName, LastName, Phone, EmailAddress)

INVOICE (InvoiceNumber, CustomerID, DateIn, DateOut, Subtotal, Tax, TotalAmount)

INVOICE_ITEM (InvoiceNumber, ItemNumber, ServiceID, Quantity, UnitPrice, ExtendedPrice)

SERVICE (ServiceID, ServiceDescription, UnitPrice)

The referential integrity constraints are:

CustomerID in INVOICE must exist in CustomerID in CUSTOMER

InvoiceNumber in INVOICE_ITEM must exist in InvoiceNumber in INVOICE

ServiceID in INVOICE_ITEM must exist in ServiceID in SERVICE

Assume that CustomerID of CUSTOMER, EmployeeID of EMPLOYEE, ItemID of ITEM, SaleID of SALE, and SaleItemID of SALE_ITEM are all surrogate keys with values as follows: CustomerID Start at 100 Increment by 1

InvoiceNumber Start at 2018001 Increment by 1

D. Suppose that MArcia decides to allow multiple customers per order (e.g. for customers' spouses). Modify the design of these tables to accommodate this change.

E. Code SQL statements necessary to redesign the database, as described in your answer to question D.

F.Suppose that Marcia considers changing the primary key of CUSTOMER to (FirstName, LastName). Write correlated subqueries to display any data that indicate that this change is not justifiable.

In: Computer Science