Questions
What is an alternate configuration to an acitve-passive clustering configuration. Why would you use that instead...

What is an alternate configuration to an acitve-passive clustering configuration. Why would you use that instead of active -passive.

In: Computer Science

Write an implementation of the ADT stack that uses a resizeable array to represent the stack...

Write an implementation of the ADT stack that uses a resizeable array to represent the stack items. Anytime the stack becomes full, double the size of the array. Maintain the stack's top entry at the beginning of the array.

Use c++ to write this code.

In: Computer Science

A restaurant sells packs of chicken nuggets in various denominations. Using octave, Write a script that...

A restaurant sells packs of chicken nuggets in various denominations. Using octave, Write a script that prompts the user for a vector of the available pack denominations. The script should then prompt the user for a vector of quantities of each denomination to be purchased. Finally, the script should calculate and print the total number of chicken nuggets that would be obtained from the purchase. Hint: Note that if you multiply (in the linear algebra sense) a 1 × n row vector and an n × 1 column vector you obtain a scalar: h a1 a2 a3 · · · an i          b1 b2 b3 . . . bn          = a1b1 + a2b2 + a3b3 + · · · anbn. Sample output: Enter the denominations in which chicken nuggets are available: [ 6 9 20 ] Enter the quantity of each denomination to be purchased: [ 1 1 1 ] The total number of chicken nuggets purchased is 35 Enter the denominations in which chicken nuggets are available: [ 4 10 50 8 ] Enter the quantity of each denomination to be purchased: [ 2 0 1 0 ] The total number of chicken nuggets purchased is 58. Also, use disp to print entire vectors of numbers.

In: Computer Science

C++ 11.7: Customer Accounts Write a program that uses a structure to store the following data...

C++

11.7: Customer Accounts Write a program that uses a structure to store the following data about a customer account: Customer name Customer address City State ZIP code Telephone Account balance Date of last payment The program should use an array of at least 20 structures. It should let the user enter data into the array, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven user interface. Prompts And Output Labels. Your main menu should be the following: 1. Enter new account information 2. Change account information 3. Display all account information 4. Exit the program The user is expected to enter 1 or 2 or 3 or 4. The main menu is displayed at the start of the program and after the handling of choices 1, 2 and 3. If 1 is entered for the main menu, the program prompts for each of the data listed above, in the order listed above, using the above data descriptions (e.g. "ZIP code") as prompts (followed in each case by a colon). After reading in and processing the data, the program prints You have entered information for customer number X where X is the customer number: 0 for the first customer and increasing by 1 for each subsequent customer that is entered. If 2 is entered for the main menu, the program prompts for the customer number: Customer number: Upon entering a valid customer number the program displays all the data for the particular customer that has been saved: Customer name: ... Customer address: ... City: ... State: ... ZIP code: ... Telephone: ... Account balance: ... Date of last payment: ... The program then skips one or two lines and prompts for a change, using the same prompts as in choice 1 above for all the data items associated with a customer. If 3 is entered for the main menu, the program displays all the data for each customer that has been saved, using the display format in choice 2 above. After the display of each customer the program prompts "Press enter to continue..." and waits for the user to hit return. If 4 is entered for the main menu, the program terminates. Input Validation (OPTIONAL).When the data for a new account is entered, be sure the user enters data for all the fields. No negative account balances should be entered.

.make sure it good with codelab

In: Computer Science

In java Step 1) Assume that you have tracked monthly BSIT inquires for 10 months. Save...

In java

Step 1) Assume that you have tracked monthly BSIT inquires for 10 months. Save the following data into a text file in notepad in the order listed 40 22 17 35 28 17 22 28 25 19

Step 2) Write a java program that reads the monthly BSIT inquires for 10 months from the text file that you created in step 1. Read the monthly inquires from the input file into an array in one execution of the program. Write a sort method to sort the inquiry values lowest to highest. Write a method to calculate the average of the monthly inquiries. Write a method to determine the maximum value. Your program should call the sort, average and maximum methods. Create an output file to which you write the sorted array output, the average value and maximum value.

In: Computer Science

This is for Python programming, and I am trying to use 2 for loops to ask...

