Questions
Write a program in Python to practice evaluating some logical expressions and determine whether the expressions...

Write a program in Python to practice evaluating some logical expressions and determine whether the expressions are equivalent.

  1. Read in a 0 or 1 integer value for each of the following variables: A, B, C, and D.

  1. Use an if…else statement to change the 0 and 1 integer values into True and False Boolean values. Booleans in Python have to have this capitalization (True/False, not true/false or TRUE/FALSE) and shouldn’t contain double quotes (which makes them a String instead of a Boolean).

  1. Use the converted True/False values to compute:

(( A ¬C) D)

in your code.

  1. Use the values to compute:

(( ¬A) B)

in your code.   HINT: There no Boolean in Python. How would you write the code for the operator using if statements and the 3 standard Boolean operators: AND, OR, and NOT?

  1. Check to make sure that your program successfully calculates the result of both expressions.

  1. If the truth values for the entered combination of A, B, C, and D values is the same for both expressions, (( A ¬C) D ) and (( ¬A) B), print a message saying: “matches”

Otherwise print a message saying “untrue.” At this stage, your program will produce just one line of output per run.

  1. We know that the operator produces an answer of true ONLY when the two expressions produce the same result for EVERY combination of input values.

Change your program so instead of asking the user to enter an A, B, C, and D value, the computer uses loops to iterate through all the possible combinations of A, B, C, and D values. HINT: What possible values can A take on? What possible values can B take on? Nested loops will be your friend here.

For each set of A, B, C, and D values, print these input values on one line along with the computed match/untrue message for that line.   

Example: (( A ¬C) D)

Input                                 express 1           express 2           result

0      0      0      0              0                      1                      untrue

0      0      0      1              1                      1                      matches

…..

  1. After all of the possible combinations of input have been considered, print a message saying “equivalent” if you find that the two expressions are equivalent. Print a message saying “not equivalent” if you find that the two expressions are not equivalent.

In: Computer Science

Write a C program that, given a file named Program_2.dat as input, determines and prints the...

Write a C program that, given a file named Program_2.dat as input, determines and prints the following information:

  1. The number of characters in the file.
  2. The number of uppercase letters in the file.
  3. The number of lowercase letters in the file.
  4. The number of words in the file.
  5. The number of lines in the file.

Your program should assume that the input file, Program_2.dat, may contain any text whatsoever, and that text might be, or might not be, the excerpt from A Tale of Two Cities shown below.

  • Your program's input and output must look as much as possible like the sample run shown below (including, but not necessarily limited to, wording, punctuation, horizontal & vertical spacing, and indentation).

Assume that the program will be tested  using gcc (GCC) 8.2.0.

Sample Run # 1

When file Program_2.dat is present in the current working directory.

        Program_2_jeffsolheim.c  14 FEB 2019

        This program reads text from Program_2.dat and determines:

                1.  The number of characters in the file.
                2.  The number of uppercase letters in the file.
                3.  The number of lowercase letters in the file.
                4.  The number of words in the file.
                5.  The number of lines in the file.

        The file Program_2.dat contains:

                631 characters

                4 uppercase letters

                471 lowercase letters

                119 words

                17 lines

Sample Run # 2

When file Program_2.dat is not present in the current working directory.

        Program_2_jeffsolheim.c  14 FEB 2019

        This program reads text from Program_2.dat and determines:

                1.  The number of characters in the file.
                2.  The number of uppercase letters in the file.
                3.  The number of lowercase letters in the file.
                4.  The number of words in the file.
                5.  The number of lines in the file.

        Error! Failed to open Program_2.dat!

Sample Input File

It was the best of times,
it was the worst of times,
it was the age of wisdom,
it was the age of foolishness,
it was the epoch of belief,
it was the epoch of incredulity,
it was the season of Light,
it was the season of Darkness,
it was the spring of hope,
it was the winter of despair,
we had everything before us,
we had nothing before us,
we were all going direct to Heaven,
we were all going direct the other way--
in short, the period was so far like the present period, that some of
its noisiest authorities insisted on its being received, for good or for
evil, in the superlative degree of comparison only.

In: Computer Science

Assume that a mad scientist has created a computer that has 9 bit registers. The most...

Assume that a mad scientist has created a computer that has 9 bit registers. The most significant bit is the sign bit. He wants to execute the following operation using 9 bit register.

-256-2

