Questions
you are to write a program in Java, that reads in a set of descriptions of...

you are to write a program in Java, that reads in a set of descriptions of various geometric shapes, calculates the areas and circumferences of the shapes, and then prints out the list of shapes and their areas in sorted order from smallest to largest area. There are four possible shapes: Circle, Square, Rectangle, and Triangle. The last is always an equilateral triangle. The program should read from standard input and write to standard output. The program should read until the end of input is reached, i.e., there is no sentinel value to mark the end of input. There are at most 100 shapes in the input. Each line of the input contains a description of one shape and contains three or four fields separated by a single space. The first field is the name of the particular object (some String). The second field is the type of the shape (one of "Circle", "Square", "Rectangle", or "Triangle" - also a string.) The third field is the size: the radius of the circle, the size of a side of the square, the length of the rectangle, or the size of a side of the triangle. Only the rectangle has a fourth field - the height of the rectangle. The program should read in the input, compute both the area and circumference (or perimeter) of the shape, then sort the shapes by their areas, and print out the shapes in order from smallest to largest area.

Your program must: • Read from standard input and write to standard output. • Work on any size lists up to and including 100, not just the sizes in the example below. • Be efficient. • Have a base class, Shape, for a generic shape. This class must a method, getShape(String desc) which takes the description of a shape (including the name of the object) as described above and returns an appropriate Shape object, a getArea method, a getCircumference method, and a toString method. • Have four subclasses of Shape: Circle, Square, Rectangle, and Triangle.

In: Computer Science

Project title: Automated attendance system using facial recognition system Describe in detail about this title of...

Project title: Automated attendance system using facial recognition system

Describe in detail about this title of project

Research Depth :

- Depth of literature review

- Feasibility of the proposed project

- Implementation plan, methods and strategies

- Incorporating previous comments

In: Computer Science

USING JAVA Consider the following methods: StringBuilder has a method append(). If we run: StringBuilder s...

USING JAVA

Consider the following methods:
StringBuilder has a method append(). If we run:
StringBuilder s = new StringBuilder();
s.append("abc");
The text in the StringBuilder is now "abc"
Character has static methods toUpperCase() and toLowerCase(), which convert characters to upper or lower case. If we run Character x = Character.toUpperCase('c');, x is 'C'.
Character also has a static isAlphabetic() method, which returns true if a character is an alphabetic character, otherwise returns false.
You will also need String's charAt() method, which returns the character at a given index in the String. For example, "Godzilla".charAt(1) returns 'o'.

Write an application as follows:
public static String getNonAlpha() takes a String as parameter, builds a StringBuilder consisting of only the nonalphabetic characters in the String, and returns a String based on the StringBuilder (eg, sb.toString())
public static String getUpper() takes a String, builds a StringBuilder of the upper case versions of all the alphabetic characters in the String, and returns a String based on the StringBuilder.
Write JUnit tests to verify that the above methods are correct

In: Computer Science

Convert the following decimal numbers to 16-bit 2’s complement binary. Display your result in hexadecimal. a.3030...

Convert the following decimal numbers to 16-bit 2’s complement binary. Display your result in hexadecimal.

a.3030

b.404

c.5050

d.-5050

e.-20000

Show work with steps

In: Computer Science

Programming languages Explain orthogonality and its importance.

Programming languages

Explain orthogonality and its importance.

In: Computer Science

For this activity, you will use a top-down approach to create part of a specification for...

For this activity, you will use a top-down approach to create part of a specification for development of a video game. The game can be any genre or theme that you’d like, but for this exercise, you should choose a single platform (smartphones, iPads, PS4, PC, etc.).

Your “roadmap” should cover the following elements:

Cover the specifications for the software needs and requirements of the project, presented in a top-down approach (starting with the “big picture” and breaking down from there into the smaller requirements). Remember that not all software needs are programming related. For each need or requirement, propose a software solution. You don’t have to specify the exact program you would use (for example, you could say “word processor” instead of “Microsoft Word”).
You may use any requirement tracking technique or tool you like in building the requirements list. One program, platform, application, or piece of software can meet many different needs.
In a separate section, you should describe how you will apply prototyping techniques and analysis tools to improve the final product. Again, this discussion should consider what, if any, tools you will need to implement prototyping.
You can structure the specification however you think best, as long as it maintains a top-down perspective. Suggested formats include a flowchart style or a tiered outline.
You can refer to online resources or independent research for this activity.

In: Computer Science

Create a Java method findLongestPalindrome that takes a Scanner scn as its parameter and returns a...

Create a Java method findLongestPalindrome that takes a Scanner scn as its parameter and returns a String. It returns the longest token from scn that is a palindrome (if one exists) or the empty string (otherwise). (Implementation note: Use the built in isPalindrome method. This method calls for an optimization loop.)

