Questions
1) Represent -34 and +67 in the following ways: a) 8 bit sign and magnitude representation...

1) Represent -34 and +67 in the following ways: a) 8 bit sign and magnitude representation with MSB as sign bit. b) 8 bit 1’s complement representation. c) 8 bit 2’s complement representation. 2) Convert the decimal numbers 40 and 20 into 8-bit unsigned binary representation and add the two numbers.

In: Computer Science

Python Chemicals can be described as either acids or bases. The pH scale measures the concentration...

Python Chemicals can be described as either acids or bases. The pH scale measures the concentration of hydrogen ions in a chemical to determine just how acidic or basic it is. For this task you are going to determine whether a chemical is acidic or basic based on its pH value, and how strongly it has that property. Remember, don't call input() or print() anywhere, just use the parameters provided and return statements.

You must have at least one conditional in each function. You cannot import any module. A couple of the tasks have individual restrictions; note them, as we will remove points for any task that does not follow the requirements.

def chemical_strength(pH): Accepts one floating point parameter for the pH value, and then:

  • Determines if the pH value is valid (pH must be between 0 and 14 inclusive).

  • You’ll return the string "bad measurement" if pH value doesn't make sense.

  • Determines a description of the chemical based on its pH value.

    o A pH of less than 7 is an acidic chemical, however, we will be more specific:

  • ▪ a pH value less than or equal to 1 is a "very strong acid"
    ▪ a pH value between 1 and 4 (exclusive) is a "strong acid"
    ▪ a pH value of exactly 4 is a "plain acid"

    ▪ a pH between 4 and 6 (exclusive) is a "weak acid"

    ▪ a pH value greater than or equal to 6 is a "very weak acid"
    o A pH of more than 7 is a basic chemical, however, we will be more specific:

    ▪ a pH value less than or equal to 8 is a "very weak base"
    ▪ a pH value between 8 and 10 (exclusive) is a "weak base"
    ▪ a pH value of exactly 10 is a "plain base"
    ▪ a pH value between 10 and 13 (exclusive) is a "strong base"▪ a pH value greater than or equal to 13 is a "very strong base"

    o If the pH is exactly 7, the chemical is simply "neutral"

  • Returns the strength description as a string, e.g. "weak acid", "very strong base" etc.• Examples:

    o #pH is in between 4 and 6
    chem_strength(4.7) → 'weak acid'

    o # pH is outside of the valid pH range chem_strength(15.43) → 'bad measurement'

In: Computer Science

Using the pumping lemma for regular languages, show that language is not regular. b) L3= {0n...

Using the pumping lemma for regular languages, show that language is not regular.
b) L3= {0n 1m, m = n+2 } Language= {0,1}

In: Computer Science

Let's look at the auditing system in Windows Server 2008. What are the characteristics? How do...

Let's look at the auditing system in Windows Server 2008. What are the characteristics? How do you set it up?

In: Computer Science

This game is simpler than the normal game of war, but the object is to have...

This game is simpler than the normal game of war, but the object is to have a card with a higher value than the dealer. The user makes a bet. Then, both the user and the computer draw a card. If the user’s card has a larger value than the computer’s card, then the user wins, and gets the value of their bet added to their total. Otherwise, the computer wins, and the user loses their bet. After each round, discard the cards. Keep playing until the user runs out of money, or until they say they don’t want to play anymore.

Card class - the class representing a single card in a deck. Every card has three properties. The first is a “suit,” which is either “Hearts”, “Diamonds,” “Spades”, or “Clubs”. A card also has a color, where Hearts and Diamonds are red, and Spades and Clubs are black. Finally, each card has a value from 1-13 (inclusive). Some values have special names: the 1 is an Ace, 11 is a Jack, 12 is a Queen, and 13 is a King.

Your first job is to design a class for a card, with each of these properties. It should have these methods:

  1. public Card(int value, String suit) - initializes the Card and it’s variables. For example, Card(12, “Hearts”) will create a red 12 of hearts.

  2. public int getValue( ) - returns value of the card

  3. public String getColor( ) - returns color of the card

  4. public String getSuit( ) - returns suit of the card

  5. public String toString() - returns string representation of the card, E.G. “King of Hearts.”

    Or “7 of clubs”