This is for Python programming, and I am trying to use 2 for loops to ask a slaesperson how many of 5 different items they sold, then the program is to calculate the total dollar amount sold. Formatting and all that aside, I am having an issue with the loops not stepping through the 2 lists at the same time. The first loop is taking all 5 entered quantities times the price of the first item, and then all 5 quantities times the price of the 2nd item, etc. I need to get Item1 * Quant1, Item2 * Quant2, etc.

Item1 = 2.5
Item2 = 1.98
Item3 = 5.75
Item4 = 3.45
Item5 = 4.0
  
Quant1 = int(input("Enter the quantity of Item1 sold: "))
Quant2 = int(input("Enter the quantity of Item2 sold: "))
Quant3 = int(input("Enter the quantity of Item3 sold: "))
Quant4 = int(input("Enter the quantity of Item4 sold: "))
Quant5 = int(input("Enter the quantity of Item5 sold: "))
for Item in [Item1, Item2, Item3, Item4, Item5]:
for Quant in [Quant1, Quant2, Quant3, Quant4, Quant5]:
Cost = float(Quant * Item)
print (Cost)

In: Computer Science

Create an object call Accounts using python for a banking system. Initialize the account with three...

Create an object call Accounts using python for a banking system.
Initialize the account with three data as inputs : Firstname, Lastname and initial deposit. Create 4 additional member functions: Deposit, Withdraw, Fee Calculations, interest
The fee calculation is going to be $14 per month if the total amount in the account is less than $1000. Interest is set to be at 5%.

In: Computer Science

C++ 11.11: Customer Accounts A student has established the following monthly budget: 500.00 Housing 150.00 Utilities...

C++

11.11: Customer Accounts A student has established the following monthly budget: 500.00 Housing 150.00 Utilities 65.00 Household 50.00 Expenses 50.00 Transportation 250.00 Food 30.00 Medical 100.00 Insurance 150.00 Entertainment 75.00 Clothing 50.00 Miscellaneous Write a program that has a MonthlyBudget structure designed to hold each of these expense categories. The program should pass the structure to a function that asks the user to enter the amounts spent in each budget category during a month. The program should then pass the structure to a function that displays a report indicating the amount over or under in each category, as well as the amount over or under for the entire monthly budget. NOTES: For each of the categories listed above, and in that order, the program prompts the user for the the amount spent on X: where X is a category from the above list (e.g. "Insurance"). Using the values read into the structure, the program generates a table with a heading and in each row there are four items: the category (e.g. "Housing"), followed by the value budgeted for the category (500.00 in the case of Housing), followed by the value that had been read in for that category, followed by the amount that the actual spent was over or under the category budget. Finally, after the table, is an indication of whether the student is over or under budget.

make sure it works with codelab

In: Computer Science

the first few hops are the same for various websites? . Then briefly describe what is...

the first few hops are the same for various websites?

  1. . Then briefly describe what is the reason of having the same hops for different destinations.
  2. Need help understanding why using Tracer T certain websites have the some of the same route steps but different destinations. Thank you

In: Computer Science

Write a code to ask for a vector with 10 elements from the user and replace...

  1. Write a code to ask for a vector with 10 elements from the user and replace the 1st, 3rd, 8th  to 9th  elements with the second element of the given vector. (you can insert a vector when you use input function)

In: Computer Science

At the college, two subnetworks have been set up: Subnet A: 192.168.22.64/26 Subnet B: 192.168.22.128/26 The...

At the college, two subnetworks have been set up:

  • Subnet A: 192.168.22.64/26
  • Subnet B: 192.168.22.128/26

The network administrator has connected several end-devices to these networks. A device is misconfigured. You are asked to identify this device.

a) An IP camera in network B with the following configuration: 192.168.22.129/26

b) A workstation in network B with the following configuration: 192.168.22.175/255.255.255.192

c) A printer in network A with the following configuration: 192.168.22.65/26

d) An IP camera in network B with the following configuration: 192.168.22.191/26

e) An IP camera in network A with the following configuration: 192.168.22.68/255.255.255.192

f) A laptop in network A with the following configuration: 192.168.22.117/255.255.255.192

g) An IP phone in network B with the following configuration: 192.168.22.170/255.255.255.192

