Questions
Lab Text Manipulation Inside the main method, do the following: Create an ArrayList of strings and...

Lab Text Manipulation

Inside the main method, do the following:

  • Create an ArrayList of strings and call it parks.
  • Read in the names of national parks from the user until the user enters done(or DONE,
    or dOnE, .. ) Keep in mind, that the names of some national parks consist of more than one word, for example, Mesa Verde.
    As you read in the national parks, add them to the list.
  • Next, we are going to build a string based on the elements in the list parks. Since the text keeps changing as we add one park at a time, we use class StringBuilder for this task.
    • Use a StringBuilder called sb to create the string  nationalParks .
    • Loop through all the elements of the list  parks and add them one at a time.
      The resulting string should have the following format:
      Favorite National Parks: {park1} | {park2} | . . . | {parkN}
      The parks are separated by a space, a vertical bar, and another space. However, there is no vertical bar after the last element. {park1}, {park2}, {parkN} are the various list elements with updated spelling.
    • Create a private method to update the spelling.
      We can't control whether the user enters the park names in uppercase or lowercase letters. However, we can change the names to a spelling where all letters are lowercase except for the first letters of each individual word. In order to make those changes, create a private method called updateSpelling. It has the following method header:
      private static String updateSpelling(String text)
      E.g.: When you pass the string "MESA VERDE" the method returns "Mesa Verde"
      E.g.: When you pass "yEllOwstOnE" it returns "Yellowstone"
      E.g.: Passing "black canyon of the gunnison" returns "Black Canyon Of The Gunnison"
      E.g.: Passing "Denali" returns "Denali"
    • When you are done building the specified string in SringBuilder, print it.

The output depends on the information provided by the user.

Please enter your favorite National Park or DONE to stop: mesa verde
Please enter your favorite National Park or DONE to stop: black CANYON of ThE gunnisON
Please enter your favorite National Park or DONE to stop: DENALI
Please enter your favorite National Park or DONE to stop: yellowStone
Please enter your favorite National Park or DONE to stop: Done

Favorite National Parks: Mesa Verde | Black Canyon Of The Gunnison | Denali | Yellowstone

In: Computer Science

Program #1: You will be writing code for several different examples of conditional execution. Each example...

Program #1: You will be writing code for several different examples of conditional execution. Each example should be written as a unique method. Each method should include a method header. So the basic outline of your code is: public class Branching { /** * This is an example method header. Notice how it's multi-line and written * using college-level English and not fragments - this is for the Human to * read and not the compiler to parse, so be verbose here. The purpose of this * main method is call the methods written for each of the parts of the *assignment. */ public static void main(String[] args) { methodA(); } public static void methodA() { /** *methodA header */ } A. Prompt the user with: "Enter a whole number". a. Determine if the number is negative and if so, print: "The number is negative." b. Determine if the number is positive and if so, print: "The number is positive." B. Ask the user for another whole number, and then determine if the number is even or odd. a. Hint: modulo might help. b. Print out a message that includes the number the user input as well as indicating if the number the user input was odd or even. C. Ask the user for a temperature, stored as an integer. Write an if/else statement that asks: Is the temperature higher than 78 degrees? If it is not, is the temperature less than (or equal to) 78 degrees? a. Describe the current temperature as “higher than 78 degrees” or “less than or equal to 78 degrees” D. Prompt the user for a letter grade and store this in a char. Then, write a multi-way if statement that ends in a tail-test, that asks the following questions: Is the grade an “A”? Else is the grade a “B”? Else is the grade a “C”? Else is the grade a “D”? Else is the grade an “F”? a. Notice the use of the word else in the sentence above, which provides for a more precise meaning. In spoken English we might use the word “or” instead, but of course, English is terribly ambiguous and Java needs to be discrete, deterministic, and precise. E. Rewrite your code for number D, but use a switch statement to accomplish the same thing. F. Prompt the user for two integer values and store them as “firstInteger” and “secondInteger”. a. Write an if/else statement that outputs either: “ firstInteger was larger than secondInteger” or “secondInteger was larger than firstInteger” on the console, based on the values provided by user that also includes the integer values in the output stament. b. If the values are equal, indicate this in an output that includes the values of the integers.