Use 2's complement method (in binary) to find the result of the above operation in binary system. Show the computations in the answer.

In: Computer Science

Write a program (preferably in Java) that, given an arithmetic expression, first transforms it to a...

Write a program (preferably in Java) that, given an arithmetic expression,

  • first transforms it to a postfix form, and then computes its value (by using stack-based algorithms).

Assume that all the numbers in the arithmetic expression are one-digit numbers, i.e., each of these numbers is either 0, or 1, or 2, ..., or 9. For example, your program should correctly process expressions like 2+3*4, but there is no need to process expressions like 11+22.

In: Computer Science

Implement a Composite Design Pattern for the code below that creates a family tree MAIN: public...

Implement a Composite Design Pattern for the code below that creates a family tree

MAIN:

public class Main {
public static void main(String[] args) {
/* Let's create a family tree (for instance like one used on genealogy sites).
For the sake of simplicity, assume an individual can have at most two children.
If an individual has 1-2 children, they are considered a "tree". If an individual
does not have children, they are considered a "person".
With that in mind, let's populate a family tree with some data. */

Person p1 = new Person(1);
Person p2 = new Person(2);
Person p3 = new Person(3);
Person p4 = new Person(4);

Tree t1 = new Tree(p1, 1);
Tree t2 = new Tree(p2, p3, 2);
Tree t3 = new Tree(t1, p4, 3);
Tree t4 = new Tree(t3, t2, 4);
  
t4.print();
}
}

PERSON:


public class Person {
String name;
  
public Person(int num) {
name = "person" + num;
}
  
public void print() {
System.out.println(name);
}
}

TREE:


public class Tree {
private String name;
  
private Tree tree1;
private Tree tree2;
  
private Person person1;
private Person person2;

public Tree(Person p1, int num) {
tree1 = null;
tree2 = null;
person1 = p1;
person2 = null;
name = "tree" + num;
}

public Tree(Tree t1, int num) {
tree1 = t1;
tree2 = null;
person1 = null;
person2 = null;
name = "tree" + num;
}

public Tree(Tree t1, Tree t2, int num){
tree1 = t1;
tree2 = t2;
person1 = null;
person2 = null;
name = "tree" + num;
}
  
public Tree(Tree t1, Person p2, int num){
tree1 = t1;
tree2 = null;
person1 = null;
person2 = p2;
name = "tree" + num;
}
  
public Tree(Person p1, Person p2, int num){
tree1 = null;
tree2 = null;
person1 = p1;
person2 = p2;
name = "tree" + num;
}
  
public void print() {
System.out.println(name);
if (tree1 != null) {
tree1.print();
}
if (tree2 != null) {
tree2.print();
}
if (person1 != null) {
person1.print();
}
if (person2 != null) {
person2.print();
}
}
}

In: Computer Science

In Modern Infrastructure strategy there are 2 basic models to consider. Keep in mind choosing the...

In Modern Infrastructure strategy there are 2 basic models to consider. Keep in mind choosing the best for the business is the right strategic decision. There is also a 3rd a hybrid or combination model.

Model 1-Traditional onsite of co-located data center facility. This houses your network, storage and compute technologies. You purchase and manage the equipment and your entire network/compute environment yourself.

Model 2-Newer Cloud or SAS model. In this model all the network, comput, storage lives in the cloud or at a service provider's datacenter. It's model 1 but your paying someone to host and maintain the environment for you.

**Compare and contrast the 2. What is the right strategy for a smaller start-up firm? What about a larger more established firm. Support your arguments and create a strength and weakness argument for each small vs larger firm. Remember concerns like cost, scale, security etc-as discussed in class.***

{Please focus more on the bottom part with the stars. A thorough explanation is appreciated.}

In: Computer Science

Consider the following list of names: PEVAC, MARKOV, ZLATAREVA, ABDOLLAHZADEH, CHEN, WILLIAMS, ALBAYRAM, KURKOVSKY, ZABIHIMAVAN. Use...

Consider the following list of names: PEVAC, MARKOV, ZLATAREVA, ABDOLLAHZADEH, CHEN, WILLIAMS, ALBAYRAM, KURKOVSKY, ZABIHIMAVAN. Use Radix sort to sort them in alphabetic order. How many passes would be made through the outer while loop? Trace the contents of the list after each of these passes

In: Computer Science

In Java and using JavaFX, write a client/server application with two parts, a server and a...