h) A desktop in network A with the following configuration: 192.168.22.98/26

In: Computer Science

Java please. A stack machine executes programs consisting of arithmetic commands that manipulate an internal stack....

Java please.

A stack machine executes programs consisting of arithmetic commands that manipulate an internal stack.

The stack is initially empty.

The commands are:

push N  ; push N onto the stack (N is any Double)

pop     ; removes top element from a stack

add     ; replace top two elements of the stack by their sum

mul     ; replace top two elements of the stack by their product

sub     ; replace top two elements of the stack by their difference: [a, b, ... ] => [a-b, ... ]

div     ; replace top two elements of the stack by their quotient: [a, b, ... ] => [a/b, ... ]

For example, the following program computes 23:

(push 1, push 2, mul, push 2, mul, push 2, mul)

The following types of exceptions are thrown by the stack machine:

stack empty

stack too short (not enough elements to complete the operation)

divide by 0

syntax error

Part 1

Implement a generic stack class for the stack machine:

class Stack<T> { ??? }

Notes

·You will need to implement the following methods: push, pop, top, clear, and toString.

·pop and top may throw EmptyStack exceptions

·How will you store the elements in the stack? List? Set?

Part 2

Implement your design using your solution for part 2.

Notes

·Executing arithmetic commands may throw ShortStack exceptions if there aren't at least two elements on the stack.

·div may throw a DivByZero exception. Restore the stack before throwing this exception.

·Consider making the execute method and stack in your StackMachine class static. Then, commands can make static references to the stack without needing to have an association to the stack machine.

·The execute method of StackMachine should have separate catch clauses for each type of exception. For now it just prints the exception but in the future we could potentially have different strategies for each type of exception caught.

·After the last command is execute the stack machine should print the stack.

·Before the first command is execute the stack machine should clear the stack.

Here is my code, but I am stuck here. Please help.

class Program{
   List<Command> commands;
   void excute() throws StackMachineException{
       for(Command c: commands)
           c.excute();
   }
}
class Add extends Command{
   void excute() throws StackMachineException{
      
   }
}
class Command{
  
  
}
class Stack<T>{
  
}
class StackMachineException{
  
  
}
public class StackMac {
   public Stack<Double> stack;
  
   void excute(Program p)
   {
      
   }
}

And here is the test code

public class StackMackTests {

        // f() = 5x^2 - 3
        public static void test0(Double x) {
                // create an empty program
                Program p = new Program();
                // add commands to p:
                p.add(new Push(3.0));
                p.add(new Push(x));
                p.add(new Push(x));
                p.add(new Push(5.0));
                p.add(new Mul());
                p.add(new Mul());
                p.add(new Sub());
                // now execute
                StackMachine.execute(p);
        }

        // f(x) = x^3 + 3x^2 - 2x + 1
        public static void test1(Double x) {
                // ???
        }

        public static void main(String[] args) {
                test1(2.0); // [17.0]
                test1(5.0); // [191.0]

                test0(2.0); // [17.0]
                test0(4.0); // [77]
        }

}

In: Computer Science

C++ Zybook Lab 15.4 Zip code and population (class templates) Complete the TODOs in StatePair.h and...

C++ Zybook Lab

15.4 Zip code and population (class templates)

Complete the TODOs in StatePair.h and main.cpp.

StatePair.h

Define a class StatePair with two template types (T1 and T2), and constructor, mutators, accessors, and PrintInfo() member functions which will work correctly with main.cpp. Note, the three vectors (shown below) have been pre-filled with StatePair data in main() and do not require modification.

  • vector<StatePair <int, string>> zipCodeState: ZIP code - state abbreviation pairs
  • vector<StatePair<string, string>> abbrevState: state abbreviation - state name pairs
  • vector<StatePair<string, int>> statePopulation: state name - population pairs

main.cpp

Complete main() to:

  • Use an input ZIP code to retrieve the correct state abbreviation from the vector zipCodeState.
  • Then, use the state abbreviation to retrieve the state name from the vector abbrevState.
  • Then, use the state name to retrieve the correct state name/population pair from the vector statePopulation and,
  • Finally, output the pair.

