Questions
Arithmetic Expression Evaluation Write a program that reads an infix expression (that contains only A, B...

Arithmetic Expression Evaluation
Write a program that reads an infix expression (that contains only A, B and/or C as operands) from
the user and prints out the value of the expression as an output.
Implement the following methods:

o String infixToPostfix(String expr)
Converts the given infix expression expr and returns the corresponding postfix notation
of expr.
o Integer evaluatePostfixExpr(String expr)
Evaluates and returns the value of the given postfix expression expr.

Sample Input/Output #1
Enter your arithmetic expression: A+B-C*A
Enter the value of A: 5
Enter the value of B: 10
Enter the value of C: 2
The postfix expression is AB+CA*-
The above expression evaluates to 5.
Sample Input/Output #2
Enter your arithmetic expression: A+BC
Enter the value of A: 5
Enter the value of B: 10
Enter the value of C: 2
The above expression is invalid and can't be evaluated.


In: Computer Science

Generate 5th order linear recursive sequence using shift registers using the primitive polynomial 1+X^2+x^5

Generate 5th order linear recursive sequence using shift registers using the primitive polynomial 1+X^2+x^5

In: Computer Science

In Java An outlet store is having a sale in their Cabin brand sweaters. There are...

In Java

An outlet store is having a sale in their Cabin brand sweaters. There are two different pricing systems depending on if it is a Cabin brand or not. Tax must be added on after the sweater charge is computed.
You must have two classes using separate files.

Requirements for Sweater Class
Fields
1. sweater price (in dollars)
2. Boolean to indicate if it is a Cabin brand or not
3. number of sweaters purchased
Methods
1.   One 3 parameter constructor- the constructor uses three parameters representing the sweater price, whether it is a Cabin Brand or not, and the number of sweaters purchased.
2.   Getter and setter for each field
3.   getTotalPurchase method
This method must call the appropriate getter member methods where necessary. Do not access the fields directly.
This method calculates and returns the total amount of the sweater.
If the sweater is Cabin brand, calculate the discount as follows;
-If the customer purchases 1 sweater the discount is 20% of the sweaters price.
-if the customer purchases 2 or more sweaters the discount is 30%
-the customer cannot purchase less than 1 sweater.
-compute the purchase subtotal by subtracting the appropriate discount from the sweaters price.
Use a tax rate of 7% of the purchase subtotal to compute the sales tax in dollars. Add the sales tax amount to the purchase subtotal to determine the total purchase amount.
Return the total purchase amount to the calling code.

Requirements for the SweaterDriver Class
Main method
1.   customer must be prompted appropriately
2.   All values related to money may include values after the decimal point. All values displayed to the screen must display with 2 places after the decimal.
3.   The customer must indicate whether the sweater is Cabin brand or not by typing a single character (y for yes, n for no) program must accept Upper and lower case, Y,y,N,n.
4.   If the sweater is Cabin brand, prompt the customer to enter the number of Cabin sweaters being purchased.
5.   Instantiate a Sweater object using a three parameter constructor.
Note that the parameter that indicates if the sweater is a Cabin brand is a Boolean data type.
The customer must type a single character. You will have to use selection to instantiate a Sweater object with the correct data type foe this parameter.
6.   Display the values in the output by calling the appropriate method of the Sweater object. The output must line up at the decimal point as in the sample runs.
Sample runs
1
Enter the price of the sweater: $50.00
Is the swear a Cabin(Y/N)? N

Price of sweater $50.00
Total purchase $53.50

Run 2
Enter the price of the sweater: $60.00
Is the sweater a Cabin(Y/N)? Y
Enter the number of sweaters being purchased: 2
Price of sweater $60.00
Total Purchase $89.88

Run 3

Enter price of sweater: $40.00
Is the sweater a Cabin(Y/N)? Y
Enter the number of sweaters being purchased: 1
Price of sweater $40.00
Total purchase $34.24

In: Computer Science

Task #1 The while Loop (8 pts) 1. Copy the file DiceSimulation.java as directed by your...

Task #1 The while Loop (8 pts) 1. Copy the file DiceSimulation.java as directed by your instructor. Correct syntax errors if any, and improve programming style when necessary (indents, newlines, etc.). DiceSimulation.java is incomplete. Since there is a large part of the program missing, the output will be incorrect if you run DiceSimulation.java. 2. We have declared all the variables. You need to add code to simulate rolling the dice and keeping track of the doubles. Convert the algorithm below into Java code and place it in the main method after the variable declarations, but before the output statements. You will be using several control structures: a while loop and an if-else-if statement nested inside another if statement. Use the indenting of the algorithm to help you decide what is included in the loop, what is included in the if statement, and what isincluded in the nested if-else-if statement. 3. To “roll” the dice, use the nextInt method of the random number generator to generate an integer from 1 to 6. Repeat while the number of dice rolls are less than the number of times the dice should be rolled. Get the value of the first die by “rolling” the first die Get the value of the second die by “rolling” the second die If the value of the first die is the same as the value of the second die If value of first die is 1 Increment the number of times snake eyes were rolled Else if value of the first die is 2 Increment the number of times twos were rolled Else if value of the first die is 3 Increment the number of times threes were rolled Else if value of the first die is 4 Increment the number of times fours were rolled Else if value of the first die is 5 Increment the number of times fives were rolled Else if value of the first die is 6 Increment the number of times sixes were rolled Page 3 of 3 Increment the number of times the dice were rolled 4. Compile and run. You should get numbers that are somewhat close to 278 for each of the different pairs of doubles. Run it several times. You should get different results than the first time, but again it should be somewhat close to 278. Task #2 Using Other Types of Loops: do-while (4 pts) 1. Change the while loop to a do-while loop. 2. Make other necessary changes to save your work as new file named DiceSimulation_Do.java. 3. Compile and run. You should get the same results as at Task #1. Task #3 Using Other Types of Loops: for (4 pts) 1. Change the do-while loop to a for loop. 2. Make other necessary changes to save your work as new file named DiceSimulation_For.java. 3. Compile and run. You should get the same results as at Task #1.

import java.util.Random;   // Needed for the Random class

/**
   This class simulates rolling a pair of dice 10,000 times
   and counts the number of times doubles of are rolled for
   each different pair of doubles.
*/

public class DiceSimulation
{
   public static void main(String[] args)
   {
      final int NUMBER = 10000;  // Number of dice rolls

      // A random number generator used in
      // simulating the rolling of dice
      Random generator = new Random();

      int die1Value;       // Value of the first die
      int die2Value;       // Value of the second die
      int count = 0;       // Total number of dice rolls
      int snakeEyes = 0;   // Number of snake eyes rolls
      int twos = 0;        // Number of double two rolls
      int threes = 0;      // Number of double three rolls
      int fours = 0;       // Number of double four rolls
      int fives = 0;       // Number of double five rolls
      int sixes = 0;       // Number of double six rolls

      // TASK #1 Enter your code for the algorithm here

      // Display the results
      System.out.println ("You rolled snake eyes " +
                          snakeEyes + " out of " +
                          count + " rolls.");
      System.out.println ("You rolled double twos " +
                          twos + " out of " + count +
                          " rolls.");
      System.out.println ("You rolled double threes " +
                          threes + " out of " + count +
                          " rolls.");
      System.out.println ("You rolled double fours " +
                          fours + " out of " + count +
                          " rolls.");
      System.out.println ("You rolled double fives " +
                          fives + " out of " + count +
                          " rolls.");
      System.out.println ("You rolled double sixes " +
                          sixes + " out of " + count +
                          " rolls.");
   }
}

In: Computer Science

write a java program that allows the user to insert two number consists of only 3...

write a java program that allows the user to insert two number consists of only 3 digits and print it and all a number between it but don't print any number that has digits equal to a number 4. like (211,212,213,215,...,350), if the user print number that not equal to 3 digits like ( 23,2298,1) print invalid number

In: Computer Science

In 1-2 pages (a paragraph or so for each item), describe your top 3 security-related takeaways...

In 1-2 pages (a paragraph or so for each item), describe your top 3 security-related takeaways or security insights you noted while reading the book.(cuckoos egg.)

  • These insights can be about anything you noted in the story (chocolate chip recipes do not count, though) whether it is about technology, investigative/(pre)forensic techniques—technical or otherwise, preventative, reactive, collaboration (or lack thereof) between entities/organizations/groups, etc

In: Computer Science

Can you assist me in understand and write the steps in this code? Write a method...

Can you assist me in understand and write the steps in this code?

Write a method named howMany that does not take in any arguments. Use the Scanner class to ask the user to enter a number between 1 and 5. Print One of the following based on their entry.

1    2 3 4 5   Anything Other Number   

“Lonely Num” “Company” "Crowd" "Fun" "Party"     "Only 1 to 5 Please"

In: Computer Science

1) Imagine you are the owner of an e-commerce Web site. a. What are some of...