Where the isPalindrome Method takes a String s as a parameter and returns a boolean. It returns true if s reads the same forwards and backwards, i.e., is a Palindrome, and returns false otherwise.

I only need help creating the findLongestPalindrome method, I already have the isPalindrome method.

In: Computer Science

Write a program named StringWorks.java that asks the user to input a line of text from...

Write a program named StringWorks.java that asks the user to input a line of text from the keyboard.   Ask the user if they want their answers case sensitive or not. You output should be

  1. the list of words in the sentence including duplicates
  2. A sorted list of the words (alphabetically)
  3. A sorted list of words listed backwards (where z comes before a)
  4. A randomly shuffled list of works
  5. the list of words in the sentence alphabetically removing duplicates.

You need to remove punctuation. Use the Character.isLetterOrDigit() method.

Sample output:

Please type in a sentence:

I love java, and Java loves me! That is cool, yes?

Do you want case sensitivity? (y/n):

n

List of words: i love java and java loves me that is cool yes

Sorted alphabetically: and cool i is java java love loves me that yes

Sorted backwards: yes that me loves love java java is i cool and

Shuffled: java that cool is i love and loves me java yes

Without duplicates, sorted alphabetically: and cool i is java love loves me that yes

In: Computer Science

Extend the definition of the class clockType by overloading the pre-increment and post-increment operator function as...

Extend the definition of the class clockType by overloading the pre-increment and post-increment operator function as a member of the class clockType.

Write the definition of the function to overload the post-increment operator for the class clockType as defined in the step above.

Main.cpp

//Program that uses the class clockType.

#include <iostream>
#include "newClock.h"

using namespace std;

int main()
{
clockType myClock(5, 6, 23);
clockType yourClock;

cout << "Line 3: myClock = " << myClock << endl;
cout << "Line 4: yourClock = " << yourClock
<< endl;

cout << "Line 5: Enter time in the form "
<< "hrs:mins:secs ";
cin >> myClock;   
cout << "Line 7: New value of myClock = "
<< myClock << endl;   

++myClock;

cout << "Line 9: After increment myClock is "
<< myClock << endl;

yourClock.setTime(13, 35, 38);
cout << "Line 11: Now yourClock = "
<< yourClock << endl;

if (myClock == yourClock)
cout << "Line 13: myClock and yourClock "
<< "are equal" << endl;
else
cout << "Line 15: myClock and yourClock "
<< "are not equal" << endl;

if (myClock <= yourClock)
cout << "Line 17: myClock is less than "
<< "yourClock" << endl;
else
cout << "Line 19: myClock is not less "
<< "than yourClock" << endl;  

cout << "Line 20: Testing post increment operator"
<< endl;

yourClock = myClock++;   

cout << "Line 22: myClock = " << myClock << endl;
cout << "Line 23: yourClock = " << yourClock
<< endl;

return 0;
}

newClock.cpp

//Implementation file newClock.cpp

#include <iostream>
#include "newClock.h"

using namespace std;

//Overload the pre-increment operator.

//Overload the post-increment operator.

//Overload the equality operator.
bool clockType::operator==(const clockType& otherClock) const
{
return (hr == otherClock.hr && min == otherClock.min
&& sec == otherClock.sec);
}

//Overload the not equal operator.
bool clockType::operator!=(const clockType& otherClock) const
{
return (hr != otherClock.hr || min != otherClock.min
|| sec != otherClock.sec);
}

//Overload the less than or equal to operator.
bool clockType::operator<=(const clockType& otherClock) const
{
return ((hr < otherClock.hr) ||
(hr == otherClock.hr && min < otherClock.min) ||
(hr == otherClock.hr && min == otherClock.min &&
sec <= otherClock.sec));
}

//Overload the less than operator.
bool clockType::operator<(const clockType& otherClock) const
{
return ((hr < otherClock.hr) ||
(hr == otherClock.hr && min < otherClock.min) ||
(hr == otherClock.hr && min == otherClock.min &&
sec < otherClock.sec));
}

//Overload the greater than or equal to operator.
bool clockType::operator>=(const clockType& otherClock) const
{
return ((hr > otherClock.hr) ||
(hr == otherClock.hr && min > otherClock.min) ||
(hr == otherClock.hr && min == otherClock.min &&
sec >= otherClock.sec));
}

//Overload the greater than or equal to operator.
bool clockType::operator>(const clockType& otherClock) const
{
return ((hr > otherClock.hr) ||
(hr == otherClock.hr && min > otherClock.min) ||
(hr == otherClock.hr && min == otherClock.min &&
sec > otherClock.sec));
}