For FULL CREDIT on this assignment, the member functions for StatePair MUST be written outside the class StatePair { ... }; context as indicated by the TODO comments.

Ex: If the input is: 21044 the output is: Maryland: 6079602

Here's the code:

//StatePair.h

#ifndef STATEPAIR
#define STATEPAIR

template<typename T1, typename T2>
class StatePair {

// TODO: Define signatures ONLY for a constructor, mutators,
// and accessors for StatePair which work with main.cpp
// as written
  
// TODO: Define a signature for the PrintInfo() method

// TODO: Define data member(s) for StatePair
};

// TODO: Complete the implementations of the StatePair methods

#endif

//main.cpp

#include<iostream>
#include <fstream>
#include <vector>
#include <string>
#include "StatePair.h"
using namespace std;

int main() {
   ifstream inFS; // File input stream
   int zip;
   int population;
   string abbrev;
   string state;
   unsigned int i;

   // ZIP code - state abbrev. pairs
   vector<StatePair <int, string>> zipCodeState;

   // state abbrev. - state name pairs
   vector<StatePair<string, string>> abbrevState;

   // state name - population pairs
   vector<StatePair<string, int>> statePopulation;

   // Fill the three ArrayLists

   // Try to open zip_code_state.txt file
   inFS.open("zip_code_state.txt");
   if (!inFS.is_open()) {
       cout << "Could not open file zip_code_state.txt." << endl;
       return 1; // 1 indicates error
   }
   while (!inFS.eof()) {
       StatePair <int, string> temp;
       inFS >> zip;
       if (!inFS.fail()) {
           temp.SetKey(zip);
       }
       inFS >> abbrev;
       if (!inFS.fail()) {
           temp.SetValue(abbrev);
       }
       zipCodeState.push_back(temp);
   }
   inFS.close();
  
// Try to open abbreviation_state.txt file
   inFS.open("abbreviation_state.txt");
   if (!inFS.is_open()) {
       cout << "Could not open file abbreviation_state.txt." << endl;
       return 1; // 1 indicates error
   }
   while (!inFS.eof()) {
       StatePair <string, string> temp;
       inFS >> abbrev;
       if (!inFS.fail()) {
           temp.SetKey(abbrev);
       }
       getline(inFS, state); //flushes endline
       getline(inFS, state);
       state = state.substr(0, state.size()-1);
       if (!inFS.fail()) {
           temp.SetValue(state);
       }
      
       abbrevState.push_back(temp);
   }
   inFS.close();
  
   // Try to open state_population.txt file
   inFS.open("state_population.txt");
   if (!inFS.is_open()) {
       cout << "Could not open file state_population.txt." << endl;
       return 1; // 1 indicates error
   }
   while (!inFS.eof()) {
       StatePair <string, int> temp;
       getline(inFS, state);
       state = state.substr(0, state.size()-1);
       if (!inFS.fail()) {
           temp.SetKey(state);
       }
       inFS >> population;
       if (!inFS.fail()) {
           temp.SetValue(population);
       }
       getline(inFS, state); //flushes endline
       statePopulation.push_back(temp);
   }
   inFS.close();
  
   cin >> zip;

for (i = 0; i < zipCodeState.size(); ++i) {
       // TODO: Using ZIP code, find state abbreviation
       if(zipCodeState.at(i).SetValue() == zip)
{
abbrev = zipCodeState.at(i).SetValue();
break;
}
   }


   for (i = 0; i < abbrevState.size(); ++i) {
       // TODO: Using state abbreviation, find state name
       if(abbrevState.at(i).SetValue() == abbrev){
state = abbrevState.at(i).SetValue();
break;
}
   }


   for (i = 0; i < statePopulation.size(); ++i) {
       // TODO: Using state name, find population. Print pair info.
       if(statePopulation.at(i).SetValue() == state){
statePopulation.at(i).PrintInfo();
break;
}
   }

}

In: Computer Science

For this assignment, you will apply what you learned in analyzing Java™ code so far in...