In: Computer Science

Step 1: Identify and Solve a Typical Problem There are a number of typical models in...

Step 1: Identify and Solve a Typical Problem
There are a number of typical models in the Operations Research field which can be applied to a wide range of supply chain problems. Select one of the following typical models:
• Travelling Salesperson Problem (TSP)
• Multiple Traveling Salesman Problem (mTSP)
• Knapsack Problem
• Vehicle Routing Problems (VRP)
• Job Shop Scheduling
• Parallel Machine Scheduling
• Christmas lunch problem
• Newsvendor problem
• Pickup and delivery
• Travelling thief problem
• Eight queens problem
• Minimum Spanning Tree
• Hamiltonian path problem

1.1. Background:
• Provide a detailed explanation of the selected problem.

1.2. Model
• Provide typical mathematical model of the selected problem and clearly explain different aspects of the model (e.g. decision variable, objective function, constraints, etc.)

1.3. Solving an Example
Develop a mathematical model for a workable and reasonable size of the problem.
– For many typical problems, when size of the problem increases, it becomes NP-Hard. In other words, your computer will not be able to solve it mathematically. Therefore, ‘workable and reasonable size’ here means that size of the selected problem should not be too small or too large.
• Solve the problem in Excel and transfer your solution to Word. It is required that details and steps of getting the solution are provided in the Word document.
• Interpret the findings and discuss.


Step 2: LR on Application of Selected Typical Model in Design and Analysis of Supply Chain
Identify at least 5 peer reviewed articles in which your selected typical problem has been employed to address knowledge gaps in supply chain field.
– At least one of the selected articles should be published after 2010. • Write a comprehensive literature review on the application of “your selected” typical model in design and analysis of supply chain and address the following (but not limited to) points:
- What type of problems in supply chain can be addressed by the selected typical problem?
– Compare similarities and differences of selected articles.
– Discuss the suitability of using the selected typical model in design/analysis of various supply chains. – What are the limitations of your selected typical problem? – Undertaking any additional critical and/or content analysis on the application of selected typical problem in design and analysis of supply chain is highly recommended.

Step 3: Summary of Findings


• A summary of findings regarding the strengths and weaknesses of the selected typical problem in design and analysis of supply chain should be summarised in this section.

In: Math

Racism, juries, and interactions: In a study of racism, Nail, Harton, and Decker (2003) had participants...

Racism, juries, and interactions: In a study of racism, Nail, Harton, and Decker (2003) had participants read a scenario in which a police officer assaulted a motorist. Half the participants read about an African American officer who assaulted a European American motorist, and half read about a European American officer who assaulted an African American motorist. Participants were categorized based on political orientation: liberal, moderate, or conservative. Participants were told that the officer was acquitted of assault charges in state court but was found guilty of violating the motorist’s rights in federal court. Double jeopardy occurs when an individual is tried twice for the same crime. Participants were asked to rate, on a scale of 1–7, the degree to which the officer had been placed in double jeopardy by the second trial. The researchers reported the interaction as F(2, 58) = 10.93, p < 0.0001. The means for the liberal participants were 3.18 for those who read about the African American officer and 1.91 for those who read about the European American officer. The means for the moderate participants were 3.50 for those who read about the African American officer and 3.33 for those who read about the European American officer. The means for the conservative participants were 1.25 for those who read about the African American officer and 4.62 for those who read about the European American officer. ***This prompt requires certain formatting so that you can draw tables and bar graphs. You can use Microsoft Excel or Microsoft Word, or any other word processing software to create your post/ post it as an attachment in the discussion. Draw a table of cell means that includes the actual means for this study. Do the reported statistics indicate that there is a significant interaction? If yes, describe the interaction in your own words. Draw a bar graph that depicts the interaction. Include lines that connect the tops of the bars and show the pattern of the interaction. Is this a quantitative or qualitative interaction? Explain. Change the cell mean for the conservative participants who read about an African American officer so that this is now a quantitative interaction. Draw a bar graph that depicts the pattern that includes the new cell means. Change the cell means for the moderate and conservative participants who read about an African American officer so that there is now no interaction. Draw a bar graph that depicts the pattern that includes the new cell mean

