Questions
Task 1. Create class "Vehicle" with variables "company" and "year". LM 2. Create 3 derived classes:...

Task 1. Create class "Vehicle" with variables "company" and "year". LM 2. Create 3 derived classes: "Bus", "Car", and "Motorcycle". They should contain a variable storing number of seats (bus) / weight (car) / number of tires (motorcycle), constructor, destructor and a print_info function that will print all the information about the vehicle. PK 3. The constructors should take as parameters: company, year and number of seats / weight / number of tires. Inside it assign the company name and create an if / else condition that will throw an invalid_argument () exception with message "bus / car / motorcycle not produced yet" if the year is bigger than 2020, or assign the proper value. Additionally: a) for class "Bus": create if / else condition that throws an out of_range () exception with message "invalid number of seats" if that value is smaller than 8 and bigger than 70, or assign the proper value b) for class "Car": create if / else condition that throws an exception with message "car is too heavy" if that value is bigger than 3500, or assign the proper value c) for class "Motorcycle": create if / else condition that throws an exception with message "vehicle is not a motorcycle" if that value is different than 2, or assign the proper value

In: Computer Science

I need to write a MATLAB code for this question, but I couldn't figure how to...

I need to write a MATLAB code for this question, but I couldn't figure how to do it.

7. Engineers often have to convert from one unit of measurement to another; this can be tricky sometimes. You need to think through the process carefully. For example, convert 5 acres to hectares, given that an acre is 4840 square yards, a yard is 36 inches, an inch is 2.54 cm, and a hectare is 10000 m2.

In: Computer Science

Consider the following scheduling problem. There are n jobs and a single machine. Each job has...

Consider the following scheduling problem. There are n jobs and a single machine. Each job has a length ℓi and a weight wi . The weight wi represents the importance of job i.

a) Let fi be the finishing time of job i. Design a greedy algorithm to minimize the weighted sum of the completion times ∑n i=1 wifi . Your algorithm should run in time O(n log n) and output an ordering of the jobs.

b) Prove the correctness of your algorithm and analyze its running time.

Example: Suppose there are two jobs: t1 = 1, w1 = 2, t2 = 3, and w2 = 1. Doing job 1 first would give f1 = 1, f2 = 4, and a weighted sum of 2 · 1 + 1 · 4 = 6, which is optimal. Doing job 2 first would yield f1 = 4, f2 = 3, and a larger weighted sum of 2 · 4 + 1 · 3 = 11. (Hint: how does the weighted sum change if we swap two adjacent jobs?)

In: Computer Science

Consider the following variant of the Interval Scheduling problem. There are n jobs and each job...

Consider the following variant of the Interval Scheduling problem. There are n jobs and each job has a start time si and an end time fi . There is a single machine that can run at most one job at any given time. The jobs are now daily jobs. Once accepted, it must run continuously every day between its start and end times. (Note that a job can start before midnight and end after midnight.)

a) Design an algorithm that accepts as many jobs as possible. Your algorithm should run in time O(n 2 ) and output an optimal schedule (a set of intervals).

b) Prove the correctness of your algorithm and analyze its running time.

Example: Suppose there are 4 jobs, specified by (start-time, end-time) pairs: (9pm, 3am), (6pm, 6am), (3am, 1pm), and (2pm, 7pm). The optimal solution would be to pick 3 jobs (9pm, 3am), (3am, 1pm), and (2pm, 7pm), which can be scheduled without overlapping. (Hint: first enumerate an interval Ij = 1, . . . , n. How could we compute a schedule Oj with maximum size among all valid schedules that contain Ij?)

In: Computer Science

JAVA - PLEASE COMMENT CODE - THANK YOU: Implement a program that can input an expression...

JAVA - PLEASE COMMENT CODE - THANK YOU:

Implement a program that can input an expression in postfix notation and output its value.

In: Computer Science

Exercise 1: You are required to re-write the following code to catch the exception that can...

Exercise 1:

You are required to re-write the following code to catch the exception that can occur.

import java.util.Scanner;

public class ExceptionDemo

{

public static void main(String[] args)

{

Scanner scanner = new Scanner(System.in);

System.out.print("Enter an integer: ");

int number = scanner.nextInt();

// Display the result

System.out.println( "The number entered is " + number);

          }

}

