Questions
write me a java progrm that does this: y=x^3 +1 drivative of y=3X^2+0 y=mx+b m is...

write me a java progrm that does this:

y=x^3 +1

drivative of y=3X^2+0

y=mx+b

m is slope for x=2 put 2 back to equation y=3(2)^2=12

now we have 12 and y=9 so

9=2(12)+b and we find b=-15

now we write new equation that with these information

y=12x-15 we solve for 12x-15=0, we solve for x and x=15/12=1.25

now we do the same thing above we put at the drivative equation y=3(1.25)^2+0=4.6875

now we put this to 2.943125=(4.6875)*3+b

we solve for b=-2.90625

y=4.6875x-2.90625 and 4.6875x-2.90625=0 we solve for x and =0.62 now we use this as we did above to find another new equation and this go in a loop to do the same thing over and over to find new point and equation

In: Computer Science

using java For this assignment, you will write a program that guesses a number chosen by...

using java

For this assignment, you will write a program that guesses a number chosen by your user. Your program will prompt the user to pick a number from 1 to 10. The program asks the user yes or no questions, and the guesses the user’s number. When the program starts up, it outputs a prompt asking the user to choose a number from 1 to 10. It then proceeds to ask a series of questions requiring a yes or no answer. For example: Is your number evenly divisible by 3? (Yes or No).The user will enter “Yes” or “No” to each question. When the program is sure it knows the user’s number it outputs the number. For example, Your number is 9.

Your program must always guess the user’s number in less than five questions.

In: Computer Science

Briefly explain what are the chief differences between queues, dequeues and priority queue? How can you...

Briefly explain what are the chief differences between queues, dequeues and priority queue? How can you determine when it is appropriate to use a queue, a dequeue, or a priority queue? Write a simple example program using any of the 3.

In: Computer Science

