Questions
. Fibonacci sequence Fn is defined as follows: F1 = 1; F2 = 1; Fn =...

. Fibonacci sequence Fn is defined as follows: F1 = 1; F2 = 1; Fn = Fn−1 + Fn−2, ∀n ≥ 3. A pseudocode is given below which returns n’th number in the Fibonacci sequence. RecursiveFibonacci(n) 1 if n = 0 2 return 0 3 elseif n = 1 or n = 2 4 return 1 5 else 6 a = RecursiveFibonacci(n − 1) 7 b = RecursiveFibonacci(n − 2) 8 return a + b Derive the complexity of the above algorithm by writing the recurrence and solving it. Use the memoization idea (of dynamic programming) to obtain a linear time algorithm for the above problem. Show Pseudo-code and complexity proof. (5 + 10)

In: Computer Science

Create a method called firstLetter that takes a String parameter and integer parameter. It should return...

Create a method called firstLetter that takes a String parameter and integer parameter. It should return -1 if the number of words in the given String is greater than or equal to the integer parameter (it should return -1 and not process the String any further) (4 points). If the String does not have more words than the given integer, the method should return 1 if all the words in the string start with the same letter(8 points) and 0 if all the words do not start with the letter(4 points). (4 points: correct method signature-2 for parameter, 2 for return type) For example, System.out.println(firstLetter("Charlie chews chewy chews.",10)); would print to screen 1 since all words start with the same letter (notice the method is not case sensitive) and the number of words is less than 10.

code in java

In: Computer Science

Design a set of classes that keeps track of demographic information about a set of people,...

Design a set of classes that keeps track of demographic information about a set of people, such as age, nationality, occupation, income, and so on. Design each class to focus on a particular aspect of data collection. Assume the input data is coming from a text file. Create a main driver class to instantiate several of the classes.

In: Computer Science

Use adventure works 2014 database to solve the following questions in SQL management studio. 1. Create...

Use adventure works 2014 database to solve the following questions in SQL management studio.

1. Create a stored procedure that will receive parameters (all non-nullable fields should be supplied except the primary key which should be auto created still) to add a customer, single email, and single phone. The procedure should run it's code in a transaction and if any part of the add fails then the transaction should rollback.

2. Provide this query from previous assignments written with an isolation level that won't see your procedure transaction above until it's complete. Using joins List the orders customer name, order status, date ordered, count of items on the order, and average quantity ordered where the count of items on the order is greater than 300.

the data tables for second question are: sales.customer, sales.salesOrderHeader, Person.Person, sales.salesOrderDetail

In: Computer Science

For this final discussion, I would like you to venture out beyond the information presented in...

For this final discussion, I would like you to venture out beyond the information presented in this class and find a news article or magazine article (something "current") that is related to a company software upgrade. Identify what software was updated and why, security concerns, etc. Explain how the story or example works in regards to the things we have focused on in this course. Given your newly acquired knowledge on these topics, what stands out to you from this story? Is there anything you feel could have been done better?  

In: Computer Science

Write a program to read in a list of domain names from the provided file (domains.dat),...

Write a program to read in a list of domain names from the provided file (domains.dat), and print the reverse domain names in sorted order. For example, the reverse domain of cs.princeton.edu is edu.princeton.cs. This computation is useful for web log analysis. To do so, create a data type Domain, using reverse domain name order. The H file contains the required functions. The compareTo function is provided for you. This will allow you to compare 2 Domain objects.

Also use the StringHelper class provided. The H file of StringHelper outlines all the functions included.

The final list is sorted by as if the list were not reversed.

Below are the given files to complete program.

Domain.cpp

#include <algorithm> // used for min function

#include "Domain.h"

using namespace std;

int Domain::compareTo(Domain that)const {

                vector<string> thatFields = that.getFields();

                for (int i = 0; i < min(n, that.getN()); i++) {            

                                string s = fields[n - i - 1];

                                string t = thatFields[that.getN() - i - 1];

                                int c = s.compare(t);

                                if(c!= 0)

                                                return c;

                }

                return 0; //strings are equal

}