void clockType::setTime(int hours, int minutes, int seconds)
{
if (0 <= hours && hours < 24)
hr = hours;
else
hr = 0;

if (0 <= minutes && minutes < 60)
min = minutes;
else
min = 0;

if (0 <= seconds && seconds < 60)
sec = seconds;
else
sec = 0;
}

void clockType::getTime(int& hours, int& minutes,
int& seconds) const
{
hours = hr;
minutes = min;
seconds = sec;
}

//Constructor
clockType::clockType(int hours, int minutes, int seconds)
{
setTime(hours, minutes, seconds);
}

//Overload the stream insertion operator.
ostream& operator<<(ostream& osObject, const clockType& timeOut)
{
if (timeOut.hr < 10)
osObject << '0';
osObject << timeOut.hr << ':';
  
if (timeOut.min < 10)
osObject << '0';
osObject << timeOut.min << ':';
  
if (timeOut.sec < 10)
osObject << '0';
osObject << timeOut.sec;

return osObject; //return the ostream object
}

//overload the stream extraction operator
istream& operator>> (istream& is, clockType& timeIn)
{
char ch;

is >> timeIn.hr; //Step a

if (timeIn.hr < 0 || timeIn.hr >= 24) //Step a
timeIn.hr = 0;
  
is.get(ch); //Read and discard :. Step b

is >> timeIn.min; //Step c

if (timeIn.min < 0 || timeIn.min >= 60) //Step c
timeIn.min = 0;

is.get(ch); //Read and discard :. Step d

is >> timeIn.sec; //Step e

if (timeIn.sec < 0 || timeIn.sec >= 60) //Step e
timeIn.sec = 0;

return is; //Step f
}

newClock.h

//Header file newClock.h

#ifndef H_newClock
#define H_newClock

#include <iostream>

using namespace std;

class clockType
{
friend ostream& operator<<(ostream&, const clockType&);
friend istream& operator>>(istream&, clockType&);

public:
void setTime(int hours, int minutes, int seconds);
//Function to set the member variables hr, min, and sec.
//Postcondition: hr = hours; min = minutes; sec = seconds

void getTime(int& hours, int& minutes, int& seconds) const;
//Function to return the time.
//Postcondition: hours = hr; minutes = min; seconds = sec

clockType operator++();
//Overload the pre-increment operator.
//Postcondition: The time is incremented by one second.

   clockType operator++(int);
   // Overload the post increment operator
   // Postcondition: Time is incremented by one second.

bool operator==(const clockType& otherClock) const;
//Overload the equality operator.
//Postcondition: Returns true if the time of this clock
// is equal to the time of otherClock,
// otherwise it returns false.

bool operator!=(const clockType& otherClock) const;
//Overload the not equal operator.
//Postcondition: Returns true if the time of this clock
// is not equal to the time of otherClock,
// otherwise it returns false.

bool operator<=(const clockType& otherClock) const;
//Overload the less than or equal to operator.
//Postcondition: Returns true if the time of this clock
// is less than or equal to the time of
// otherClock, otherwise it returns false.

bool operator<(const clockType& otherClock) const;
//Overload the less than operator.
//Postcondition: Returns true if the time of this clock
// is less than the time of otherClock,
// otherwise it returns false.

bool operator>=(const clockType& otherClock) const;
//Overload the greater than or equal to operator.
//Postcondition: Returns true if the time of this clock
// is greater than or equal to the time of
// otherClock, otherwise it returns false.

bool operator>(const clockType& otherClock) const;
//Overload the greater than operator.
//Postcondition: Returns true if the time of this clock
// is greater than the time of otherClock,
// otherwise it returns false.

clockType(int hours = 0, int minutes = 0, int seconds = 0);
//Constructor to initialize the object with the values
//specified by the user. If no values are specified,
//the default values are assumed.
//Postcondition: hr = hours; min = minutes;
// sec = seconds;

private:
int hr; //variable to store the hours
int min; //variable to store the minutes
int sec; //variable to store the seconds
};

#endif

In: Computer Science

Hello! I'm trying to work on a python lab in my class, and we basically have...

Hello! I'm trying to work on a python lab in my class, and we basically have to make this method

play_interactive

Now for the fun bit. The function play_interactive will take just one argument --- the length of patterns to use as keys in the dictionary --- and will start an interactive game session, reading either '1' or '2' from the player as guesses, using the functions you wrote above and producing output as shown in the sample game session at the beginning of this writeup. If the player types in any other input (besides '1' or '2'), the game should terminate.

Hint: the input function can be used to read input from the user as a string.

My code so far looks like this, I have the basic loop down and working, but my guesses list to retain the guesses for this method isn't updating

def play_interactive(pattern_length=4):
while True:
x = input()
intX = int(x)
guesses = ([])
if(intX == 1 or intX == 2):
guesses.append(intX)
print(len(guesses))
else:
print("Finished")
break