For this assignment, you will apply what you learned in analyzing Java™ code so far in this course by writing your own Java™ program. The Java™ program you write should do the following:

  • Accept user input that represents the number of sides in a polygon. Note: The code to do this is already written for you.
  • If input value is not between 3 and 5, display an informative error message
  • If input value is between 3 and 5, use a switch statement to display a message that identifies the correct polygon based on the number of sides matching the input number (e.g., triangle, rectangle, or polygon)

Complete this assignment by doing the following:

  1. Download and unzip the linked Week Two Coding Assignment Zip File.
  2. Read the file carefully, especially the explanatory comments of what the existing code does.
  3. Add your name and the date in the multi-line comment header.
  4. Refer to the following linked Week Two Recommended Activity Zip File to see examples of how to code all of the Java™ statements (i.e., switch, println(), and if-then-else) you will need to write to complete this assignment.
  5. Replace the following lines with Java code as directed in the file:
  • LINE 1
  • LINE 2
  1. Comment each line of code you add to explain what you intend the code to do.
  2. Test and modify your Java™ program until it runs without errors and produces the results as described above.

Program: PRG/420 Week 2
* Purpose: Week 2 Coding Assignment
* Programmer: Iam A. Student   
* Class: PRG/420   
* Creation Date: 10/18/17
*********************************************************************
*
**********************************************************************
* Program Summary: This program demonstrates these basic Java concepts:
* - defining variables of different types
* - if-then and if-then-else logic
* - constructing a string to display onscreen
* - switch logic
*
* To complete this assignment, you will add code where indicated. The
* behavior of your completed assignment should be to accept an input
* value for the number of sides of a two-dimensional figure. Based on that value,
* your code should display the type of figure that corresponds to the number of polygon angles
* indicated (3=triangle, 4=rectangle, etc.)
*
* Here are the specific requirements:
*
* After the user types in a value from 3 to 5 inclusive (i.e., 3, 4, or 5):
*
* 1. Your code determines whether the input value is out of range (less than 3 or more than 5)
* and, if so, displays a meaningful error message on the screen and ends the program.
*
* 2. Because you will be comparing a single expression (the input value) to multiple constants (3, 4, and 5),
* your code should use a switch statement to display the following message onscreen:
*
* If user inputs 3, onscreen message should say "A triangle has 3 sides."
* If user inputs 4, onscreen message should say "A rectangle has 4 sides."
* If user inputs 5, onscreen message should see "A pentagon has 5 sides."
*
* 3. Be sure to test your program. This means running your program multiple
* times with test values 3, 4, 5, as well as at least two values that fall outside that range
* (one lower than the lowest and one higher than the highest) and making sure
* that the correct message displays for each value you input. Also be sure
* that running your program does not cause any compiler errors.
***********************************************************************/
package week2codingassignment;

import java.util.Scanner;

public class PRG420Week2_CodingAssignment {

public static void main(String[] args) {

String userInputStringOfAngles; // Declare a variable of type String to capture user input
int numberOfAngles; // Declare a variable of type int to hold the converted user input

Scanner myInputScannerInstance = new Scanner(System.in); // Recognize the keyboard
System.out.print("Please type the integer 3, 4, or 5 and then press Enter: "); // Prompt the user
userInputStringOfAngles= myInputScannerInstance.next(); // Capture user input as string
numberOfAngles = Integer.parseInt(userInputStringOfAngles); // Convert the string to a number in case this will be useful later
  
// LINE 1. CODE TO DETERMINE WHETHER USER INPUT IS OUT OF BOUNDS GOES HERE
  
  
// LINE 2. SWITCH CODE TO PRINT CORRECT "SHAPE" MESSAGE BASED ON USER INPUT GOES HERE
  

}
}

In: Computer Science

A network administrator has a block of IP addresses: 10.5.4.0/23. From this block of IP addresses,...

A network administrator has a block of IP addresses: 10.5.4.0/23. From this block of IP addresses, he created 32 subnets of the same size with a prefix of /28. He wants to determine the directed broadcast address for each subnet. He wrote down a list of possible broadcast addresses. Select the IP addresses that do not correspond to a broadcast address for any subnets he created. Choose two options.

a) 10.5.5.207

b) 10.5.5.159

c) 10.5.5.7

d) 10.5.4.78

e) 10.5.4.47

f) 10.5.4.95

In: Computer Science