Domain.h

#include <vector>

#include <string>

class Domain{

                private:

                                std::vector<std::string> fields;

                                int n; //length of vector

                public:

                                Domain(std::string);

                                int getN()const;

                                std::vector<std::string> getFields()const;

               

                std::string printDomain()const;

                 int compareTo(Domain)const;

};

DomainDriver.cpp

using namespace std;

//Function prototypes

void swap(int, int, vector<Domain>&);

void sort(vector<Domain>&);

int main(){

                return 0;

}

domains.dat

sjc.edu.bz

cs.princeston.edu

auckland.ac.nz

belize.scotiabank.com

ub.edu.bz

ox.ac.uk

cs.auckland.ac.nz

cs.famu.edu

geeksforgeeks.org

my.uscis.gov

dcc.godaddy.com

group.bnpparibas

ocw.mit.edu

mail.google.com

law.unsw.edu.au

sesp.northwestern.edu

drive.google.com

unsw.edu.au

amazon.co.uk

letour.fr

StringHelper.h

#ifndef STRING_HELPER

#define STRING_HELPER

#include <string>

#include <sstream>

#include <vector>

class StringHelper{

                public:

                static std::vector<std::string> parse(std::string , char );

                static std::string toUpper(const std::string );

                template<typename T>

                static std::string toString(const T& );

};

#endif

In: Computer Science

Calendar Program Write a program to design an appointment calendar. An appointment includes a description, date,...

Calendar Program

Write a program to design an appointment calendar. An appointment includes a description, date, starting time, and ending time. Supply a user interface to add appointments, remove canceled appointments, and print out a list of appointments for a particular day.   Appointments should not be duplicated for a given time and date.

Include a class AppointmentMenu to print the menu to the screen and accept user input. AppointmentMenu creates an AppointmentCalendar and then calls the appropriate methods to add, cancel, show, or quit.

Include a class AppointmentCalendar that is not coupled with the Scanner or PrintStream classes. (In other words, all println statements should be in AppointmentMenu.) AppointmentCalendar will include an arrayList of Appointments, a method to add Appointments, a method to cancel Appointments, and return the Appointments for a selected day.

Include a class Appointments which holds the input of description, date, and time. It should have a method to format the output for printing by the AppointmentMenu, a method to check to see if two appointments are equal so an appointment is not duplicated for a given date and time, and a method to check for a certain date when show and cancel are called.   

Be sure to include any other methods including any accessor methods that you need to complete this program using the design process described in Chapter 12.

Your main class should be called AppointmentSystem. Use the code below:

/**
 A system to manage appointments.
*/
public class AppointmentSystem { 
   public static void main(String[] args) {
      AppointmentMenu menu = new AppointmentMenu();
      menu.run();
   }
}


Here is a sample program run. (bold items are sample user inputs).

A)dd  C)ancel  S)how  Q)uit
A
Appointment (Description Date From To)
Dentist 
01/10/2007 
17:30 
18:30

A)dd  C)ancel  S)how  Q)uit
A
Appointment (Description Date From To)
Sweets Cafe 
01/10/2007
19:00 
20:00

A)dd  C)ancel  S)how  Q)uit
A
Appointment (Description Date From To)
CS1 class 
02/10/2007
08:30 
10:00

A)dd  C)ancel  S)how  Q)uit
S
Show appointments for which date?
01/10/2007
Appointments:
Dentist 01/10/2007 17:30 18:30
Sweets Cafe 01/10/2007 19:00 20:00

A)dd  C)ancel  S)how  Q)uit
C
Cancel appointments on which date?
01/10/2007
1) Dentist 01/10/2007 17:30 18:30
2) Sweets Cafe 01/10/2007 19:00 20:00
Which would you like to cancel? 
1

A)dd  C)ancel  S)how  Q)uit
S
Show appointments for which date?
01/10/2007
Appointments:
Sweets Cafe 01/10/2007 19:00 20:00

