Computer Science

Which of the approaches given in the text would you use to arrive at system scenarios for the following cases:

1. A customer recounts, “During the last version implementation, I had difficulty in migrating data from the previous version -it failed while backing up data for the customer master and while adding extra columns for the discounts table.”

2. A product is being deployed in the FMCG industry and in the retail sales industry and should be customizable to each.

3. A test engineer performs unit testing, updates the defect repositories, sends emails to the component’s owners, chats with them and updates his log.

Accounting

Comparative financial statement data of Crest Optical Mart follow:

Other information:

1. Market price of Crest common stock: $61 at December 31, 20X6, and $45.50 at December 31, 20X5.

2. Common shares outstanding: 15,000 during 20X6 and 14,000 during 20X5.

3. All sales on credit.

❙ Required

1. Compute the following ratios for 20X6 and 20X5:

a. Current ratio  p. 700) b. Inventory turnover  pp. 701–702)

c. Times-interest-earned ratio  p. 703)

d. Return on assets  p. 704)

e. Return on common stockholders’ equity  pp. 705–706)

f. Earnings per share of common stock  pp. 705–706)

g. Price/earnings ratio  pp. 706–707)

2. Decide whether  a) Crest’s financial position improved or deteriorated during 20X6 and  b) the investment attractiveness of Crest’s common stock appears to have increased or decreased.  Challenge)

3. How will what you learned in this problem help you evaluate an investment?  Challenge)

rank);

}

}