DECK CLASS

In an entire deck, there are 52 cards, each of the 13 values for the four different suits. You should implement a class to handle all of the logistics of the deck, so that as a user of the class, all you have to do is pick cards from the deck, and then discard them once you’re done with them. This class has a bit more logic in it, so here’s what you have to do.

  1. public Deck()

    This method will initialize the deck - creating an array of each of the 52 possible cards. After generating them, you should also shuffle them in the array (shuffling method is defined below). This method should also initialize a discard pile array, which currently has nothing in it. You may want to initialize other variables too, to assist with your other methods.

  2. public void shuffle()

This method shuffles all of the items in the deck. You can be creative with your shuffling algorithm, but I suggest you implement this one (the first algorithm under “The Modern Algorithm”). This is in “pseudo code,” which means it’s not in a real programming language, so it will be your job to convert this into real java code. Make sure if there are some “null” elements in your deck, that you don’t shuffle them into the deck.

  1. public Card drawNextCard()

    This method will give you the next card in the deck. Initially, this will be the card at index 0, then index 1, then index 2... up until index 51. After index 51, drawNextCard should take all of the cards in the discard pile, put them in the deck array, empty the discard pile, shuffle them, and then return the first one.

  2. public void discard(Card c)

    This method will add the card into the discard pile. Initially it will add the card to the first index of the discard pile, then the second index, etc...

Hints:

  1. Remember that assignments for Arrays are by reference. If you want the deck to be a copy

    of everything in the discard pile, you can just do:
    currentDeck = discardPile.clone();
    Then to empty the discard pile, you can just say: discardPile = new Card[52];

  2. Be careful with shuffling that you don’t accidentally shuffle “null” objects into the deck. This won’t happen in the beginning when the deck is full, but when you’re making the contents of the discard pile into the new deck, there will probably be some “null” elements at the end.

Feel free to add any other methods to these classes.

CLIENT CODE

Once you have these classes done, and have tested them to make sure they work, you can start using these objects to write the game in our casino, in a new file Casino.java.

you should have a main method that allows the users to play these games. There are many choices that are left up to you regarding the design of the game. For example, what do you do when the user runs out of money. How do you decide how much the user starts with? Will you implement a betting minimum and maximum?

In: Computer Science

SOLVE USING WHILE. A perfect number is a positive integer that is equal to the sum...

SOLVE USING WHILE. A perfect number is a positive integer that is equal to the sum of its positive divisors except the number itself. The first two perfect numbers are 6 and 28 since 1+2+3=6 and 1+2+ 4+7+14=28. Write a matlab computer program that finds the first n perfect number (the user must input the value of n) and show them in a vector

thanks! xo

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

In Linux Can you reboot the system as a normal user? Explain your answer. Draw on...

In Linux

  • Can you reboot the system as a normal user? Explain your answer. Draw on the concepts discussed in this course to justify your answer.
  • How do you change the system run level? Changing the system run level means switching from your default run level to run level 1 and vice versa.

Your response to each should meet the following criteria:

  • It should be a minimum of 1 paragraph (five single-spaced sentences).
  • If you are using outside sources, you need to acknowledge your sources with APA citations.

please type your answer, I will rate you well.

In: Computer Science

in java Create a class City with x and y as the class variables. The constructor...

in java Create a class City with x and y as the class variables. The constructor with argument will get x and y and will initialize the city. Add a member function getDistanceFrom() to the class that gets a city as the input and finds the distance between the two cities.

In: Computer Science