A)dd  C)ancel  S)how  Q)uit
A
Appointment (Description Date From To)
Sweets Cafe 
01/10/2007
19:00 
20:00
This appointment already exists.

A)dd  C)ancel  S)how  Q)uit
Q

How do I write this program in JAVA not C++ ? Thanks

Also DON'T

import java.io.IOException;

import java.sql.SQLException;

I can only import the scanner class, and ArrayLists and Arrays

What I've done so far is

/**
A system to manage appointments.
*/
public class AppointmentSystem {

public static void main(String[] args) {

AppointmentMenu menu = new AppointmentMenu();

menu.run();
}
}

import java.util.Scanner;
public class AppointmentMenu extends AppointmentCalendar{

public void run(){
Scanner in = new Scanner(System.in);

System.out.println("A)dd C)ancel S)how Q)uit");

String choice = in.nextLine(); {


if (choice.equalsIgnoreCase("A")){
super.addApt();
System.out.println("Appointment(Description Date From To)");
}


if (choice.equalsIgnoreCase("C")){
super.cancelApt();
System.out.println("Cancel appointments on which date?");
}


if (choice.equalsIgnoreCase("S")){
super.showApt();
System.out.println("Show appointments for which date?");
}


if (choice.equalsIgnoreCase("Q"))
return;


}




}

}

import java.util.ArrayList;

public class AppointmentCalendar extends Appointments{
private ArrayList<String[]> appointments = new ArrayList<String[]>();

public void addApt(){

}

public void cancelApt(){

}

public void showApt(){

}




}

import java.util.ArrayList;
import java.util.Scanner;

public class Appointments {

private ArrayList<String[]> description = new ArrayList<String[]>();
private ArrayList<String[]> dates = new ArrayList<String[]>();
private ArrayList<String[]> times = new ArrayList<String[]>();




}

In: Computer Science

write a C program that asks the user to enter numbers and finds maximum among them

write a C program that asks the user to enter numbers and finds maximum among them

In: Computer Science

Q1) Write a program to implement the quick sort algorithm in a one dimensional array? Q2)...

Q1) Write a program to implement the quick sort algorithm in a one dimensional array?

Q2) Write a program to implement the merge sort algorithm in a one dimensional array?

In: Computer Science

Data structure Give three distinct binary search trees for the following data:   1 2 3 4...

Data structure

  1. Give three distinct binary search trees for the following data:   1 2 3 4 5 6 7. One of these trees must have minimum height and another must-have maximum height.
  2. Draw the BSTs that result from each sequence of add operations. (2) a. 10, 20, 30, 40 b. 30, 20, 40, 10 c. 20, 10, 30, 40

In: Computer Science