In: Math

Write a Python program called “exam.py”. The input file, “input.txt”, is given to you in the...

  1. Write a Python program called “exam.py”. The input file, “input.txt”, is given to you in the Canvas exam instructions.
  2. Name your output file “output.txt”.
  3. Ensure the program consists of a main function and at least one other function.
  4. Ensure the program will read the input file, and will output the following information to the output file as well as printing it to the screen:
  • output the text of the file to screen
  • output the number of words in the file
  • output the number of sentences in the file
  • output the first sentence in the file
  • output the last sentence in the file
  • output the length of the first sentence
  • output the length of the last sentence
  • output the first word in the file
  • output the first letter in the file
  • output the last word in the file
  • output the last letter in the file

The input file, “input.txt” is called parse Text.txt

Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we can not dedicate — we can not consecrate — we can not hallow — this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us — that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion — that we here highly resolve that these dead shall not have died in vain — that this nation, under God, shall have a new birth of freedom — and that government of the people, by the people, for the people, shall not perish from the earth.

In: Computer Science

//JAVA //basic please for learning programming 2. Thank you. Write the Class Variables Class Box is...

//JAVA
//basic please for learning programming 2. Thank you.

Write the Class Variables
Class Box is to have the following private data members:

  • height of type double
  • width of type double
  • length of type double

Write the following Overridden Method
Class Box is to have an overridden equals() method that does the following:​​​​

  • tests to see if the parameter represents an object (null test)
  • tests to see if the parameter object is of the same class type as the calling object (class test)
  • determines if the calling object and the parameter object store identical data values for the corresponding data members (variable to variable test)

Write the Get and Get Methods
Class Box is to have standard get/set methods for each data member
Write the following Auxiliary Method
Class Box is to have an auxiliary method getVolume( ). The method is to have an access of public and return a value of type double. The method is to do the following:

  • calculate and return the volume of the box
  • volume is calculated by multiplying the length of the box by the width of the box by the height of the box

Write the Constructors
Class Box is to have two constructors with the following specifications:

  • a no-arg constructor that initializes each double data member to zero
  • a constructor that takes three parameters, each representing one of the class data members. the arguments are to be listed in the order of (height, width, length)

Class: Box
Write the class header
Write the following Overridden Method
Class Box is to have an overridden toString() method that does the following:

  • displays the following information in the format presented:

Height: display height of the object
Width: display the width of the object
Length: display the length of the object
Write the following application class: BoxApp.

Class BoxApp is to do the following:

  • create an object of type Box named smallBox that has a height of 3, a width of 4 and a length of 5;
  • create an object of type Box named mediumBox that has a height of 6, a width of 7 and a length of 8;
  • create an object of type Box named unknownBox that has a height of 0, a width of 0 and a length of 0;
  • test to see if smallBox equals unknown box. If they are equal, display the word true. If they are not equal, display the word false.
  • output the following information for smallBox

Height: the value of the height property
Width: the value of the width property
Length: the value of the length property

In: Computer Science

Problem Description: Game: Bean Machine or Galton Box To figure out if the ball falls to...

Problem Description: Game: Bean Machine or Galton Box

To figure out if the ball falls to Left or Right, you can generate a random number using Math.random(). If this random number is greater than or equal to 0.5 we assume the ball falls to the Right otherwise it falls to the Left (or vise versa).

If there are 8 slots, the ball should hit 7 nails (8 -1), thus you should run a loop 7 times to figure out the path for that ball. If you have N balls, this whole process should be repeated N times. Here is a basic algorithm.

# of balls = N

# of slots = K

array of K elements

for ( i = 0 to N) {

   int R = 0;

   for (j = 0 to K-1) {

        if ( random number >= 0.5)

                  R++;

}//end loop j

array[R] ++;

}// end loop i

