Questions
IN JAVA A salesman wants to go to five different cities and sell some products. The...

IN JAVA

A salesman wants to go to five different cities and sell some products. The locations of the cities are listed in the following table.

City #

X_location

Y_location

City 1

1

1

City 2

1

3

City 3

4

1

City 4

5

3

City 5

3

5

The distance between two cities is defined as the Euclidean distance. That is:

Distance = sqrt( (x1 – x2)^2 + (y1 – y2)^2 )

For example, the distance between cities 1 and 2 will be:

Distance = sqrt( (1 – 1)^2 + (1 – 3)^2 ) = sqrt( 4 ) = 2

The purpose: The salesman starts his journey from city 1. He then has 4 remaining options for the next city (city 2, city 3, city 4, city 5). If he chooses city 3 as the next destination, then he will have 3 remaining options (city 2, city 4, city 5). He wants to travel all the cities and then come back to the start location (City 1). Not all the paths will be a good choice. We want to help the salesman by finding the shortest path (best order of cities to visit (visit all of them once) starting from city 1).

Steps:

Step 1 [7 points]: Create a class City with x and y as the class variables. The constructor with argument will get x and y and will initialize the city. Add a member function getDistanceFrom() to the class that gets a city as the input and finds the distance between the two cities.

city1.getDistanceFrom(city2) will be distance between city 1 and 2.

Step 2 [6 points]: Create 5 city objects and initialize their location (x and y) using the above table. Then put all of the five cities in a vector.

Step 3 [7 points]: Create a two dimensional array or vector DistanceVec of size 5 * 5 and initialize it such that DistanceVec[i,j] is the distance between city_i and city_j. Print the distanceVec and show the distance among all cities.

Step 4 [15 points]: If the salesman starts from the city 1, search all the possible paths and find the optimal path (order of cities to visit) that leads to the minimum total travel distance. Display the found optimal path (order of cities to travel) in your sample run.

In: Computer Science

How to create a program Budget Enter the amount budgeted for the month: 400 Enter the...

How to create a program Budget

Enter the amount budgeted for the month: 400

Enter the expense (-1 to quite):100

Enter the expense (-1 to quite):-1

$400 budgeted.

1 expenses totaling $100.

$300 under budget.

Need to use sentinel value of -1, while loop

In: Computer Science

Windows: Write one paragraph on the the benefits of BitLocker. Write one paragraph on the benefits...

Windows:

Write one paragraph on the the benefits of BitLocker.

Write one paragraph on the benefits of Implementing Windows Server Update Services (WSUS) Solution.

Write in your own words.

In: Computer Science

Problem 2(a). Letter Frequencies. ? Write Python code that reads a text file into memory and...

Problem 2(a). Letter Frequencies.

? Write Python code that reads a text file into memory and creates a dict object with a frequency count for each letter. For example, for encryptedA.txt, your output should contain the key:value pairs 'a': 78 and 'b': 31.

Notes

  • Do not distinguish between uppercase and lowercase letters.
  • Ignore punctuation. Punctuation counts must not appear in your dict
  • If a given letter does not appear in the text, there must be a key:value pair with value 0.

? Use Python to determine which letter has the highest frequency in each text file, and print the result.

Problem 2(b). Formatting for R.

? Write your two dictionaries with frequency counts from 2(a) to a pair of suitably named .csv files, with one column for the key and one column for the frequency counted. Include both .csv files with your commit to GitHub.

In: Computer Science

This is in python3.. Calculate the Balance - Deposit If the action is Deposit 'D’, use...

This is in python3..

Calculate the Balance - Deposit

If the action is Deposit 'D’, use a deposit function to add funds to the account

Deposit Input

userchoice = input ("What would you like to do?\n")
userchoice = 'B'
deposit_amount = 200

Deposit Output

What would you like to do?
How much would you like to deposit today?
Deposit was $200, current balance is $700.25

Customer Deposit

  1. Write a function called `deposit`.
  2. Request from the user the amount to be deposited. This value should be stored in a variable called `deposit_amount`. Use both the `input` and `float` methods in order to ensure the `deposit_amount` is a float value.
  3. Calculate a new account balance.
  4. The calculation for depositing funds into the account is `account_balance = account_balance + deposit_amount`.
  5. Print the new account balance.

need to add to this program below. use a deposit function to add funds to the account.