Add comments to the following code: PeopleQueue.java import java.util.*; public class PeopleQueue {     public static...

Add comments to the following code:

PeopleQueue.java

import java.util.*;
public class PeopleQueue {

    public static void main(String[] args) {
        PriorityQueue<Person> peopleQueue = new PriorityQueue<>();
        Scanner s = new Scanner(System.in);
        String firstNameIn;
        String lastNameIn;
        int ageIn = 0;
        int count = 1;
        boolean done = false;

        System.out.println("Enter the first name, last name and age of 5 people.");
        while(peopleQueue.size() < 5) {
            System.out.println("Enter a person");
            System.out.print("First Name: ");
            firstNameIn = s.nextLine();
            System.out.print("Last Name: ");
            lastNameIn = s.nextLine();
            System.out.print("Age: ");
            while(!done) {
                try {
                    ageIn = Integer.parseInt(s.nextLine());
                    done = true;
                } catch (NumberFormatException e) {
                    System.out.println("Error: Please enter a number for age");
                    System.out.print("Age: ");
                }
            }
            Person person = new Person(firstNameIn, lastNameIn, ageIn);
            peopleQueue.add(person);
            System.out.println("Added to queue: " + firstNameIn + " " + lastNameIn + ", Age: " + ageIn + "\n");
            done = false;
        }

        NameCompare nameCompare = new NameCompare();
        List<Person> people = new ArrayList(peopleQueue);
        Collections.sort(people, nameCompare);

        System.out.println("Sorted by Last Name\n");
        for (int i = 0; i < people.size(); i++) {
            System.out.println("Name: " + people.get(i).getFirstName() + " "
                                        + people.get(i).getLastName() + ", Age: "
                                        + people.get(i).getAge());
        }


        System.out.println("\nSorted by Age and removed from queue\n");
        while (!peopleQueue.isEmpty()) {
            System.out.println("Removed Person " + count + " -" + peopleQueue.remove());
            count++;
        }
    }
}


Person.java

public class Person implements Comparable<Person> {

    private int age;
    private String firstName;
    private String lastName;

    public Person(String first, String last, int theirAge) {
        this.firstName = first;
        this.lastName = last;
        this.age = theirAge;
    }

    public String getFirstName() {
        return this.firstName;
    }

    public String getLastName() {
        return this.lastName;
    }

    public void setLastName(String last) {
        this.lastName = last;
    }

    public int getAge() {
        return this.age;
    }

    @Override
    public int compareTo(Person person) {
        if(this.equals(person))
            return 0;
        else if(getAge() < person.getAge())
            return 1;
        else
            return -1;
    }

    public String toString() {
        return " Name: " + getFirstName() + " " + getLastName() + ", Age: " + getAge();
    }


}


NameCompare.java

import java.util.Comparator;
public class NameCompare implements Comparator<Person> {

    public int compare(Person p1, Person p2) {
        int i = p1.getLastName().compareTo(p2.getLastName());
        if(i != 0) return -i;
        return i;
    }
}

In: Computer Science

how can you count the number of different letters there are in a word in C...

how can you count the number of different letters there are in a word in C programming?

In: Computer Science

Computer/Network Security How do you implement write access through web server?

Computer/Network Security

How do you implement write access through web server?

In: Computer Science

Based on what you have learned on the WAN technologies, there are three different types of...

  • Based on what you have learned on the WAN technologies, there are three different types of environments that need your help. The three types of environments include a small business, a medium corporate, and a large enterprise environment. What type of technology would you recommend for these different types of companies? Justify your answer.

  • What network optimization tools, methods, or techniques do you think will be most important to you as you manage your organization's network? Explain why?

In: Computer Science

PRELAB - Week of September 16 You’ve created a general-purpose function for allocating an array with...

PRELAB - Week of September 16

You’ve created a general-purpose function for allocating an array with elements of any data type:

array = createArray(numElems, elemSize);

and which supports the following function for obtaining its number of elements:

size = getArraySize(array);

and that’s all you’ll need for this pre-lab. All you’re asked to do for next week is to be able to:

1. Open a file

2. Read an integer giving the number of employee records in the file

3. Allocate an array of employee records (structs) to hold the records in the file

4. Read the records into the allocated array where an employee record is declared as:

typedef struct {

intempID, ssn, position;

float salary;}

Record;

To get comfortable with structs you’ll probably want to loop through the array and print the four members of each record–but you’d probably do that anyway just to verify that you get the results you expect from your test file!

In: Computer Science

Java assignment, abstract class, inheritance, and polymorphism. these are the following following classes: Animal (abstract) Has...

Java assignment, abstract class, inheritance, and polymorphism.

these are the following following classes:

Animal (abstract)

  • Has a name property (string)
  • Has a speech property (string)
  • Has a constructor that takes two arguments, the name and the speech
  • It has getSpeech() and setSpeech(speech)
  • It has getName and setName(name)
  • It has a method speak() that prints the name of the animal and the speech.

o Example output: Tom says meow.

Mouse

  • Inherits the Animal class
  • Has a constructor takes a name and also pass “squeak” as speech to the super class
  • Has a method chew that takes a string presenting the name of a food.

o Example output: Jerry is chewing on cheese.

Cat

  • Inherits the Animal class
  • Has a constructor takes a name and also pass “meow” to the super class
  • Has a method chase that takes a Mouse object.  

o Example output: Tom is chasing Jerry.

TomAndJerry

  • Has a static method makeAnimalSpeak that takes an Animal object and makes it animal speak.
  • Has a main method that
    • Create a variable of Animal type and assign it a mouse named “Jerry”
    • Create a variable of Animal type and assign it a cat named “Tom”
    • all the method makeAnimalSpeak on the animals you have created
    • Make the mouse chew on “cheese”
    • Make the cat chase the mouse

Sample run:

Jerry says squeak.

Tom says meow.

Jerry is chewing on cheese.

Tom is chasing Jerry.

In: Computer Science

What chmod command would you use to impose the following permissions? 1. on a directory(called dir1)...

What chmod command would you use to impose the following permissions?

1. on a directory(called dir1) and all its subdirectories such that: the owner would have read, write, and execute; the group would have read and execute; and others would have read(write the command in two ways: using rwx and using numeric value)

2. on file (called file1)such that: the owner would have read and write; the group would have no permissions; and others would have write

(write the command in two ways: using rwx and using numeric value)

3. set the special permission SGID and sticky bit for dir1.(you don't need to change the defined permission in 1)

Starting from the Linux default permissions for file and directories, what umask command would you use to ensure that for all new:

4. directories, the owner would have read, write, and execute; members of the group would have read and execute; and others would have read

5. files, the owner would have read and execute; the group would have read, write, and execute; and others would have execute

In: Computer Science

I am struggling with this java code Objectives: Your program will be graded according to the...

I am struggling with this java code

Objectives: Your program will be graded according to the rubric below. Please review each objective before submitting your work so you don’t lose points. 1. Create a new project and class in Eclipse and add the main method. (10 points)

2. Construct a Scanner to read input from the keyboard. (10 points)

3. Use the Scanner to read the name, number of balls, and yards per ball of a yarn type specified by a pattern. Prompt the user to input this data as shown in the example below, and store the data in variables. (15 points)

4. Use the Scanner to read the name and yards per ball of a substitute yarn. Prompt the user to input this data, and store the data in variables. (10 points)

5. Use conditional statements to check that each numerical input is a positive integer. Give the user one chance to correct each invalid input. Prompt the user to input a positive value as shown in the example. (15 points)

6. Calculate the number of substitute yarn balls. Use a method of the Math class to round up to the nearest full ball, and store the result in a variable. (20 points)

7. Print the number of substitute yarn balls to the console, matching the format of the example. (10 points)

8. Use meaningful variable names, consistent indentation, and whitespace (blank lines and spaces) to make your code readable. Add comments where appropriate to explain the overall steps of your program. (10 points)

In: Computer Science

Please discuss the design principles that guide the authors of instruction sets in making the right...

Please discuss the design principles that guide the authors of instruction sets in making the right balance. Provide examples of application of each of the three design principles while designing instruction sets.

In: Computer Science

Please type your answer, I will rate you well. This is about Threat Modeler when conducting...

Please type your answer, I will rate you well.

This is about Threat Modeler when conducting risk assessments.

  • What did you learn about threat modeling by examining the features of Threat Modeler?
  • Should software like Threat Modeler be used exclusively, or in addition to other threat modeling techniques?

In: Computer Science

mport java.util.Scanner; public class BankAccount { //available balance store static double availableBalance; // bills constants final...

mport java.util.Scanner;

public class BankAccount {

//available balance store

static double availableBalance;

// bills constants

final static int HUNDRED_DOLLAR_BILL = 100;

final static int TWENTY_DOLLAR_BILL = 20;

final static int TEN_DOLLAR_BILL = 10;

final static int FIVE_DOLLAR_BILL = 15;

final static int ONE_DOLLAR_BILL = 1;

public static void main(String[] args) {

System.out.print("Welcome to CS Bank\n");

System.out.print("To open a checking account,please provide us with the following information\n:" );

String fullname;

String ssn;

String street;

String city;

int zipCode;

Scanner input = new Scanner(System.in);

System.out.print("Please enter your full name:");

fullname = input.nextLine();

System.out.print("Please enter your street address:");

street = input.nextLine();

System.out.print("Please enter the city:");

city = input.nextLine();

System.out.print("Please nter the zipCode:");

zipCode= input.nextInt();

//zip_code enter must be 5 digit

while(zipCode <10000 || zipCode> 99999) {

System.out.println("You enter an invalid zip code.");

System.out.println("Zip code must be 5 digits.");

System.out.println("Re-enter your zip code.");

zipCode = input.nextInt();

}

input.nextLine();

//System.out.println();

System.out.print("Enter the SSN");

ssn = input.nextLine();

// loop until a valid SSN is not enter

while(!validateSSN(ssn)) {

System.out.println("That was an invalid ssn.");

System.out.println("Example of a valid SSN is: 144-30-1987");

System.out.print("Re-enter the SSN:");

ssn = input.nextLine();

}

System.out.println();

System.out.print("Enter the initial balance in USD:");

availableBalance =Double.parseDouble(input.nextLine());

while(availableBalance < 0) {

System.out.println("That was an invalid amount");

System.out.print("Please re-enter the initial balance in USD:");

availableBalance = Double.parseDouble(input.nextLine());

}

System.out.println();

deposit();

System.out.println();

withdraw();

System.out.println();

displayBills();

}

public static void deposit() {

double amountToDeposit;

Scanner input = new Scanner(System.in);

System.out.print("Enter the amount to deposit:");

amountToDeposit=Double.parseDouble(input.nextLine());

while(amountToDeposit<0) {

System.out.println("That was an invalid amount.");

System.out.print("Please re-enter the amount to deposit: $");

amountToDeposit = Double.parseDouble(input.nextLine());

}

availableBalance = availableBalance + amountToDeposit;

System.out.print("Amount deposited successfully\n");

System.out.println("Your final currentbalance is: $" + String.format("%.2f", availableBalance));

}

public static void withdraw() {

double amountToWithdraw;

Scanner input = new Scanner(System.in);

System.out.print("Enter the amount to withdraw:");

amountToWithdraw = Double.parseDouble(input.nextLine());

while(amountToWithdraw < 0) {

System.out.print("That was an invalid amount.");

System.out.print("Please re-enter the amount to withdraw:$");

amountToWithdraw = Double.parseDouble(input.nextLine());

}

if((availableBalance-amountToWithdraw)< 0) {

System.out.println("SERIOUS ERROR OCCURED");

System.out.println("You try to withdraw an amount more than the available balance");

System.out.print("Program is exiting....");

System.exit(-1);

}

availableBalance = availableBalance-amountToWithdraw;

System.out.println(" Amount withdraw successfully");

System.out.println("Your final account balance is:$ "+String.format("%.2f",availableBalance));

}

public static void displayBills() {

double balance = availableBalance;

int bill_100 = (int)(balance/HUNDRED_DOLLAR_BILL );

balance = balance-(bill_100*HUNDRED_DOLLAR_BILL);

int bill_20 = (int)(balance/TWENTY_DOLLAR_BILL);

balance = balance-(bill_20*TWENTY_DOLLAR_BILL);

int bill_10 = (int)(balance/TEN_DOLLAR_BILL);

balance = balance-(bill_10*TEN_DOLLAR_BILL);

int bill_5 = (int)(balance/FIVE_DOLLAR_BILL);

balance = balance-(bill_5*FIVE_DOLLAR_BILL);

int bill_1 = (int)balance;

if(bill_100 > 0)

System.out.println("Count of $100 Bill is" + bill_100);

if(bill_20 > 0)

System.out.println("Count of $20 Bill is" + bill_20);

if(bill_10 > 0)

System.out.println("Count of $10 Bill is" + bill_10 );

if(bill_5 > 0)

System.out.println("Count of $5 Bill is" + bill_5);

if(bill_1 > 0)

System.out.println("Count of $1 Bill is" + bill_1);

}

public static boolean validateSSN(String ssn) {

//split the ssn based on '-' as delimiter

String[] tokens =ssn.split("-");

if(tokens.length != 3)

return false;

else {

if(tokens[0].length() != 3)

return false;

else if(tokens[1].length() != 2)

return false;

else if(tokens[2].length() != 4)

return false;

else {

//loop for each token chars

for(int i = 0; i < tokens.length; i++) {

int len = tokens[i].length();

for(int j = 0; j < len; j++) {

if(tokens[i].charAt(j)< 'o' || tokens[i].charAt(j) >'9')

return false;

}

}

return true;

}

}

}

}

Someone please fix my java program I'm having hard properly validating SSN . And fix any problem if found. Thanks.

In: Computer Science

In java Write multiple if statements: If carYear is before 1967, print "Probably has few safety...

In java

Write multiple if statements:
If carYear is before 1967, print "Probably has few safety features." (without quotes).
If after 1971, print "Probably has head rests.".
If after 1991, print "Probably has anti-lock brakes.".
If after 2002, print "Probably has airbags.".
End each phrase with period and newline. Ex: carYear = 1995 prints:

Probably has head rests.
Probably has anti-lock brakes.

public class SafetyFeatures {
public static void main (String [] args) {
int carYear;

carYear = 1991;

*insert code here*

}
}

In: Computer Science