In Java and using JavaFX, write a client/server application with two parts, a server and a client. Have the client send the server a request to compute whether a number that the user provided is prime. The server responds with yes or no, then the client displays the answer.

In: Computer Science

OBJECTIVE-C For this program a teacher needs to be able to calculate an average of test...

OBJECTIVE-C

For this program a teacher needs to be able to calculate an average of test scores for students in their course. Your program must ask the Professor ho many students and how many tests will be averaged per student. Your program should then allow the Professor to enter scores for each student one at a time and then average those scores together. For example, if a student has 5 scores to be entered and the scores are 80, 60, 65,98, and 78 the average should be 76.2%

Here is what I got.

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{

int students, numOfScores, scores, sum;
float average;
NSLog(@"Enter number of students");
scanf("%i", &students);
NSLog(@"Enterh number of scores");
scanf("%i", &numOfScores);
int n;
int s;
for (n = 1; n <= students; n++){
for (s = 1; s <= numOfScores; s++)
{

NSLog(@"Enter the score");
scanf("%i", &scores);
sum = sum + scores;   
}
  
}
average = (float) sum / numOfScores;
NSLog(@"An average score is %f", &average);

return 0;
}

In: Computer Science

----------USING JAVA----------- Your objective is to beat the dealer's hand without going over 21. Cards dealt...

----------USING JAVA-----------

Your objective is to beat the dealer's hand without going over 21.

  • Cards dealt (randomly) are between 1 and 11.
  • You receive 2 cards, are shown the total, and then are asked (in a loop) whether you want another card.
  • You can request as many cards as you like, one at a time, but don't go over 21. (If you go over 21 it should not allow you any more cards and you lose)
  • Determine the dealer's hand by generating a random number between 1 and 11 and adding 10 to it.
  • Compare your hand with the dealer's hand and indicate who wins (dealer wins a draw)

Thank you!

In: Computer Science

40. suppose I am modeling a bank. For a CUSTOMER entity, explain why a customer's social...

40. suppose I am modeling a bank. For a CUSTOMER entity, explain why a customer's social security number is a better identifier than (LastName, FirstName).

39. Suppose I want to model an online retailer. Customers may choose to have the order delivered to one of multiple addresses which are saved in the database.

What type of attribute does "Address" represent and how should I handle it in my model. You do not need to include any discussion of cardinalities as part of your answer.

In: Computer Science

What is the difference between Fact and Query in a logic programming language?

What is the difference between Fact and Query in a logic programming language?

In: Computer Science

Write a program which accepts a sequence of comma-separated numbers from console and generate a list...

Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number. Suppose the following input is supplied to the program: 34, 67, 55, 33, 12, 98. Then, the output should be: ['34', '67', '55', '33', '12', '98'] and ('34',67', '55', '33', '12', '98'). Input can be comma separated in one line.

In: Computer Science

(1) Prompt the user for a string that contains two strings separated by a comma. (1...

(1) Prompt the user for a string that contains two strings separated by a comma. (1 pt)

  • Examples of strings that can be accepted:
    • Jill, Allen
    • Jill , Allen
    • Jill,Allen

Ex:

Enter input string:
Jill, Allen


(2) Print an error message if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two strings. (2 pts)

Ex:

Enter input string:
Jill Allen
Error: No comma in string.

Enter input string:
Jill, Allen


(3) Extract the two words from the input string and remove any spaces. Store the strings in two separate variables and output the strings. (2 pts)

Ex:

Enter input string:
Jill, Allen
First word: Jill
Second word: Allen


(4) Using a loop, extend the program to handle multiple lines of input. Continue until the user enters q to quit. (2 pts)

Ex:

Enter input string:
Jill, Allen
First word: Jill
Second word: Allen

Enter input string:
Golden , Monkey
First word: Golden
Second word: Monkey

Enter input string:
Washington,DC
First word: Washington
Second word: DC

Enter input string:
q

_________________________

Given code to work with: main.cpp

#include <iostream>
#include <string>
using namespace std;

int main() {

/* Type your code here. */
  
return 0;
}

thanks.

In: Computer Science

A prime number (or prime) is a natural number greater than 1 that has no posítive...

A prime number (or prime) is a natural number greater than 1 that has no posítive divisors other than 1 and itself. Write a Python program which takes a set of positive numbers from the input and returns the sum of the prime numbers in the given set. The sequence will be ended with a negative number.

In: Computer Science