import sys# importing the sys library
# account balance
account_balance = float(500.25)
#PPrint the balance
# This is a custom function, it returns the current balance upto 2 decimal places
def printbalance():
print('Your current balance:')
return account_balance
#the function for deposit
#This is a custom function
def deposit():
deposit_amount = float(input("Enter amount to deposit : ")) # takes in input for deposit amount
balance = account_balance + deposit_amount #calculates balance
print("Deposit was $%2f, current balance is $%2f" %(deposit_amount,balance)) # prints out the balance
#function for withdraw
#this is a custom function
def withdraw():
withdraw_amount = float(input("Enter amount to withdraw")) # takes in the withdraw amount
if(withdraw_amount > account_balance): #checks whether the amount is more than balance or not
print("$%2f is greater than account balance $%2f\n" %(withdraw_amount,account_balance)) #if yes then
else:
balance = account_balance - withdraw_amount
print("$%2f was withdrawn, current balance is $%2f" % (withdraw_amount, balance))
# User Input goes here, use if/else conditional statement to call function based on user input

userchoice = input("What would you like to do?\n")

if (userchoice == 'D'):
# here deposit function is called
deposit()
elif userchoice == 'W':
# here withdraw function is called
withdraw()
elif userchoice == 'B':
# here printbalance function is called
balance=printbalance()
print('{:.2f}'.format(balance))
else:
# it ends the program execution
sys.exit()

In: Computer Science

Telecommunication Governance 1: Give at least 4 real life examples in detail of implementing IT Governance...

Telecommunication Governance 1:

Give at least 4 real life examples in detail of implementing IT Governance in a modern enterprise.

In: Computer Science

Discuss IaaS, PaaS, SaaS models in term of the cloud consumer granted administrative control and the...

Discuss IaaS, PaaS, SaaS models in term of the cloud consumer granted administrative control and the risk of security breaches?

In: Computer Science

There are logical and run time errors in the code, as well as compilation errors. **...

There are logical and run time errors in the code, as well as compilation errors.
** Your objective is get the code to run, fix any bugs in the code and
** place validation needed to prevent any memory issues. Each function has a
** description of what it does next to its prototype.

** When you find a problem, fix it in the code and note it in this header comment below.
** Please note each problem you find on a separate comment line.
** NO CREDIT for fixing a problem without adding a comment line about it in this header.
** SUBMIT THIS FIXED C++ FILE WITH YOUR ADDED COMMENTS
**
** RUBRIC:
** 1) code must compile with no errors or warnings
** 2) code runs with no bugs: 25%
** 3) fix comments in this comment header: 75%
**
** ADD YOUR COMMENTS HERE
**
** Problem 1:
** Problem 2:
** ...
** Problem n:
*/

#include <iostream>

using namespace std;

void addToList(int *); // adds integer to integer array
void displayList(int *); //displays all items in array
void dispSum(); //gives sum of all elements in array
void dispAverage(); //gives average of elements in array.

unsigned short SIZE = 0;

int main()
{
unsigned int input;
int arrayList[10];

do
{
cout << "***Main Menu***" << endl
<< "1. add number to list" << endl
<< "2. display list." << endl
<< "3. display sum." << endl
<< "4. display average." << endl
<< "0. Quit" << endl;
//clears iostream buffer
cin.clear();
cin.ignore(10, '\n');
cout << "enter a menu choice: ";
cin >> input;

switch (input)
{
case 1: addToList(arrayList);
case 2: displayList(arrayList);
case 3: dispSum();
case 4: dispAverage();
case 0:break;
default:cout << "enter a valid choice from menu:";
}

} while (input !=0);
return 0;
}

void addToList(int *arrayList)
{
int input;
cout << "enter a number int the array: ";
cin >> input;
arrayList[SIZE++] = input;
}

void displayList(int *arrayList)
{
for (int i = 0; i <= SIZE; ++i)
cout << arrayList[SIZE];
cout << endl;
}

void dispSum(int *arrayList)
{
int sum = 0;
for (int i = 0;i <= SIZE; ++i)
sum += arrayList[i];
cout << "The Sum is " << sum << "!" << endl;
}

PreviousNext

In: Computer Science

YOU MUST USE SWITCH STATEMENTS TO SOLVE THE NEXT TWO PROBLEMS. NO LOOPS ALLOWED we have...

YOU MUST USE SWITCH STATEMENTS TO SOLVE THE NEXT TWO PROBLEMS.

NO LOOPS ALLOWED we have not covered them yet therefore we can't use them

Write a program that displays the following menu: Geometry Calculator

1. Calculate the Area of a Circle

2. Calculate the Area of a Rectangle

3. Calculate the Area of a Triangle

4. Quit

Enter your choice (1-4):

If the user enters 1, the program should ask for the radius of the circle and then display its area. Use the following formula: area = πr2

Use 3.14159 for π and the radius of the circle for r. If the user enters 2, the program should ask for the length and width of the rectangle and then display the rectangle’s area. Use the following formula: area = length * width

If the user enters 3 the program should ask for the length of the triangle’s base and its height, and then display its area. Use the following formula: area = base * height * .5

If the user enters 4, the program should end.

Input Validation: Display an error message if the user enters a number outside the range of 1 through 4 when selecting an item from the menu. Do not accept negative values for the circle’s radius, the rectangle’s length or width, or the triangle’s base or height.