while (true) {

System.out.print(“”tDepartment: “”);

department = input.nextLine();

if (department.equalsIgnoreCase(“”Mathematics””)) {

department = “”Mathematics””;

break;

} else if (department.equalsIgnoreCase(“”Engineering””)) {

department = “”Engineering””;

break;

} else if (department.equalsIgnoreCase(“”Sciences””)) {

department = “”Sciences””;

break;

} else {

System.out.printf(“”tt””%s”” is invalid%n””

Code:

import java.io.FileWriter;

import java.io.IOException;

import java.text.DecimalFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Scanner;

abstract class Person {

private String fullName;

private String id;

public Person() {

this.fullName = “Undefined”;

this.id = “Undefined”;

}

public Person(String id, String fullName) {

this.fullName = fullName;

this.id = id;

}

public void setFullName(String fullName) {

this.fullName = fullName;

}

public String getFullName() {

return this.fullName;

}

public void setId(String id) {

this.id = id;

}

public String getId() {

return this.id;

}

public abstract void print();

public abstract void report(FileWriter writer) throws IOException;

}

class Student extends Person {

private double gpa;

private int creditHours;

public Student() {

super();

this.gpa = 0.0;

this.creditHours = 0;

}

public Student(String id, String fullName, double gpa, int creditHours) {

super(id, fullName);

this.gpa = gpa;

this.creditHours = creditHours;

}

public void setGpa(double gpa) {

this.gpa = gpa;

}

public double getGpa() {

return this.gpa;

}

public void setCreditHours(int creditHours) {

this.creditHours = creditHours;

}

public int getCreditHours() {

return creditHours;

}

@Override

public void print() {

DecimalFormat decimalFormat = new DecimalFormat(“#.##”);

System.out.println(“Here is the tuition invoice for ” + this.getFullName());

System.out.println(“—————————————————–“);

System.out.println(this.getFullName() + “tttt” + this.getId());

System.out.println(“Credit Hours: ” + this.getCreditHours() + ” ($236.45/credit hour)”);

System.out.println(“Fees: $52”);

double total = this.getCreditHours() * 236.45 + 52.0;

double discount = 0;

if (this.getGpa() >= 3.85) {

discount = total * 0.25;

}

System.out.println(“Total payment(after discount): $” + decimalFormat.format(total – discount) + “tttt($” + discount + ” discount applied)”);

System.out.println(“—————————————————–“);

}

@Override

public void report( FileWriter myWriter ) throws IOException {

myWriter.write(“n”+this.getFullName());

myWriter.write(“nID:” + this.getId());

myWriter.write(“nGpa:” + this.getGpa());

myWriter.write(“nCredit hours:” + this.getCreditHours());

myWriter.write(“n”);

}

}

abstract class Employee extends Person {

private String department;

public Employee() {

super();

// Default Value

this.department = “Mathematics”;

}

public Employee(String id, String fullName, String department) {

super(id, fullName);

this.department = department;

}

public void setDepartent(String department) {

this.department = department;

}

public String getDepartment() {

return this.department;

}

}

class Faculty extends Employee {

private String rank;

public Faculty() {

super();

this.rank = “Adjunct”;

}

public Faculty(String id, String fullName, String department, String rank) {

super(id, fullName, department);

this.rank = rank;

}

public void setRank(String rank) {

this.rank = rank;

}

public String getRank() {

return this.rank;

}

@Override

public void print() {

System.out.println(“—————————————————–“);

System.out.println(this.getFullName() + “tttt” + this.getId());

System.out.println(this.getDepartment() + ” Department, ” + this.getRank());

System.out.println(“—————————————————–“);

}

@Override

public void report(FileWriter myWriter) throws IOException {

myWriter.write(“n”+this.getFullName());

myWriter.write(“nID:” + this.getId());

myWriter.write(“n”+this.getDepartment() + “,” + this.getRank());

}

}

class Staff extends Employee {

private String status;

public Staff() {

super();

this.status = “Full Time”;

}

public Staff(String id, String fullName, String department, String status) {

super(id, fullName, department);

this.status = status;

}

public void setStatus(String rank) {

this.status = rank;

}

public String getStatus() {

return this.status;

}

@Override

public void print() {

System.out.println(“—————————————————–“);

System.out.println(this.getFullName() + “tttt” + this.getId());

System.out.println(this.getDepartment() + ” Department, ” + this.getStatus());

System.out.println(“—————————————————–“);

}

@Override

public void report(FileWriter myWriter) throws IOException {

myWriter.write(“n”+this.getFullName());

myWriter.write(“nID:” + this.getId());

myWriter.write(“n”+this.getDepartment() + “,” + this.getStatus());

}

}

public class Main {

FileWriter myWriter ;

public static void main(String[] args) {

Scanner scn = new Scanner(System.in);

Person[] persons = new Person[100];

Scanner input = new Scanner(System.in);

int count = 0;

String fullName, id, rank, department, status, report;

int creditHours;

double gpa;

boolean flag;

System.out.println(“tWelcome to my Personal Management Programn”);

System.out.println(“Choose one of the options:”);

while (true) {

System.out.println();

System.out.println(“1- Enter the information of a faculty”);

System.out.println(“2- Enter the information of a student”);

System.out.println(“3- Print tuition invoice for a student”);

System.out.println(“4- Print faculty information”);

System.out.println(“5- Enter the information of a staff member”);

System.out.println(“6- Print the information of a staff member”);

System.out.println(“7- Exit program”);

System.out.println();

System.out.print(“tEnter your selection: “);

String option = scn.next();

switch (option) {

case “1”:

System.out.println(“Enter the faculty info: “);

System.out.print(“tName of the faculty: “);

fullName = input.nextLine();

while(true)

{

System.out.print(“tID: “);

id = input.nextLine();

if(id.length()==6&&Character.isAlphabetic(id.charAt(0))&&Character.isAlphabetic(id.charAt(1))&&Character.isDigit(id.charAt(2))&&Character.isDigit(id.charAt(3))&&Character.isDigit(id.charAt(4))&&Character.isDigit(id.charAt(5)))

{

break;

}

else {

System.out.printf(“Invalid ID format. Must be LetterLetterDigitDigitDigitDigitn”);

}

}

while (true) {

System.out.print(“tRank: “);

rank = input.nextLine();

if (rank.equalsIgnoreCase(“Adjunct”)) {

rank = “Adjunct”;

break;

} else if (rank.equalsIgnoreCase(“Professor”)) {

rank = “Professor”;

break;

} else {

System.out.printf(“tt”%s”” is invalid%n””

“);
}
}

Coordinates.java

/**
* Represents a set of latitude/longitude coordinates
*/
public class Coordinates {
public final double latitude;
public final double longitude;
public Coordinates(double lat

Programming Language: java

any copy answer (ofc, there is a wrong answer in Chegg. If you copy and paste, I will just report it as abuse/spam)

The Question description.

getTopNcountriesWithMostAirports

Given a Stream of airports and an int n, return a list of the names of the top n countries with the most airports, sorted in descending order by number of airports. If there are < an n countries represented in the stream, return them all, sorted in descending order by number of airports.

getClosestAirport

Given a Stream of airports and an airport ID, return the airport closest to the airport with that ID. Use the Coordinates.distance method to calculate distance between airports, and the Stream.min method to find the airport with the minimum distance away. If the airport with the given ID is not found, or the stream is empty, return an empty Optional.

countAirportsByAltitude

Given a Stream of airports, return a Given a Map that maps altitudes to the number of airports at that altitude, but only include in the map altitudes that have at least 2 airports at that altitude. If the stream is empty, return an empty map.

return a list of movies with exactly n words in the title (use String.split(“\s+”) to split the title string into words).

averageNumAirportsPerCountry

Given a Stream of airports, return the average number of airports in each country, of 0 if the stream is empty.

percentAirportsWithCityName

Given a Stream of airports, return the percentage of airport names that contain the name of the city they are in (case-insensitive). If a city name is blank, consider the airport name to NOT contain it. If the stream is empty, return 0.

—————————————————————

Airport.java
/**
* Represents an Airport
*/
public class Airport implements Comparable {
private int airportID;
private String name;
private String city;
private String country;
private String iataCode;
private String icaoCode;
private Coordinates coordinates;
private double altitude;
/**
* See https://openflights.org/data.html for what each parameter means
*
* @param airportID
* @param name
* @param city
* @param country
* @param iataCode
* @param icaoCode
* @param coordinates
* @param altitude
*/
public Airport(int airportID, String name, String city, String country,
String iataCode, String icaoCode,
Coordinates coordinates, double altitude) {
this.airportID = airportID;
this.name = name;
this.city = city;
this.country = country;
this.iataCode = iataCode;
this.icaoCode = icaoCode;
this.coordinates = coordinates;
this.altitude = altitude;
}
public int getAirportID() {
return airportID;
}
public String getName() {
return name;
}
public String getCity() {
return city;
}
public String getCountry() {
return country;

}
public String getIATAcode() {
return iataCode;
}
public String getICAOcode() {
return icaoCode;
}
public Coordinates getCoordinates() {
return coordinates;
}
public double getAltitude() {
return altitude;
}
@Override
public String toString() {
return airportID + “,” + name + “,” + city + “,” + country + “,” +
iataCode + “,” + icaoCode + “,” +
coordinates + “,” + altitude;
}
@Override
public boolean equals(Object otherObject) {
if (otherObject instanceof Airport) {
Airport other = (Airport) otherObject;
return airportID == other.airportID &&
name.equals(other.name) &&
city.equals(other.city) &&
country.equals(other.country) &&
iataCode.equals(other.iataCode) &&
icaoCode.equals(other.icaoCode) &&
coordinates.equals(other.coordinates) &&
altitude == other.altitude;
}
return false;
}
/**
* compares lexicographically by airport name
*/
@Override
public int compareTo(Airport other) {
if (name.compareTo(other.name) < 0)
return -1;
if (name.compareTo(other.name) > 0)
return 1;
return 0;
}

}

————————————————–

AirportsReader.java
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
*
* A utility class for reading a CSV-type formatted file of airports
*
*/
public class AirportsReader {
/**
* Reads a CSV-type formatted file of airport data, and returns a list of
airports
*
* @param filename the CSV file with the airport data to read
* @return a list of airports from the file
*/
public static List readAirports(String filename) {
List airports = new ArrayList<>();
try (Scanner in = new Scanner(new File(filename))) {
while (in.hasNextLine()) {
String line = in.nextLine();
/*
* The format of each line is idnumber,”Airport Name”,”City
Name”, … There are
* no commas in the the airport or city name fields.
*/
Scanner scanner = new Scanner(line);
scanner.useDelimiter(“,”);
int airportID = scanner.nextInt();
String name = removeQuotes(scanner.next());
String city = removeQuotes(scanner.next());
String country = removeQuotes(scanner.next());
String iataCode = removeQuotes(scanner.next());
String icaoCode = removeQuotes(scanner.next());
double latitude = scanner.nextDouble();
double longitude = scanner.nextDouble();
Coordinates coordinates = new Coordinates(latitude,
longitude);
double altitude = scanner.nextDouble();
scanner.close();
airports.add(new Airport(airportID, name, city, country,
iataCode, icaoCode, coordinates,
altitude));
}
} catch (FileNotFoundException e) {
System.out.println(“File: ” + filename + ” not found”);
}
return airports;
}

private static String removeQuotes(String str) {
return str.replaceAll(“””

Computer Science

Make any improvements you might deem appropriate to the class of vectors. You might be helped in this task by the following list.

• The assertions for the round bracket operator are almost identical to those of the square bracket operator and those of the Read method. Rewrite the Read method and one of these operators in such a way that they call the remaining operator (with a suitable offset, as necessary) and all the checks are given in one place.

• There are many assertions in the class as it stands. These mean that it is very easy to write programs which terminate with a run–time error. Can you turn any of the assertions into exceptions or warnings (see Chap. 9)?

• Write an output operator for vectors using the pattern given in Sect. 6.4 for the operator

Accounting

Each of the following scenarios is based on facts in an actual fraud. Categorize each scenario as primarily indicating (1) an incentive to commit fraud, (2) an opportunity to commit fraud, or (3) a rationalization for committing fraud. Also state your reasoning for each scenario.

a. There was intense pressure to keep the corporation’s stock from declining further. This pressure came from investors, analysts, and the CEO, whose financial well-being was significantly dependent on the corporation’s stock price.

b. A group of top-level management was compensated (mostly in the form of stock-options) well in excess of what would be considered normal for their positions in this industry.

c. Top management of the company closely guards internal financial information, to the extent that even some employees on a “need-to-know basis” are denied full access.

d. Managing specific financial ratios is very important to the company, and both management and analysts are keenly observant of variability in key ratios. Key ratios for the company changed very little even though the ratios for the overall industry were quite volatile during the time period.

e. In an effort to reduce certain accrued expenses to meet budget targets, the CFO directs the general accounting department to reallocate a division’s expenses by a significant amount. The general accounting department refuses to acquiesce to the request, but the journal entry is made through the corporate office. An accountant in the general accounting department is uncomfortable with the journal entries required to reallocate divisional expenses. He brings his concerns to the CFO, who assures him that everything will be fine and that the entries are necessary. The accountant considers resigning, but he does not have another job lined up and is worried about supporting his family. Therefore, he never voices his concerns to either the internal or external auditors.

f. Accounting records were either nonexistent or in a state of such disorganization that significant effort was required to locate or compile them.

int key)
{
int i;
string decoder = “”””;
for (i = 0; i < secret.length(); i++)
{
if (filter(secret[i] – key))
decoder += secret[i] – key;
else if (filter(secret[i] – key + 127 – 32))
decoder += secret[i] – key + 127 – 32;
}
if (decoder.length() == secret.length()) //All encrypted chars must be decrypted
return decoder;
return decoder = “”””;
}


  1. Your country is at war and your enemies are using a secret code to communicate with each other. You have managed to intercept a message that reads as follows:

:mmZdxZmx]Zpgy

The message is obviously encrypted using the enemy’s secret code. You have just learned that their encryption method is based upon the ASCII code. Appendix 3 shows the ASCII character set. Individual characters in a string are encoded using this system. For example, the letter “A” is encoded using the number 65 and “B” is encoded using the number 66.

Your enemy’s secret code takes each letter of the message and encrypts it as follows:

If (OriginalChar + Key > 126) then

EncryptedChar = 32 + ((OriginalChar + Key) – 127)

Else

EncryptedChar = (OriginalChar + Key)

For example, if the enemy uses Key = 10 then the message “Hey” would be encrypted as:

Character ASCII code

H is 72, e is 101, and y is 121.

Encrypted H = (72 + 10) = 82 = R in ASCII

Encrypted e = (101 + 10) = 111 = o in ASCII

Encrypted y = 32 + ((121 + 10) – 127) = 36 = $ in ASCII

Consequently, “Hey” would be transmitted as “Ro$.”

Write a program that decrypts the intercepted message. The ASCII codes for the unencrypted message are limited to the visible ASCII characters. You only know that the key used is a number between 1 and 100. Your program should try to decode the message using all possible keys between 1 and 100. When you try the valid key, the message will make sense. For all other keys, the message will appear as gibberish. Have a way for the user to choose which attempt looks correct so that the program will then output the key.

Current code:

/**************************************
Headers
**************************************/
#include

/**************************************
Function Declarations – Message Decryption
**************************************/
//used to filter the characters
bool filter(const char& chr);
//used to descrypt the message
string decryptedString(const string& secret, int key);

int main

{

cout << “**********************************************************************” << endl;
//use a new line to separate the border line above from the program name below
cout << “* *” << endl;
//describe what the program does
cout << “* ‘Message Decoder’ *” << endl;
cout << “* This program will decode from a secret string of characters *” << endl;
cout << “* the enemy is using to send messages back and forth. *” << endl;
cout << “**********************************************************************” << endl;
cin.ignore();
string decryptedString(const string & secret, int key);
string secretMsg = “:mmZ\dxZmx]Zpgy”;
cout << “nThe original undecoded message was: ” << secretMsg;
int key;
for (key = 1; key < 101; ++key)
{
cout << “Key ” << key << ” – “
<< decryptedString(secretMsg, key)
<< endl;
}
//if none were decrypted sucessfully or no decrypted string have meaning, update the filter”
cout << endl;
cin.get();

}

/**************************************
Function Definitions- Boolean Filter
**************************************/
bool filter(const char& chr)
{
return (toupper(chr) >= ‘A’ && toupper(chr) <= ‘Z’) || //a-z A-Z
(chr >= ‘0’ && chr <= ‘9’) || //0-9
(chr == ‘ ‘ || chr == ‘t’ || chr == ‘n’) || //white spaces
(chr == ‘,’ || chr == ‘.’ || //punctuations
chr == ‘:’ || chr == ‘;’ ||
chr == ”’ || chr == ‘”‘ ||
chr == ‘?’ || chr == ‘!’);
}

/**************************************
Function Definitions- Decryption
**************************************/
string decryptedString(const string& secret