Complete Chapter 5, Programming Activity 1: Working with "if/else". Make sure you study the Programming Activity 5-1 Guidance document. Which part of the guidance document was the most helpful to you? Why? At the end of your student code, also add the following statement: System.out.println("Score = " + score + " and result = " + result); This code displays your code's result for each input value in the console window. Discuss your experience writing and testing this activity. Discuss the usefulness of the program's visual output in helping you understand the flow of your code. Discuss why you think this programming activity was easy or difficult.
Programming Activity 5-1 Guidance ================================= Input parameter --------------- The parameter "score" is passed into the function where you put your code. Therefore, it is available for you to use in your code. Outputs ------- There are 3 possible outputs: "over par" "par" "below par" It is correct for the JOptionPane to pop-up after each time you enter a value. This allows you to try each test value without having to rerun the application. When you are done testing, click its Cancel button or the red X in the upper right corner of its window. Source files ------------ For all of the textbook activities, you must copy all of the source files provided in our course Textbook Activity Frameworks folder. When you compile or run the program, you must be in the correct source file in TextPad. For this activity, it is the PathClient.java file. Test cases ---------- Make sure you test with each of the recommended test cases: 45, 71, 72, and 73. Not every assignment will tell you the recommended test cases. When they are not provided, you must determine representative test cases.
In: Computer Science
Python: Write a recursive function that accepts an integer argument, n. The function should display n lines of asterisks on the screen, with the first line showing 1 asterisk, the second line showing 2 asterisks, up to the nth line which shows n asterisks. Test the function.
In: Computer Science
Which of the following polymers may be produced by condensation polymerization? Choose which apply.
1) Phenol-formaldehyde
2) Poly (vinyl chloride)
3) Polycarbonate
4) Nylon
5) Polystyrene
6) Polyethylene
In: Mechanical Engineering
How should the U.S address the Flint/ Legionnaires crisis? what other areas of the U.S. have polluted water that you can inform us about? Do a quick search on Google and inform us.
In: Psychology
BACKGROUND
Substitution ciphers that encode a message by substituting one character for another go back at least as far as Julius Caesar, who used a rotating character scheme to encode military orders. This simple type of encryption is vulnerable to statistical attacks, however, as anyone who has solved CRYPTOGRAM puzzles can attest. In World War II, the Nazi military employed an encryption scheme that addressed this weakness of simple substitution ciphers. This scheme, implemented by typewriter-sized devices known as Enigma machines, gave the Nazis a tactical advantage that greatly contributed to their early success in the war. In fact, the eventual breaking of this coding scheme by researchers at Bletchley Park, England (including Alan Turing) is hailed as one of the turning points of the war.
Enigma machines used interchangeable rotors that could be placed in different orientations to obtain different substitution patterns. More significantly, the rotors rotated after each character was encoded, changing the substitution pattern and making the code very difficult to break. The behavior of the rotating rotors can be modeled, in a simplified form, by a device consisting of labeled, concentric rings. For example, the model below has three rings labeled with the letters of the alphabet and '#' (representing a space).
To encrypt a character using this model, find the character on the inner rotor (i.e., the inside ring) and note the character aligned with it on the outer rotor (i.e., the outside ring), then find that character on the middle rotor (i.e., the middle ring) and output the one aligned with it on the outer rotor. After a character is encrypted, turn the inner rotor clockwise one step. Whenever the inner rotor returns to its original orientation, the middle rotor turns once in lock-step, just like the odometer in a car.
For example, in this configuration the character 'A' would be encrypted as 'N', since 'A' on the inner rotor is aligned with 'H' on the outer rotor, and 'H' on the middle rotor is aligned with 'N' on the outer rotor. After performing this encryption, the inner rotor is rotated clockwise, so the letter 'A' would next be encrypted as 'D'.
1 Adopted from Nifty Assignments - SIGCSE 2009 (http://nifty.stanford.edu/2009/reed-enigma/)
In other words, the rings are used in the following order: InnerOuterMiddleOuter. Note that decrypting a message requires following the same steps, only in reverse (i.e., find the character on the outer rotor, note the character aligned with it on the middle rotor, find that character on the outer rotor, then output the character aligned with it on the inner rotor). In short: Outer Middle Outer Inner.
ASSIGNMENT DESCRIPTION
For this assignment, you are to design and implement a Java class named Enigma that simulates this three-ring model of an Enigma machine. You may assume that all Enigma models have the same outer rotor, as shown in the above diagram. That is, the outer rotor consists of the 26 capital letters and the '#' symbol (representing a space) in the following clockwise order: #BDFHJLNPRTVXZACEGIKMOQSUWY. Since the middle and inner rotors are interchangeable, their contents and alignment relative to the outer rotor must be specified when constructing an Enigma model. For example, the initial settings of the inner and middle rotors in the above diagram are #GNUAHOVBIPWCJQXDKRYELSZFMT and #EJOTYCHMRWAFKPUZDINSXBGLQV, respectively. Using an Enigma object, it should be possible to both encode and decode text messages, with the appropriate rotation of the rotors occurring after each character encoding/decoding.
You should also design and implement a client program. For users who do not want to specify their own rotor settings, have a “default” option that uses the setting shown in the diagram. In addition, create an option that makes it simple for the user to specify the rotor settings on an Enigma model, and encode or decode text.
SPECIFIC TASKS
Using the outlines provided as a starting point:
Complete all method stubs in the Enigma class (Enigma.java). You are welcome to add additional methods as needed to facilitate procedural decomposition
Implement a user-friendly client program (EnigmaClient.java)
Provide user instructions fully explaining how to use your program for making your
program user-friendly
Fully demonstrate the proper functioning of your program by providing samples
input/output
Design and implementation guidelines:
Javadoc comment all class files and methods
Handle exceptions as appropriate and include @throws documentation in Javadoc
comments
Structured code - use methods to eliminate redundancy and break large methods into
smaller, logical sub problems
ENIGMA CLASS OUTLINE
This Enigma class outline contain method “stubs” along with commented descriptions of what each method should do. You need to write the actual methods, with the appropriate inputs and outputs. An example of a method stub is provided below:
This method stub tells you that the method takes a String as input and returns a Boolean value. The comments provided in the method stub list some hints on how the String should be validated. You need to write the method and the Javadoc comment. You should also comment your code using line comments as you see fit.
WHAT TO SUBMIT
You will need to submit the following files:
Your Enigma.java file
Your EnigmaClient.java file
A text document showing how you tested your program (include screen shots or copy and
paste sample output). Include a “Reflections” section in this text document that discusses any difficulties you had with the assignment, what you learned, what you found interesting, etc.
PLEASE MAKE SURE THE JAVA FILES YOU SUBMIT COMPILE AND RUN – EVEN IF YOU ARE NOT ABLE TO FINISH THE PROGRAM COMPLETELY AND/OR CORRECTLY.
Sample output is provided below. You do not have to recreate this format exactly, but your program should have similar behavior.
SAMPLE PROGRAM OUTPUT
1. Upon running the program:
2. After first user selection:
3. After second user selection:
NOTE: You do not have to keep printing out rotor
settings, but you may find this feature helpful when you are trying
to write the encryption and decryption methods.
In: Computer Science
Subject- ( App Development for Web) ( language C#, software -visual studio)
I have created a 'Calculator' named program in visual studio. This is the main console program(Program.cs) shown below. Then i have created a "CaculatorLibrary" named project by adding the project from FILE--->ADD--->NEW PROJECT. Then i selected library and selected classLibrary(.NETcore). The programs for both are given below. There are no errors in the program. Now the requirement is to build unit test project within this project that will perform atleast 10 tests.The tests must be like add rwo positive numbers,multiply two positive numbers and so on ... . This test project will also be created by FILE--->ADD--->NEW PROJECT.But here instead of library select test .
Program.cs
using CalculatorLibrary;
using System;
namespace CalculatorProgram
{
class Program
{
static void Main(string[] args)
{
bool endApp = false;
// Display title as the C# console calculator app.
Console.WriteLine("Console CalculatorProgram in C#\r");
Console.WriteLine("------------------------\n");
Calculator Calculator = new Calculator();
while (!endApp)
{
// Declare variables and set to empty.
string numInput1 = "";
string numInput2 = "";
double result = 0;
// Ask the user to type the first number.
Console.Write("Type a number, and then press Enter: ");
numInput1 = Console.ReadLine();
double cleanNum1 = 0;
while (!double.TryParse(numInput1, out cleanNum1))
{
Console.Write("This is not valid input. Please enter an integer
value: ");
numInput1 = Console.ReadLine();
}
// Ask the user to type the second number.
Console.Write("Type another number, and then press Enter: ");
numInput2 = Console.ReadLine();
double cleanNum2 = 0;
while (!double.TryParse(numInput2, out cleanNum2))
{
Console.Write("This is not valid input. Please enter an integer
value: ");
numInput2 = Console.ReadLine();
}
// Ask the user to choose an operator.
Console.WriteLine("Choose an operator from the following
list:");
Console.WriteLine("\ta - Add");
Console.WriteLine("\ts - Subtract");
Console.WriteLine("\tm - Multiply");
Console.WriteLine("\td - Divide");
Console.Write("Your option? ");
string op = Console.ReadLine();
try
{
result = Calculator.DoOperation(cleanNum1, cleanNum2, op);
if (double.IsNaN(result))
{
Console.WriteLine("This operation will result in a mathematical
error.\n");
}
else Console.WriteLine("Your result: {0:0.##}\n", result);
}
catch (Exception e)
{
Console.WriteLine("Oh no! An exception occurred trying to do the
math.\n - Details: " + e.Message);
}
Console.WriteLine("------------------------\n");
// Wait for the user to respond before closing.
Console.Write("Press 'n' and Enter to close the app, or press any
other key and Enter to continue: ");
if (Console.ReadLine() == "n") endApp = true;
Console.WriteLine("\n"); // Friendly linespacing.
}
return;
}
}
}
CalculatorLibrary.cs
using System.Diagnostics;
using System;
using System.IO;
namespace CalculatorLibrary
{
public class Calculator
{
public Calculator()
{
StreamWriter logFile = File.CreateText("calculator.log");
Trace.Listeners.Add(new TextWriterTraceListener(logFile));
Trace.AutoFlush = true;
Trace.WriteLine("Starting Calculator Log");
Trace.WriteLine(String.Format("Started {0}",
System.DateTime.Now.ToString()));
}
public double DoOperation(double num1, double num2, string
op)
{
double result = double.NaN; // Default value is "not-a-number"
which we use if an operation, such as division, could result in an
error.
// Use a switch statement to do the math.
switch (op)
{
case "a":
result = num1 + num2;
Trace.WriteLine(String.Format("{0} + {1} = {2}", num1, num2,
result));
break;
case "s":
result = num1 - num2;
Trace.WriteLine(String.Format("{0} - {1} = {2}", num1, num2,
result));
break;
case "m":
result = num1 * num2;
Trace.WriteLine(String.Format("{0} * {1} = {2}", num1, num2,
result));
break;
case "d":
// Ask the user to enter a non-zero divisor.
if (num2 != 0)
{
result = num1 / num2;
Trace.WriteLine(String.Format("{0} / {1} = {2}", num1, num2,
result));
}
break;
// Return text for an incorrect option entry.
default:
break;
}
return result;
}
}
}
In: Computer Science
discuss the implementation process and challeges of health information technology in the rehab setting.
In: Nursing
1. Is it important to have a manufacturing strategy to be successful in the simulation, and if so, why / how? If you have implemented a manufacturing strategy, what conditions were the reason(s) for your thinking?
In: Operations Management
How can you use one of the tactics below to motivate your team members?
1. Rational Persuasion: trying to convince someone with reason, logic or facts
2. Inspirational Appeals: trying to build enthusiasm by appealing to others' emotions, ideals or values
3. Consultation: getting others to participate in planning, making decisions, and changes
4. Ingratiation: getting someone in a good mood prior to making a request
5. Personal Appeals: referring to friendship and loyalty when making a request
6. Exchange: making express or implied promises and trading favors
7. Coalition Tactics: getting others to support your effort to persuade someone
8. Pressure: demanding compliance or using intimidation threats
9. Legitimating Tactics: basing request on one's authority or right, organizational rules or policies, or express or implied support from superiors
In: Operations Management
Women's involvement in physical activity and sports was often limited due to medical rhetoric that associated women's reproductive systems with weakness and fragility. What are some examples of this found in this week's lecture and reading. What impact does this history of medical/reproductive barriers still have on girls and women today? These early held beliefs about human reproduction still influences our language today - "that person has balls" versus "that person is a pussy" has opposite meanings where the male reproductive system is associated with strength while the female reproductive system is associated with weakness. Are there other examples of how this thinking impacts our lives perhaps without us realizing it until now?
In: Psychology
Programmatic marketing is becoming an important driver of the shift to data-driven marketing in many companies. Are these AI related processes likely to reduce autonomy and creativity in marketing decisions - why or why not?
In: Operations Management
Schedule of Cash Payments for a Service Company
SafeMark Financial Inc. was organized on February 28. Projected selling and administrative expenses for each of the first three months of operations are as follows:
March | $148,200 |
April | 139,300 |
May | 126,800 |
Depreciation, insurance, and property taxes represent $32,000 of the estimated monthly expenses. The annual insurance premium was paid on February 28, and property taxes for the year will be paid in June. 65% of the remainder of the expenses are expected to be paid in the month in which they are incurred, with the balance to be paid in the following month.
Prepare a schedule indicating cash payments for selling and administrative expenses for March, April, and May.
SafeMark Financial Inc. | |||
Schedule of Cash Payments for Selling and Administrative Expenses | |||
For the Three Months Ending May 31 | |||
March | April | May | |
March expenses: | |||
Paid in March | $ | ||
Paid in April | $ | ||
April expenses: | |||
Paid in April | |||
Paid in May | $ | ||
May expenses: | |||
Paid in May | |||
Total cash payments | $ | $ | $ |
In: Accounting
In: Operations Management
Problem 01: GroceryCalculator
Write a program to calculate the cost of a list of grocery items. It includes one attribute: totalCost. It includes five user-defined methods:
Problem 02: Dog
“Hi, my name is Lucky. I am a Chiwawa. I am 3 years old, and my color is white.”
In: Computer Science