In: Computer Science

Exercise 2: Try-Catch Exercise Write a Java code that does the following: Create a class MyClass...

Exercise 2:

Try-Catch Exercise

Write a Java code that does the following:

Create a class MyClass and create three methods myMethod1(), Method2() and Method3().

Invoke Method2() from Method1() and Method3() from Method2().

Write a code that can throw an exception inside myMethod3() and compile:

File file=new File("filename.txt");

Scanner sc=new Scanner(file);

You will get compilation errors now, as you are not handling a checked exception FileNotFoundException.

Declare throws over myMethod3() and myMethod2(). You will need to add throws FileNotFoundException on myMethod() as:

public void myMethod3() throws FileNotFoundException

{

File file=new File("filename.txt");

Scanner sc=new Scanner(file);

}

Handle the exception in myMethod1() by enclosing the code that can throw exception using a try-catch block:

public void myMethod1()

{

try{

myMethod2();

}

catch(FileNotFoundException e)

{

e.printStackTrace();

}

}

In: Computer Science

The following variables are declared as follow: int Var1 = 9, Var2 = 2, Var3 =...

The following variables are declared as follow:

int Var1 = 9, Var2 = 2, Var3 = 0;

What will the output of the following statements be?

Var3 = Va1 / Var2;

Var2 = Var2 / Var1;

out.print(Var3);
out.print(Var2);
int Var1 = 19, Var2 = 12,

oy.print(Var1 % Var2);
oy.print(Var1 % 3.0);
3. Var1 += 5;

System.oy.print(Var1);

In: Computer Science

whats the purpose of data warehouse design ? how is dimensional data models implemented in a...

whats the purpose of data warehouse design ?

how is dimensional data models implemented in a database covering relation implementation and multidemensional implementation.

In: Computer Science

List the product name and description of every product with a list price higher than $500...

List the product name and description of every product with a list price higher than $500 that has either the word “humbuck” or “fret” in the description. Use a regular expression to do this.


my guitar shop

In: Computer Science

List five types of files (e.g., JS) that have special meaning in web servers/web pages, and...

List five types of files (e.g., JS) that have special meaning in web servers/web pages, and explain briefly the role of each of the file types.

explain the hierarchy of network protocols used by web browsers/web servers, starting from the low level (IP) up to the high level (HTTP), with a brief explanation of each one.

In: Computer Science

JAVA Program The program below the text reads in the pet type …dog, cat or other...

JAVA Program

The program below the text reads in the pet type …dog, cat or other (only the words dog, cat, other) and the appointment amount. It is supplied as a beginning code to the assignment:

_______________________________________________________________
pet_lab package; 
import javax.swing.JOptionPane; 
public class pet_lab 
{ 

        public static void main (String [] args) 
        { 
                String pet, temp; 
                double payment; 
                pet = JOptionPane.showInputDialog (null, 
                 "Enter the pet type", "", JOptionPane.QUESTION_MESSAGE); 
                temp = JOptionPane.showInputDialog (null, 
                "Enter the payment for the appointment", "", JOptionPane.QUESTION_MESSAGE); 
            payment = Double.parseDouble (temp); 
            System.exit (0); 
        } 
}
_______________________________________________________________

You are to make the following changes:

  • Add a loop that reads data until the user wishes to stop
  • Count and print the number of dogs, cats and other pets
  • Calculate and print the total paid for dogs, cats and other pets
  • Calculate and print the total payment of all pets seen
  • Print which pet is seen the most, dogs, cats, or other

Please paste both the java code, a screenshot of the same code, and a screenshot/pasting of the final answer. Using this to check my Java data. Thanks!

In: Computer Science

Hi ERP experts! I am looking for ERP failure implementation cases. Specifically, I need suggestions of...

Hi ERP experts! I am looking for ERP failure implementation cases. Specifically, I need suggestions of cases, so I can summarize key factors influencing the success of the Sales & Marketing ERP module implementation.

In: Computer Science

Analysis and Discussion about if, if else, else if statement and Switch C programming write on...

Analysis and Discussion about if, if else, else if statement and Switch C programming write on your computer font

In: Computer Science

Java does not have a retry keyword like Ruby. How can we implement the same sort...

Java does not have a retry keyword like Ruby. How can we implement the same sort of functionality?

In: Computer Science