1) Imagine you are the owner of an e-commerce Web site.

a. What are some of the signs that your site has been hacked?

b. Discuss the major types of attacks you could expect and the resulting damage to your site.

2) Given the shift toward mobile commerce,

a. do a search on mobile commerce crime.

b. Identify and discuss in one page the new security threats this type of technology creates.

In: Computer Science

Write a JavaFx program for addition of two numbers. (create text as Number1, Number2 and Result...

Write a JavaFx program for addition of two numbers. (create text as Number1, Number2 and Result and create 3 textfileds. Create sum button. You have to enter number1 and number2 in the textfileds. If you click the button Sum, the result will be showed in the third text field.

In: Computer Science

write a java code to implement a linked list, called CupList, to hold a list of...

write a java code to implement a linked list, called CupList, to hold a list of Cups.

1.Define and write a Cup node class, called CupNode, to hold the following information about a cup:

•number (cup number)

•capacity (cup capacity in ml)

•Write a method size() that returns the number of elements in the linkedlist CupList.

•Write a method getNodeAt() that returns the reference to cup node object at a specific position given as a parameter of the method.

•Write a method, insertPos(),  to insert a new CupNode object at a specific position given as a parameter of the method.

•Write a method, deletePos(),  to remove the CupNode object at a specific position given as a parameter of the method.

•Write a method, swapNodes,  to swap two nodes at two positions pos1 and pos2 given as parameters of the method.

Implement the Cup list using double linked list.

•Update CupNode class by adding a link to the previous node in the list. Then update the constructor of the class

•Update the CupList by adding a last attribute, to hold the reference to the last node of the list.

•Implement the following methods in CupList isEmpty(), size(), insertAtFront(), insertAtRear(), insertAt(), removeFirst(), removeLast(), removeAt().

  CupNode should have a constructor and methods to manage the above information as well as the link to next node in the list.

2.Define and write the CupList class to hold objects of the class CupNode. This class should define:

a)a constructor,

b)a method isEmpty() to check if the list is empty or not,