Write below in Python Get user name from keyboard using input() function (Example username = input("Enter...

Write below in Python

Get user name from keyboard using input() function

(Example username = input("Enter username:")

A: What is your name?

B: My name is XXXX.

B: What is yours?

A: My name is XXXX.

A: Nice to meet you.

B: Nice to meet you, too.

Use print statement and use input() function

In: Computer Science

Write a class IgnoreCaseComparator that implements Comparator<Character>. If it were used as the argument to List.sort(),...

Write a class IgnoreCaseComparator that implements Comparator<Character>. If it were used as the argument to List.sort(), it would sort the list ignoring case. This behavior is different from using the natural ordering of characters, where uppercase characters come before lowercase characters.

Note that this question is not asking you to sort a list -- just to write the comparator!

For example, if the unsorted list were [b, C, A, d], then the list would be [A, b, C, d] after sorting using this comparator. (If you had sorted using the natural ordering of characters, the result would instead have been[A, C, b, d].)

You may find a utility method of Character, such as Character.toLowerCase(), helpful.

You may assume that Comparator and Character are imported. You may not import other classes.

In: Computer Science

Using Java language: Overall Situation: You work for a company that sells cars and services cars....

Using Java language:

Overall Situation:

You work for a company that sells cars and services cars. You have been instructed to write a program to help keep track of these operations for the store manager. Your company is moving to an object oriented programming system for all of its software, so you will have to create a car class and use it in your program. Besides creating the cars when the user chooses, the user can also change information about a car they choose. You will need to incorporate error handling to make sure that incorrect values are not stored if the user enters them for a change. There are also menu options for specific reports you should show on the screen when the user selects those options.

Car Class:

Your system works with cars. Each car has the following information it keeps: vin (a string), make (a string), model (a string), year (a number greater than 1970), mileage (a number not less than zero), price (a floating point number greater than 1000.)

Menu:

You need to have a menu system for this program. The user should be allowed to do several different things and each time returning to the main menu when they are done.

Main System Features/Processes:

Here are the main functional features your system has to have for the user:

  • Ability to add a car to the array and set all of the values for it with input from the user
  • Ability to ask the user which car in the array they wish to change in some way, and then make that change.

(Hint: Have it in a separate method you are calling and print a message and ask them what they want to change and number them so you can do a separate If/Else or Switch. Then ask them for the value to change it to, and do it there. …don’t try to do it in the main menu.)

  • Display a message with all the data for a car the user chooses.
  • Display the data for all the cars (currently in the array) for the user.
  • Display the average mileage for all of the cars on the lot.
  • Display the lowest price for all of the cars on the lot.

In: Computer Science

Towards the end of the chapter (p. 160-161), examples of deriving control signals are given. Table...

Towards the end of the chapter (p. 160-161), examples of deriving control signals are given. Table 5-6 lists out the "actions" to fetch/decode/execute each CPU instruction.

List out the control signals given when a CPU instruction is being executed. For example, when each of the instructions X, Y, and Z is being executed, the control unit gives a set of signals at different time T:
X: at T4: A0 A1 C0
at T5, A1 B0
(function/inst X and at T4: signals A0 A1 C0 are given
function/inst X and at T5, signals A1 B0 are given)

Y: at T3, signals B1 C0
at T4, signals A1 B1 C1

Z: at T4: signals A0 C1
at T5, signals A1 B0 C0

Then, each signal is given when:
A0 = X T4 + Z T4 = (X+Z) T4
A1 = X T4 + X T5 + Y T4 + Z T5 = (X+Y) T4 + (X+Z) T5
B0 = X T5 + Z T5 = (X+Z) T5
B1 = Y T3 + Y T4 = Y (T3+T4)
C0 = X T4 + Y T3 + Z T5
C1 = Y T4 + Z T4 (Y+Z) T4

Q1. For the Fetch, Decode, and Indirect steps (T0 through T3) list out signals like the above. First list out signals used in Fetch, Decode, then Indirect. Then for each signal, list its timing definition.
(There should be 8 different signals appeared 12 times.)
(10 pts)

Q2. For signals used to execute 7 different memory-reference
instructions, sort them out the same way as above. First
by instruction name, then by signal name.
Order the listing alphabetically. (10 pts)

Q3. What is interrupt-handling and why is it useful for operation of I/O devices? (2 pts)

In: Computer Science

unix Delete the second character from every line in a file Delete the last word from...

unix

  1. Delete the second character from every line in a file
  2. Delete the last word from every line in a file.
  3. Swap the first and second letter of every line in a file.
  4. Swap the first and last characters of every line in a file.
  5. For each line that begins with a single space, replace the space with a tab. Lines that begin with 2 or more spaces should not be effected.
  6. Finds dates in the form mm/dd/yy and replaces them with the form mm/dd/20yy. In other words puts 20 in front of a 2 digit year. 4 digit years should not be changed.
  7. Move lines 3 through 5 after line 8 (so the output lines would be in order 1,2,6,7,8,3,4,5,9,10,....)
  8. Given a line with a UNIX path specified, print the base file name only. So for example, "/home/users/james" would print "james"
  9. Given a line with a UNIX path specified, print the directory part only. So for example, "/home/users/james" would print "home/users"

In: Computer Science