Any help would be appreciated! Thank you so much

In: Computer Science

using C program Assignment Write a computer program that converts a time provided in hours, minutes,...

using C program

Assignment

Write a computer program that converts a time provided in hours, minutes, and seconds to seconds

Functional requirements

  1. Input MUST be specified in hours, minutes, and seconds
  2. MUST produce the same output as listed below in the sample run
  3. MUST correctly compute times

Nonfunctional requirements

  1. MUST adhere to program template include below
  2. MUST compile without warnings and errors
  3. MUST follow the code template provided in this assignment
  4. MUST NOT change " int main() " function
  5. MUST only edit sections marked by " // complete this "

Sample run

4 hours, 13 minutes and 20 seconds is equal to 15200 seconds.
8 hours, 0 minutes and 0 seconds is equal to 28800 seconds.
1 hours, 30 minutes and 0 seconds is equal to 5400 seconds.

Grading

This assignment will be graded according to the programming grading rubric.

Due date

The assignment is due by the 11:59pm on September 20, 2019.

Requested files

time_to_sec.c

/*

* time_to_sec.c

*

* Created on: Jul 20, 2016

* Author: leune

*/

// appropriate #include statements

/* Convert a time interval specified in hours, minutes and seconds to

* seconds.

* Parameters:

* hours, minutes, seconds: input time elements

* Preconditions:

* 0 <= minutes < 60

* 0 <= seconds < 60

* Return:

* number of seconds in the interval

*/

unsigned int time_to_sec(unsigned int hours, unsigned int minutes,

unsigned int seconds) {

// complete this

}

/* Print a formatted representation of the calculation

* Parameters:

* hours, minutes, seconds: input time elements

* Postcondition:

* Function will write the calculation to standard output.

*/

void format_seconds(unsigned int hours, unsigned int minutes,

unsigned int seconds) {

// complete this

}

int main(void) {

format_seconds(4, 13, 20);

format_seconds(8, 0, 0);

format_seconds(1, 30, 0);

}

In: Computer Science

Create a 1- to 2-page IRP Microsoft Word for an IT organization. In your plan, ensure...

Create a 1- to 2-page IRP Microsoft Word for an IT organization. In your plan, ensure you:

  • Discuss roles and responsibilities.
  • Discuss the critical activities for each of the 5 phases in the incident response process.
  • List at least 3 cyber security tools that work together to monitor the organization’s network for malicious and abnormal activity.

In: Computer Science

C++ Given two finite sets, list all elements in the Cartesian product of these two sets.

C++

Given two finite sets, list all elements in the Cartesian product of these two sets.

In: Computer Science

Computer Science (C and Assembly Languages)    •   Assume there are two 32-bit variables in RAM...

Computer Science (C and Assembly Languages)

   •   Assume there are two 32-bit variables in RAM memory called In and Out. Write C code that sets Out equal to In plus 2.

   •   Assume there are two 32-bit variables in RAM memory called In and Out. Write assembly code that sets Out equal to In plus 2.


   •   What are the three stack rules?

   •   Assume B1 is a 32-bit unsigned global variable. We wish to write code that decrements B1 with the exception that it will not decrement if B1 is already 0. Draw a flowchart of the process. Write the code in both C and assembly.


   •   Assume G1 is a 32-bit unsigned global variable. We wish to write code that increments G1 if G1 is less than 20. Draw a flowchart of the process. Write the code in both C and assembly.

   •   Develop the pseudocode and the flowchart for a program that finds the sum of 5 numbers.


   •   Comment each line of the ARM Assembly language to explain what the code does. [4 pts]
start
MOV r0, #15
MOV r1, #8
ADD r0, r0, r1
MOV r4, #0x300

   •   Comment each line of the C language to explain what the code does. [4 pts]
#include <stdio.h>
int main()
{
int number;
printf("Enter an integer: ");
scanf("%d", &number);

if (number < 0)
{
printf("You entered %d.\n", number);
}

printf("The if statement is easy.");

return 0;
}

In: Computer Science

Python Albert Einstein famously said that compound interest is the 8th wonder of the world. Hopefully,...

Python

Albert Einstein famously said that compound interest is the 8th wonder of the world. Hopefully, all of you have had a finance course to teach you why it is so much more powerful than simple interest, which we programmed in class. If you are unfamiliar with compound interest, google it (note - if you google "compound interest for dummies" you will get a MUCH simpler explanation of how it works, without greek function notations!!)

Your assignment this week is to use a for loop, with the range() function to figure out compound interest on a deposit. You will ask the user for the amount of the deposit, the interest rate and the number of years and tell her how much money she has after that amount of time. Be sure to use the isnumeric function, and do NOT use an exponent to figure out compound interest - use a loop!

In: Computer Science