Output the array to show how many balls are in each slot.

Things to DO!!!!!

Analysis: (3 points)

(Describe the problem including inputs and outputs in your own words.)

Design: (3 points)

(Describe the major steps in your algorithm for solving the problem.)

Coding: Write a well documented and properly indented Java source program. Your program should have a block comment with your name and a statement of purpose at the very top. Use meaningful variable names. You must have proper labels and informative statements for all inputs and outputs. (10 points)

Testing: (Describe how you test this program, you should use your own input data to test not just the test cases given in sample runs.) (4 points)

Test your program according to following test schedule and generate output to show the number of balls in each slot.

N K
10 8
50 10
100 20
500 30

What to Submit:

  1. A PDF with descriptions of Analysis, Design, and Testing. Must have a title with your name and assignment number. (Do not submit a Word document!!!!)
  2. Error free Java source program (Programs with syntax errors receive 0 credit) with methods, proper comments and indentation. Java source program is the program you wrote with .java file extension. (Do not submit a Word or any other document of your code!!!!)
  3. The Program outputs for the 4 different test cases in a PDF

In: Computer Science

C Programming Assignment 4 Cache Simulation Objective: To write a C program that simulates reading and...

C Programming Assignment 4

Cache Simulation

Objective:

To write a C program that simulates reading and writing to a custom-sized direct-mapped cache, involving a custom-sized main memory.

The program will read all values from the ZyLab as Test Bench inputs.

Main Menu Options:

The program simulates reading from and writing to a cache based on choosing from a menu of choices, where each choice calls the appropriate procedure, where the choices are:

  1. Enter Configuration Parameters
  2. Read from Cache
  3. Write to Cache
  4. Quit Program

Note that when you read from ZyLab, the input values are not displayed on the screen as they are in the sample run at the end of this document.

Inputs:

  • Enter Parameters
    • The total size of accessible main memory (in words)
    • The total size of the cache (in words)
    • The block size (words/block)
  • Read from Cache
    • The main memory address to read
  • Write to Cache
    • The main memory address to write
    • The contents of the address for writing to the cache

Input Value Checks:

  • All the parameter values must be powers of 2.
  • The block size must never be larger than the size of accessible main memory.
  • The total cache size must be some multiple of the block size.
  • Your program should verify that all input variables are within limits as they are entered.

Output Messages:

All messages should be display EXACTLY as shown in the sample run; that is, prefixed by three asterisks, a space and hyphen and one more space. The message should be followed by a blank line.   

  • Data Accepted Message is comprised of two sentences:

*** All Input Parameters Accepted.

     Starting to Process Write/Read Requests

  • Error Messages are preceded by “*** Error –“. A list of possible errors is given below.

Note that one message has been deleted from previous versions of this Specification and three new ones have been added.

*** Error - Main Memory Size is not a Power of 2

*** Error - Block Size is not a Power of 2

*** Error - Cache Size is not a Power of 2

*** Error – Block size is larger than cache size

  • Deleted Error Message

*** Error – Cache Size is not a multiple of Block Size

  • Newly Added Error Messages

*** Error – Read Address Exceeds Memory Address Space

*** Error – Write Address Exceeds Memory Address Space (The write value following the invalid address value should be read and then discarded)

*** Error – Invalid Menu Option Selected (Until configuration data has been accepted, the only valid menu options that can be entered are “1” or “4.”)

Whenever any one of these errors occurs, the program should loop back to the Main Menu.

  • Content Message resulting from reading/writing to the cache

*** Word WW of Cache Line LL with Tag TT contains Value VV

This message should appear after all successful reads or writes

WW is the word number in the cache line, LL is the line number in the cache, TT is the line’s tag value and VV is the content value in the cache.

All values are in decimal.

  • Read Messages (two possible messages)

*** Read Miss - First Load Block from Memory (followed on the next line by the Content Message above)

*** Cache Hit (followed on the next line by the Content Message above)

  • Write Messages

*** Write Miss - First Load Block from Memory (followed on the next line by the Content Message above)

*** Cache Hit (followed on the next line by the Content Message above)

  • Quit Program Message