c)a method insert() that will allow to insert a new cup node at the end of the list,

d)a method print() that will allow to print the content of the list,

e)A method getCupCapacity() that will return the capacity of a cup given its number. The method should first find out if a cup with that number is in the list.

3.Write a TestCupList class to test the class CupList. This class should have a main method in which you perform the following actions :

a)Create a CupList object,

b)Insert five to six CupNode objects into the created Cup List,

c)Print the content of your cup list,

d)Search for a given cup number in the list and print out its capacity.

In: Computer Science

Write a Python program to simulate a very simple game of 21 •Greet the user. •Deal...

Write a Python program to simulate a very simple game of 21
•Greet the user.
•Deal the user a card and display the card with an appropriate message.
•Deal the user another card and display the card
.•Ask the user if they would like a third card. If so, deal them another card and display the value with an appropriate message.
•Generate a random number between 10 and 21 representing the dealer’s hand. Display this value with an appropriate message.
•If the user’s total is greater than the dealer’s hand and the user’s total is NOT greater than 21, the user wins, otherwise the dealer wins. Display the player’s and the dealer’s totals along with an appropriate message indicating who won.

In: Computer Science

•From the e-Activity, determine what you believe is the most critical component of BCP from FEMA’s...

•From the e-Activity, determine what you believe is the most critical component of BCP from FEMA’s implementation / suggestions for the BCP process. Justify your answer. •Determine whether or not you believe the BCP process would be successful without proper BIA processes being conducted. Explain why or why not

In: Computer Science

Describe your opinion of why some collaborative interfaces, such as email, are much more popular than...

Describe your opinion of why some collaborative interfaces, such as email, are much more popular than others, such as video-conferencing. Compare and contrast your method with at least two of your peers' responses.

In: Computer Science

Write C++ statements that will align the following three lines as printed in two 20 character...

Write C++ statements that will align the following three lines as printed in two 20 character columns.

Item                                                    Price

Banana Split                                                   8.90

Ice Cream Cake                                            12.99

In: Computer Science

CSIS 113A C++ Programming Level1 Rock, Paper, Scissors Introduction In this assignment you will create a...