1_ What is the output? private void btnMethods_Click(object sender, EventArgs e) { int arg1 = 2;...

1_ What is the output?

private void btnMethods_Click(object sender, EventArgs e)

{

int arg1 = 2;

double val = ValReturnMethod(arg1, 2.00);

MessageBox.Show(val.ToString());

}

private void ValReturnMethod(int val, double val2)

{

return val1 * val2 *25.50;

}

_____________________________

2_ What is the output?

private void btnMethods_Click(object sender, EventArgs e)

{

int arg1 = 4;

double val = ValReturnMethod(ref arg1);

MessageBox.Show(arg1.ToString());

}

private double ValReturnMethod(ref int val1)

{

return val1 *25.50;

}

______________________________

3_ What is the output?

private void btnMethods_Click(object sender, EventArgs e)

{

int arg1 = 4;

double arg2 = 10.50;

MessageBox.Show(ValReturnMethod(arg1,arg2).ToString());

}

private double ValReturnMthod (int val1,double val2)

{

return val1 * 25.50;

}

In: Computer Science

What is the signed decimal equivalent of the following signed-magnitude binary value? 11101010.1001 What is the...

What is the signed decimal equivalent of the following signed-magnitude binary value?

11101010.1001

What is the binary equivalent (in two's complement binary representation) of the following signed decimal value? Represent the integer part of the binary value in 8 bits.

-58.1875

In: Computer Science

For each of the following situations provide the type of variable(s) that you would use to...

For each of the following situations provide the type of variable(s) that you would use to model it and give a kind of probability distribution that would be appropriate for modeling that variable.

  1. Age of students in the class
  2. Choice of color marker
  3. Whether you ride a bus given how much cash you have in your pocket.
  4. Number of ice creams I have eaten, up to 3 ice creams maximum.
  5. Cost of a crop based on the harvest size.
  6. Cities in the US
  7. Distance of a city in the US to Columbus
  8. Height of students in class based on gender

In: Computer Science

C++ Text message decoder Use getline() to get a line of user input into a string:...

C++

Text message decoder

Use getline() to get a line of user input into a string:

Enter text:  
IDK if I'll go. It's my BFF's birthday. 

Search the string using find() for common abbreviations and replace() them with their long form. In addition, use a for loop to iterate through each character of the string and replace any occurences of '.' with '!':

Enter text:
IDK if I'll go.  It's my BFF's birthday. 

I don't know if I'll go!  It's my best friend forever's birthday!

Use loops for each abbreviation to replace multiple occurrences:

Enter text:
Hi BFF.  IDK where I'm going but it's not going to be with you!  JK you know you're my BFF.  IDK why I just said that.  Anyway, TMI.  Why do I always give people TMI?  IDK.  Alright TTYL bye BFF!

Hi best friend forever!  I don't know where I'm going but it's not going to be with you!  just kidding you know you're my best friend forever!  I don't know why I just said that!  Anyway, too much information!  Why do I always give people too much information!  I don't know!  Alright talk to you later bye best friend forever!

Support these abbreviations:

  • BFF -- best friend forever
  • IDK -- I don't know
  • JK -- just kidding
  • TMI -- too much information
  • TTYL -- talk to you later

Use the predefined constants for each abbreviation BFF, IDK, etc. and each long form BFF_LONG, IDK_LONG, etc. rather than hardcoding strings inside the loop.

In: Computer Science

What is the unsigned hexadecimal equivalent of the following unsigned octal value? Do NOT include in...

What is the unsigned hexadecimal equivalent of the following unsigned octal value?

Do NOT include in your answer ANY insignificant zeros.

107655.643

What is the binary equivalent (in signed-magnitude binary representation) of the following signed decimal value? Represent the integer part of the binary value in 8 bits.

-116.6875

In: Computer Science

JAVA Palindrome Detector A palindrome is any word, phrase, or sentence that reads the same forward...

JAVA Palindrome Detector

A palindrome is any word, phrase, or sentence that reads the same forward or backward. Here are some well-known palindromes:

Able was I, ere I saw Elba

A man, a plan, a canal, Panama

Desserts, I stressed

Kayak

Write a boolean method that users recursion to determine where a String argument is a palindrome. The method should return true if the argument reads the same forward and backward. Demonstrate the method in a program.

Include the following modifications:

  • Use JOptionPanes for all user I/O.
  • Allow the user to input test strings until they type "quit" to exit.

In: Computer Science