*** Memory Freed Up – Program Terminated Normally

When option 4 is entered, the memory should be freed up and the message “Memory Freed Up – Program Terminated Normally”, followed by a blank line, should be displayed before exiting the program.

Program Requirements:

  • Use a structure (struct) to represent a cache line consisting of a tag (integer) and a block (integer pointer). Define the cache to be a pointer to the struct.
  • Upon entering the parameters, the main memory and cache are to be dynamically allocated (use malloc) based on their respective total sizes.

Each word i of main memory is initialized with the value Mi, where M is the size of main memory in words. So, memory location 0 will contain the address of the last memory location and the last memory location will contain the address of the first memory location (i.e. 0).

  • Reading/writing from/to a new block in the cache results in dynamically allocating a block for that instance, based on the previously entered block size.

Prologue & Comments:

At the very beginning of your source code (the very first lines), please include a prologue which looks like the following:

/*

Dr. George Lazik                      (use your full name not mine)

Programming Assignment 4: Cache Simulation

Comp 222 – Fall 2019

Meeting Time: 0800-0915       (your meeting time)

*/

  • Include simple (brief) comments strategically throughout your program so that someone else can readily follow what you are doing, but don’t overdo it. Examples might look like these:

// Reading input values from ZyLab

// Determining the contents of memory

ZyLab Test Benches:

  • You will be permitted unlimited submission attempts on ZyLab until the due date. Afterwards, the inputs will be changed, the point value of the assignment will be increased to 100 and only one submission will be permitted. This last submission will be on the day following the due date and should be the one with the highest score.

  • Hardcopy printed listing of your program. Please place this on the Professor’s desk at the beginning of class on day the assignment is due. It should be properly C formatted listing and not one from programs such as Word.

Make sure your full name appears on each page of the listing and that all pages are stapled together in their correct order BEFORE you come to class.

Failure to provide this listing will result in no grade for the assignment.

Sample Test Run

The following is a sample run of one of the tests in Assignment 4’s Test Bench on ZyBooks. Note: Some recently added error conditions are not included in this run.

1

65536

512

1024

1

65536

1027

16

1

65536

1024

15

1

65537

1026

4096

1

65536

1024

18

1

65536

1024

16

3

65535

14

2

65535

3

65534

512

2

1023

4

Your output

Programming Assignment 4: Cache Simulation

Comp 222 - Fall 2019

Main Menu - Main Memory to Cache Memory Mapping

------------------------------------------------

1) Enter Configuration Parameters

2) Read from Cache

3) Write to Cache

4) Quit Program

Enter selection:

Enter main memory size (words):

Enter cache size (words):

Enter block size (words/block):

*** Error - Block Size is Larger than Cache Size

Main Menu - Main Memory to Cache Memory Mapping

------------------------------------------------

1) Enter Configuration Parameters

2) Read from Cache

3) Write to Cache

4) Quit Program

Enter selection:

Enter main memory size (words):

Enter cache size (words):

Enter block size (words/block):

*** Error - Cache Size is not a Power of 2

Main Menu - Main Memory to Cache Memory Mapping

------------------------------------------------

1) Enter Configuration Parameters

2) Read from Cache

3) Write to Cache

4) Quit Program

Enter selection:

Enter main memory size (words):

Enter cache size (words):

Enter block size (words/block):

*** Error - Block Size is not a Power of 2

Main Menu - Main Memory to Cache Memory Mapping

------------------------------------------------

1) Enter Configuration Parameters

2) Read from Cache

3) Write to Cache

4) Quit Program

Enter selection:

Enter main memory size (words):

Enter cache size (words):

Enter block size (words/block):

*** Error - Main Memory Size is not a Power of 2

Main Menu - Main Memory to Cache Memory Mapping

------------------------------------------------

1) Enter Configuration Parameters

2) Read from Cache

3) Write to Cache

4) Quit Program

Enter selection:

Enter main memory size (words):

Enter cache size (words):

Enter block size (words/block):

*** Error - Cache size is not a multiple of block size