In: Computer Science

Q; What are the asset of a university and what kind of issues should be mentioned...

Q; What are the asset of a university and what kind of issues should be mentioned in a public security policy if this asset should be protected?

In: Computer Science

Here we will be taking data in as a file instead of from the command line...

Here we will be taking data in as a file instead of from the command line (no cin). Note that the sample file provided here is not the file that I will use to grade your assignment but the formatting will be the same.

File input is very similar to how data comes in from the user through cin (using the same operators) but we will need to setup the stream ourselves.

First we need to include <fstream> at the top of our file.

We will need to create an input file stream to work from now. We will do this with ifstream. ifstream is a datatype just like int or float. Create a variable with the datatype being ifstream. We will define the variable by using the member accessor operator to call the open function and passing in “Person.txt”, which is where our data will be.

Example: [whatever the variable name is].open(“Person.txt”);

Your program must be setup to open “Person.txt” as the file. For testing you can add your own Person.txt file into visual studios as a resource.

The file your program will have to take in will be formatted like so:

The first 2 numbers are the min and max that the Person can work. Anything under the min and the employee is docked salary. Anything above and the employee must be paid overtime. These number may vary but min will always be less than the max.

There will then be 5 lines with different amounts of numbers (indicating the Person’s work times per line):

The first number will tell how many numbers will follow (since some weeks do not have 5 work days and can have holidays.

Example file 1:

35 45

5 8 8 7 9 8

4 10 8 2 13

6 4 8 10 9 8 1

5 8 10 10 10 10

3 8 7 8

Example file 2:

20 20

3 8 8 4

2 8 8

3 8 8 8

5 8 8 4 4 2

2 4 5

You will read the first number in using the stream extraction operator. Based on that number you can read in the rest of the numbers (again using the stream extraction operator). What you will be trying to identify is whether the Person whose data you read in worked more than their max hours per week - in which case you will indicate this by outputting “OVERTIME” and however much over the max the person worked for that week. Or if the Person worked less than their min you should output “DOCK” and indicate how many hours below min they worked.

The work week will always begin on a 5 day schedule, though some persons may work on the weekend (as much as 7 days). If the person only worked 4 days or less then they will still be held to the same min and max hours. Unless you are on the last week, which may not have 5 full days in it. For the last week you must prorate (get a percentage) according to how many days are indicated. Meaning if there is only 4 days in the last week and the employee normally will work 40 hours per their min then they would only have to work 32 (40 * 4/5 = 32) hours on the last week.

The final output should indicate per week whether they should be “Docked pay”, “Normal pay”, or “Overtime” for each week (Dock and Overtime of course indicating by how much). So the output of the sample above could be:

Example Output 1:

NORMAL

DOCK 2

NORMAL

OVERTIME 3

NORMAL

Example Output 2:

NORMAL

DOCK 4

OVERTIME 4

OVERTIME 6

OVERTIME 1

Final submission should be your .cpp file only (as again I will use my own txt file to grade your assignment). Do not submit project files or solution files.

i need help with this code please

In: Computer Science

Give a pseudo-code description for an array-based implementation of the deque ADT (Abstract Data Type). What...

Give a pseudo-code description for an array-based implementation of the deque ADT (Abstract Data Type). What is the running time for each operation?

In: Computer Science

Please use the Java Programming language. This is the introductory course, chapter two. Please only use...

Please use the Java Programming language. This is the introductory course, chapter two. Please only use if/else if, else and while loop. We have not touch base with do and while do(I don't know if while do exist in Java).

Create an application that converts number grades to letter grades.

Console

Welcome to the Letter Grade Converter

Enter numerical grade: 90

Letter grade: A

Continue? (y/n): y

Enter numerical grade: 88

Letter grade: A

Continue? (y/n): y

Enter numerical grade: 80

Letter grade: B

Continue? (y/n): y

Enter numerical grade: 67

Letter grade: C

Continue? (y/n): y

Enter numerical grade: 59

Letter grade: F Continue? (y/n): n

Specifications • The grading criteria is as follows: A 88-100 B 80-87 C 67-79 D 60-67 F <60 • Assume that the user will enter valid integers between 1 and 100 for the grades. • The application should continue only if the user enters “y” or “Y” to continue.

In: Computer Science

11. Use Euclid’s extended algorithm to find x and y for Gcd(241, 191) = 241 x...

11. Use Euclid’s extended algorithm to find x and y for Gcd(241, 191) = 241 x + 191 y

Show all work.

In: Computer Science

Cyber attacks: Explain what each of the following attacks is: Replay attacks Man-in-the-middle attacks Keylogging

Cyber attacks: Explain what each of the following attacks is:

  1. Replay attacks
  2. Man-in-the-middle attacks
  3. Keylogging

In: Computer Science