CSIS 113A C++ Programming Level1

Rock, Paper, Scissors

Introduction

In this assignment you will create a program that will simulate the popular children’s game “Rock, Paper, Scissors”; using only Boolean logic and practice using the for-loop and logical operators as well as continue getting used to data of various types.

Skills: string input/output, data types, logical operators, and control structures

Rock-Paper-Scissors

Rock-Paper-Scissors is a game where two players, on the count of 3, show the rock/paper/scissors symbol with their hand. Rock smashes scissors, scissors cuts paper, and paper covers rock:

Once both players have played valid gestures, there are two ways to determine the winner: one using string comparison and Boolean logic and the other using modular arithmetic; you’ll write a solution using both approaches. For this assignment, only “rock”, “paper”, and “scissors” are considered valid gestures.

Definitions:

1. Valid game: a game in which both players select a valid gesture

2. Invalid game: a game in which a player selects a gesture that is not “rock”, “paper”, or “scissors”. (HINT: DeMorgan’s law will help negation of valid game)

main.cpp

Your program should use a for-loop to play 7 consecutive games (must be a variable) of Rock-PaperScissors determining the winner using only the four decision statements. For each game, your program should:

1) Prompt Player 1 for their selection. The inputs for each game are given below. a. If Player 1 enters an invalid selection you should update the count of invalid games and then begin a new game.

2) Prompt Player 2 for their selection. The inputs for each game are given below.

a) If Player 2 enters an invalid selection you should update the count of invalid games and then begin a new game.

3) If both players have selected a valid gesture determine the winner using string comparison and if/else logic.

4) For each valid game completed, update the count of the number of wins by Player 1, the number of wins by Player 2, or the number of ties as needed.

Test input:

• Game 1: Player one plays “scissors” and Player 2 plays “paper”

• Game 2: Player 1 plays “paper” and Player 2 plays “papers”

• Game 3: Player 1 plays “rock” and Player 2 plays “rock”

• Game 4: Player 1 plays “rocks”

• Game 5: Player 1 play “paper” and Player 2 plays “scissors”

• Game 6: Player 1 plays” scissors” and Player 2 plays “rock”

• Game 7: “Player 1 plays “paper” and Player 2 plays “rock”

Test Run: Your code should look exactly like the one below

Player 1 Enter Selection: scissors

Player 2 Enter Selection: paper

Player 1 Enter Selection: paper

Player 2 Enter Selection: papers

Player 1 Enter Selection: rock

Player 2 Enter Selection: rock

Player 1 Enter Selection: rocks

Player 1 Enter Selection: paper

Player 2 Enter Selection: scissors

Player 1 Enter Selection: scissors

Player 2 Enter Selection: rock

Player 1 Enter Selection: paper

Player 2Enter Selection: rock

=============================

Games Won

=============================

Player 1: 2

Player 2: 2

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Tie Games : 1

Invalid Games : 2

=============================

struct Player{
  String gesture;
  int wins{};
};

int main() {
  // TODO: (1) declare constant for the number of games to play
  
  // TOOO: (2) declare and initailize your other counters here (number of ties, invalid games)
  
  Player player_1;
  Player player_2;
  
  // TODO: (12) wrap in for-loop once working for 1 game. 
  
  // TODO: (3) get user input for player 1, commented out correct code for now, simulating with rock first
  player_1.gesture = "rock";
//   cout << "Player 1 enter selection: ";
//   getlline(cin, player_1.gesture);
  
  // TODO: (5) write a boolean proposition here, finish what it should be, notice how the name reads
  bool gesture_is_rock;
  bool gesture_is_paper;
  bool gesture_is_scissors;
  
  bool is_valid_gesture;
  
  // TDOO: (6) determine if player 1 entered invalid move
  if (!is_valid_gesture) {
    // TODO: (7) what should be done if invalid? How do you continue the loop
    
  }
  
  // TODO: (8) Do the exact same for Player 2 reusing the boolean variables 
  
  // TODO: (9) Determine if there was a tie, otherwise, there was a win
  bool is_tied_game;
  
  if (is_tied_game) {
    // TODO: (10) what should be done if tie?
    
  }
  else {
    // TODO: (11) consider how player one can win:
    bool player_1_wins;
    
    if (player_1_wins) {
    }
    else {
    }
  }
  
   // TODO: (4) Setup the way the output should be displayed based on the document

  return 0;
}

In: Computer Science