Main Menu - Main Memory to Cache Memory Mapping

------------------------------------------------

1) Enter Configuration Parameters

2) Read from Cache

3) Write to Cache

4) Quit Program

Enter selection:

Enter main memory size (words):

Enter cache size (words):

Enter block size (words/block):

*** All Input Parameters Accepted. Starting to Process Write/Read Requests

Main Menu - Main Memory to Cache Memory Mapping

------------------------------------------------

1) Enter Configuration Parameters

2) Read from Cache

3) Write to Cache

4) Quit Program

Enter selection:

Enter Main Memory Address to Write:

Enter Value to Write:

*** Write Miss - First load block from memory

*** Word 15 of Cache Line 63 with Tag 63 contains the Value 14

Main Menu - Main Memory to Cache Memory Mapping

------------------------------------------------

1) Enter Configuration Parameters

2) Read from Cache

3) Write to Cache

4) Quit Program

Enter selection:

Enter Main Memory Address to Read:

*** Cache Hit

*** Word 15 of Cache Line 63 with Tag 63 contains the Value 14

Main Menu - Main Memory to Cache Memory Mapping

------------------------------------------------

1) Enter Configuration Parameters

2) Read from Cache

3) Write to Cache

4) Quit Program

Enter selection:

Enter Main Memory Address to Write:

Enter Value to Write:

*** Cache Hit

*** Word 14 of Cache Line 63 with Tag 63 contains the Value 512

Main Menu - Main Memory to Cache Memory Mapping

------------------------------------------------

1) Enter Configuration Parameters

2) Read from Cache

3) Write to Cache

4) Quit Program

Enter selection:

Enter Main Memory Address to Read:

Read Miss - First Load Block from Memory

*** Word 15 of Cache Line 63 with Tag 0 contains the Value 64513

Main Menu - Main Memory to Cache Memory Mapping

------------------------------------------------

1) Enter Configuration Parameters

2) Read from Cache

3) Write to Cache

4) Quit Program

Enter selection:

*** Memory Freed Up - Program Terminated Normally

In: Computer Science

Select 1 of the economic concentrations (clusters) below: Seattle-Tacoma-Olympia, WA aerospace / defense industry Central California...

Select 1 of the economic concentrations (clusters) below:

  • Seattle-Tacoma-Olympia, WA aerospace / defense industry
  • Central California winemaking industry
  • Hollywood movie industry
  • Silicon Valley Technology hub
  • Texas / Louisiana Gulf Coast crude oil and natural gas production and refining
  • Pre-1994 vs Post-1994 US auto and light truck production and the reasons for the change in economic concentration

Write a 700- to 1,050-word paper evaluating economists’ assessments of the role the 4 factors of production played in determining how the economic concentration you selected has evolved. Complete the following in your paper:

  • Analyze how the economic concentration in the area you chose was influenced by competition and pricing.
  • Analyze how the economic concentration in the area you chose influenced the supply chain.
  • Analyze which of the 4 factors of production were the most and least important in determining the economic concentration of the area you chose.
  • Predict changes you anticipate for the area of economic concentration you chose. Support your predictions.

In: Economics

A country experiences severe storms which destroys its main resource, oil rigs. Assume that the countries...

A country experiences severe storms which destroys its main resource, oil rigs. Assume that the countries economy was in long-run equilibrium before this shock happens.

  1. Use the aggregate demand–aggregate supply model to illustrate graphically the short-run and long-run impact of this supply shock on output and prices. In other word how does the economy get back to long run? Be sure to label: i. the axes; ii. the curves; iii. the initial equilibrium values; iv. the direction the curves shift; and v. the terminal equilibrium values. State in words what happens to prices and output as a combined result of the supply shock, both in the short run and long run. What happens to unemployment rate in the short run and in the long run?
  1. If the Central Bank of the country attempted to offset this deviation from the natural rate in the short run, should the money supply be increased or decreased? Show this action in the same graph and label the shifts. Which curve shifts? Does it shift to the right or left? What happens to output and prices as a result? What happens to unemployment rate? Explain.

In: Economics