Answer:
The correct answer to the following question will be "0.625".
Explanation:
Amount of clock cycles required for subsidiary conditional guidance
= 1+3
= 4
Probability of component instruction with condition
= 0.2
Amount of clock cycles required for further guidance
= 1
Probability of a particular command
= 0.8
Normal duration of the clock
= 0.2×4+1×0.8
= 0.8+0.8
= 1.6 clocks
Median number of instructions per clock
= 1/1.6
= 0.625
Slow down
= 0.625/1
= 0.625
For this lab you will be creating your own struct, called Frog. You will need to create an array of Frog, and prompt the user for information to create Frogs and fill in the array.
(3 pts) First, create a Frog struct (first test). It should have the following fields: Name, Age, and Leg Length. Expect sample input to look like this:
Todd Jones //Name
12 //Age
12.34 //LegLength
(1 pt) After that, ask the user how many frogs they would like to create:
How many frogs do you want?
(2 pts) Next, loop for the supplied number of times, asking for user input:
What is the name of Frog 1?
What is the age of Frog 1?
What is the leg length of Frog 1?
What is the name of Frog 2?
What is the age of Frog 2?
What is the leg length of Frog 2?
Answer:
The solution code is written in c++
#include <iostream>using namespace std;struct Frog { string Name; int Age; float LegLength;}; int main (){ Frog frog_test; frog_test.Name = "Todd Jones"; frog_test.Age = 12; frog_test.LegLength = 12.34; int num; cout<<"Enter number of frogs: "; cin>>num; Frog frog[num]; int i; for(i = 0; i < num; i++){ cout<<"What is the name of Frog "<< i + 1 <<" ?"; cin>> frog[i].Name; cout<<"What is the age of Frog "<< i + 1 <<" ?"; cin>> frog[i].Age; cout<<"What is the leg length of Frog "<< i + 1 <<" ?"; cin>> frog[i].LegLength; }}Explanation:
Firstly, define a Frog struct as required by the question (Line 4 - 8).
We create a test Frog struct (Line 12 - 15).
If we run the code up to this point, we shall see a Frog struct has been build without error.
Next, prompt user to input number of frogs desired (Line 17 -19).
Use the input number to declare a frog array (Line 21).
Next, we can use a for loop to repeatedly ask for input info of each frog in the array (Line 23- 34).
At last, we shall create num elements of Frog struct in the array.
Create a class called Employee that includes three instance variables—a first name (type String), a last name (type String) and a monthly salary (double). Provide a constructor that initializes the three instance variables. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its value. Write a test app named EmployeeTest that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s yearly salary. Then give each Employee a 10% raise and display each Employee’s yearly salary again.
Answer:
public class Employee {
private String Fname;
private String Lname;
private double monthlySalary;
//Constructor
public Employee(String fname, String lname, double monthlySalary) {
Fname = fname;
Lname = lname;
this.monthlySalary = monthlySalary;
}
//Set and Get Methods
public String getFname() {
return Fname;
}
public void setFname(String fname) {
Fname = fname;
}
public String getLname() {
return Lname;
}
public void setLname(String lname) {
Lname = lname;
}
public double getMonthlySalary() {
return monthlySalary;
}
public void setMonthlySalary(double monthlySalary) {
if(monthlySalary>0) {
this.monthlySalary = monthlySalary;
}
}
}
public class EmployeeTest {
public static void main(String[] args) {
Employee employeeOne = new Employee("Dave","Jones",1800);
Employee employeeTwo = new Employee("Junely","Peters",1200);
double empOnecurrentYrSalary =(employeeOne.getMonthlySalary()*12);
System.out.println("Employee One Yearly salary is " +
""+empOnecurrentYrSalary);
double empTwocurrentYrSalary =(employeeTwo.getMonthlySalary()*12);
System.out.println("Employee Two Yearly salary is " +
""+empTwocurrentYrSalary);
// Incremments of 10%
double newSalaryOne = empOnecurrentYrSalary+(empOnecurrentYrSalary*0.1);
double newSalaryTwo = empTwocurrentYrSalary+(empTwocurrentYrSalary*0.1);
employeeOne.setMonthlySalary(newSalaryOne);
employeeTwo.setMonthlySalary(newSalaryTwo);
System.out.println("Employee One's New Yearly Salary is " +
""+(employeeOne.getMonthlySalary()));
System.out.println("Employee Two's New Yearly Salary is " +
""+(employeeTwo.getMonthlySalary()));
}
}
Explanation:
As required by the question Two Java classes are created Employee and EmployeeTest
The required fields, constructor, get and set methods are all created in the Employee class, pay attention to the comments in the code
In the EmployeeTest, two objects of the class are created as required by the question.
The current salaries are printed as initialized by the constructor
Then an increase of 10% is added and the new salary is printed.
Note the use of the setMonthlySalary and getMonthlySalary for the update and display of the salaries respectively
What is the shortest sequence of MIPS instructions that extracts a field for the constant values of bits 7-21 (inclusive) from register $t0 and places it in the lower order portion of register $t3 (zero filled otherwise)?
Answer:
What is the shortest sequence of MIPS instructions that extracts a field for the constant values of bits 7-21 (inclusive) from register $t0 and places it in the lower order portion of register $t3 (zero filled otherwise)? - sll$t0, $t3, 9# shift $t3 left by 9, store in $t0
srl $t0, $t0, 15# shift $t0 right by 15
Explanation:
The shortest sequence of MIPS instructions that extracts a field for the constant values of bits 7-21 (inclusive) from register $t0 and places it in the lower order portion of register $t3 (zero filled otherwise) is shown below:
sll$t0, $t3, 9# shift $t3 left by 9, store in $t0
srl $t0, $t0, 15# shift $t0 right by 15
Read the Security Guide about From Anthem to Anathema on pages 238-239 of the textbook. Then answer the following questions in the format on an essay. Create a heading for each question. Questions: Think about all of the cloud services you use. How vulnerable are you right now to having your data stolen
Answer:
Answer explained below
Explanation:
Think about all of the cloud services you use. How vulnerable are you right now to having your data stolen?
At its most basic level, “the cloud” is just fancy talk for a network of connected servers. (And a server is simply a computer that provides data or services to other computers). When you save files to the cloud, they can be accessed from any computer connected to that cloud’s network.
The cloud is not just a few servers strung together with Cat5 chords. Instead, it’s a system comprised of thousands of servers typically stored in a spaceship-sized warehouse—or several hundred spaceship-sized warehouses. These warehouses are guarded and managed by companies capable of housing massive loads of data, including the likes of Google (Google Docs), Apple (iCloud), and Dropbox.
So, it’s not just some nebulous concept. It’s physical, tangible, real.
When you save files to the cloud, you can access them on any computer, provided it’s connected to the Internet and you’re signed into your cloud services platform. Take Google Drive. If you use any mail, you can access Drive anywhere you can access your email. Sign in for one service and find your entire library of documents and photos in another.
Why are people concerned with cloud security?
It’s physically out of your hands.
You aren’t saving files to a hard drive at your house. You are sending your data to another company, which could be saving your data thousands of miles away, so keeping that information safe is now dependent on them. “Whether data is being sent automatically (think apps that sync to the cloud) or driven by users uploading photos to social media, the end result is that it’s all there somewhere being logged and stored,” says Jérôme Segura, Senior Security Researcher at Malwarebytes.
And that somewhere is a place that’s not in your direct control.
Risks of cloud storage
Cloud security is tight, but it’s not infallible. Cyber gurus can get into those files, whether by guessing security questions or bypassing passwords. That’s what happened in The Great iCloud Hack of 2014, where unwanted pictures of celebrities were accessed and published online.
But the bigger risk with cloud storage is privacy. Even if data isn’t stolen or published, it can still be viewed. Governments can legally request information stored in the cloud, and it’s up to the cloud services provider to deny access.
Write a recursive function that has an argument that is an array of characters and two arguments that are the bounds (inclusive) on array indices. The function should reverse the order of those entries in the array whose indices are between the two bounds. For example, if the array is a[0]: ‘A’ a[1]: ‘B’ a[2]: ‘C’ a[3]: ‘D’ a[4]: ‘E’ and the bounds are 1 and 4, then, after the function is run the array elements should be a[0]: ‘A’ a[1]: ‘E’ a[2]: ‘D’ a[3]: ‘C’ a[4]: ‘B’ Consider the following declaration for your function: void flipArray( char arr[], unsigned int from, unsigned int to ); Test your code before writing it out. You may safely assume that from and to are valid indices with respect to arr.
Answer:
Here is the C++ program:
#include <iostream> // for input output functions
using namespace std; // to identify objects like cin cout
/* recursive function to reverse the order of array elements between two bound of array indices */
void flipArray(char arr[], unsigned int from, unsigned int to) {
if (from >= to) // base case
return;
swap(arr[from], arr[to]);
//function to swap characters according to specified values in from and to
flipArray(arr, from + 1, to - 1); } // recursive function call
int main() { //start of main() function body
int size; //stores the number of elements in array
cout<<"Enter the size of the array: "; // prompts user to enter array size
cin>>size; // reads array size from user
char array[size]; // array of size specified by user
cout<<"Enter the characters: "; //prompts user to enter elements in array
// loop to take input characters in array according to specified size
for (int i = 0; i < size; ++i)
{cin >> array[i];} // reads array elements from user
unsigned int i,j; // stores values of two bounds of indices
cout<<"Enter the two bounds of array indices:";
// prompts user to enter two bounds of array indices
cin>>i>>j; //reads array indices from user
//displays original array elements
cout << "The original array is: "<<array<< endl;
flipArray(array,i,j); //calls flipArray() function
cout << "Array after flip from "<< i<<"to "<<j<<" is: "<<array << endl; }
/*displays elements of array after reversing array characters according to bounds of array indices */
Explanation:
The program is explained in the given comments with every statement. Lets understand the logic of the recursive function for the input array that has characters: A B C D E and two bounds 1 and 4 i.e. from B to E
First the base condition if (from >= to) is checked. Here the value of from is 1 and value of to is 4. So the base condition evaluates to false as 1 < 4So the program control moves to the next statement: swap(arr[from], arr[to]); which swaps the array characters from the two indices 1 and 4.
arr [1] = B, arr [4] = E
So B and E are swapped.
A E C D B
Next statement: flipArray(arr, from + 1, to - 1); is a call to recursive function flipArray,
from + 1 = 1+1 = 2 So now the from index moves one position ahead
to - 1 = 4 - 1 = 3 So now the to index moves one position behind
So new value of from = 2 and to = 3
The base condition is check again which evaluates to false as 2<3The swap() function swaps the elements at indices 2 and 3 which means:
arr[2] = C
arr[3] = D
So C and D are swapped.
A E D C B
Next is the call to recursive function flipArray()
from + 1 = 2 + 1 = 3
to - 1 = 3 - 1 = 2
So the value of from = 3 and value of to = 2
Now the base condition is checked again and it evaluates to true as 3>2So this is the stop condition.
Hence the array after flip is:
A E D C B
The program along with its output is attached in the screen shot.
You have been asked to write a two-page report that explains the extent to which the IT department can configure the cryptographic features of Word 2010. What is the process involved in configuring encryption?
Answer:Encryption is the process
of translating plain text data into something that appears to be random and meaningless. A symmetric key is used during both the encryption and decryption process. To decrypt a particular piece of ciphertex, the key that was used to encrypt the data must be used.
Types of encryption
1.Symmetric encryption :This is also known as public key encryption. In symmetric encryption, there is only one key, and all communication patties use the same key for encryption and decryption.
2.Asymmetric encryption :This is foundational technology for SSL(TLS)
How encryption is being configured
Encryption uses algorithms to scramble your information. It is then transmitted to the receiving party, who is able to decode the message with a key.
Explanation:
Describe a defense in depth strategy from an Information Systems Manager perspective; for a medium size organization with 3 campuses. There is one main campus and two satellite campuses. Campuses need communications amongst all campuses and remote workers need access to company data and email. Explain the following in your defense in depth strategy with the following concepts:
a.Confidentiality,
b.Integrity,
c.Availability,
d.Information Security,
e.Risk management,
e.Vulnerability management
Answer:
Explanation:
Confidentiality: This involves the protection of the information from being accessed by unauthorized persons within or outside of the organization as an attempt by an outsider to access it could lead to a breach which may not be easily remedied.
Integrity: This is concerned with ensuring that the information provided to the users are from a reliable source and that the information is not being altered en-route.
Availability: This means that the information is readily accessible to the authorized users. Any attempt for the unavailability of service or information could have been a denial of service (DNS) from an attacker (black hat).
Risk management: This is the understanding of the security threats and their interaction at an individual, organizational or community level. This involves assessment of possible threats as well as vulnerability.
Vulnerability Management: This is a measure taken in reducing the flaws in codes or networks. This is one of the most easily figured out concept from the five above as there are vulnerability scanners for open ports, insecure software configurations as well as susceptibility to malware infections.
Write the routines with the following declarations: void permute( const string & str ); void permute( const string & str, int low, int high ); The first routine is a driver that calls the second and prints all the permutations of the characters in string str. If str is "abc", then the strings that are output are abc, acb, bac, bca, cab, and cba. Use recursion for the second routine.
Answer:
Here is the first routine:
void permute( const string &str ) { // function with one parameter
int low = 0;
int high = str.length();
permute(str, low, high);
}
Or you can directly call it as:
permute(str, 0, str.length());
Explanation:
The second routine:
void permute( const string &str, int low, int high)
//function with three parameters
{ string str1 = str;
if ( low == high ) { //base case when last index is reached
for (int i = 0; i <= high; ++i)
cout << str1[i]; } //print the strings
else {
for (int i=low; i<high; ++i) { // if base case is not reached
string temp = str1; //fix a character
swap( str1[i], str1[low] ); //swap the values
permute( str1, low + 1, high ); //calling recursive function (recursion case)
swap( str1[i], str1[low] ); } } } //swap again to go to previous position
In this function the following steps are implemented:
A character is fixed in the first position.
Rest of the characters are swapped with first character.
Now call the function which recursively repeats this for the rest of the characters.
Swap again to go to previous position, call the recursive function again and continue this process to get all permutations and stop when base condition is reached i.e. last index is reached such that high==low which means both the high and low indices are equal.
You can write a main() function to execute these functions.
int main() {
string str;
cout << "Enter a string: ";
cin >> str;
permute(str); }
Final answer:
The question requires defining two routines to output all permutations of a given string. The first function 'permute' serves as a driver, while the second 'permute' function is a recursive method that systematically swaps characters to produce each permutation.
Explanation:
Routines to Permute a String:
The task is to write routines to generate all permutations of the characters in a given string. The first function serves as a driver, while the second function uses recursion to perform the actual permutation process.
void permute(const string &str) {
permute(str, 0, str.size() - 1);
}
void permute(const string &str, int low, int high) {
if (low == high) {
cout << str << endl;
} else {
for (int i = low; i <= high; i++) {
// Swap the current index with the low element
swap(str[low], str[i]);
// Recursively call permute on the substring
permute(str, low + 1, high);
// Swap back for the next iteration
swap(str[low], str[i]);
}
}
}
In the above code, permute(const string &str) is the driver function that calls the recursive function permute(const string &str, int low, int high), initiating the process with the full range of the string (from index 0 to the length of the string minus one).
Within the recursive function, when the low index matches the high index, it indicates that a permutation has been generated, and it gets printed. If not, the function enters a for-loop, where recursive calls are made after swapping the current character with the one at the start of the substring defined by low and high. After the recursive call returns, the characters are swapped back to their original position, allowing for correct generation of subsequent permutations.
Mary from sales is asking about the plan to implement Salesforce.com's application. You explain to her that you are in the process of getting technical specifications and pricing so that you can move forward with the rollout. This would be part of which of the following plans?
a) IT architecture
b) IT infrastructure
c) System architecture
d) Server upgrade program
e) IT strategy
Answer:
The correct answer to the following question will be Option b ( IT infrastructure).
Explanation:
This refers to either the integrated devices, applications, network infrastructure, as well as facilities needed by an organization This system to function, run, and maintain.
Your technology infrastructure seems to be the nervous system, which is accountable for supplying end customers with a streamlined operation.Total control of both your operating system infrastructure ensures you can guarantee the channel's safety is tracked.Therefore, it will be a part of the design of Mary.
Final answer:
The process of getting technical specifications and pricing for the rollout of Salesforce.com's application is a part of the organization's IT strategy, as it involves careful and strategic planning.
Explanation:
When explaining to Mary from sales about the plan to implement Salesforce.com's application, and mentioning the process of getting technical specifications and pricing for the rollout, you are discussing a key component of IT strategy.
This is because the process involves planning for the adoption of a significant system, considering its impact on business processes, and assessing the costs and technical requirements. The implementation of an application such as Salesforce.com usually undergoes careful planning within the broader context of the organization's overall technology plan, aligning with business goals and ensuring sustainability and efficiency in operations.
An odometer is the gauge on your car that measures distance traveled. In the United States, an odometer measures in miles; elsewhere else, it measures kilometers. Many vehicles with electronic odometer interfaces can switch between miles and kilometers. Something to consider: if an odometer gets replaced, a new one must be able to be set to some specified mileage. a) Write an Odometer class which must include the following methods: • _init__, _str_1_repr__, overloaded add and substract method The constructor must take two arguments mileage, and any other specification that uses units (you choose the unit specification) . Both arguments must have a default value (you may choose the default values) O Addition and subtraction both have one odometer operand and one numeric operand, where the numeric operand represents the miles being added/subtracted (not two odometer operands). o Addition should be commutative (but not subtraction). o Output methods should always be rounded to 1/10 mile (kilometer), but the odometer itself should maintain full floating-point accuracy. b) Include sample code that uses your class and demonstrates the use of all methods as well as demonstrating error handling. c) at the end of your code show an illustrated run of your code "W" "
Answer:
class Odometer():
def __init__(self, mileage=0, unit='miles'):
if mileage < 0:
raise ValueError('Mileage cannot be in negative')
self.mileage = mileage
if unit in ['miles', 'kilometers']:
self.units = unit
else:
raise ValueError("Miles and kilometer unit are allowed only")
def __repr__(self):
return self.__str__()
def __str__(self):
return 'Mileage: {:.1f} {}'.format(self.mileage, self.units)
def add(self, odometer, distance):
if odometer.units == self.units:
self.mileage = odometer.mileage + distance
elif self.units == 'miles':
self.mileage = odometer.mileage / 1.6 + distance
else:
self.mileage = odometer.mileage * 1.6 + distance
def subtract(self, odometer, distance):
if odometer.units == self.units:
self.mileage = odometer.mileage + distance
elif self.units == 'miles':
self.mileage = odometer.mileage / 1.6 - distance
else:
self.mileage = odometer.mileage * 1.6 - distance
honda_odometer = Odometer(100.56, 'miles')
print('Reading of Honda odometer:', honda_odometer)
new_odometer = Odometer(100, 'kilometers')
print('Reading of New odometer:', new_odometer)
new_odometer.add(honda_odometer, 10)
print('Reading of New odometer after adding honda odometer:', new_odometer)
new_odometer.subtract(honda_odometer,20)
print('Reading of New odometer after subtracting honda odometer:', new_odometer)
Explanation:
Create a class only supports miles and kilometers as units .Create the add method that accepts an odometer, distance and adds it to the current object .Create the subtract method that accepts an odometer and distance and subtract it to the current object .Define function multiply(), and within the function: Get user input() of two strings made of whole numbers Cast the input to int() Multiply the integers and return the equation with result as a str()
Answer:
str(int(input("enter the vale of first whole number: "))*int
(input("Enter the value of the second whole number: ")))
Explanation:
boom this works bc it does boom
In response to the question, a conceptual code example for a multiply() function has been provided where user input is taken, cast to int, multiplied, and the result is returned as a string.
The question asks to define a multiply() function in a programming context, specifically to use user input, cast string to int, perform multiplication, and return the result as a string. Here is a conceptual example of how you might write such a function:
def multiply():The multiply() function first captures two strings from the user, converts them into integers, multiplies them, and then returns the equation with the result as a string.
The two mathematical models of language description are generation and recognition. Describe how each can define the syntax of a programming language.
Answer:
The correct answer to the following question will be "Semantic and Syntax error".
Explanation:
Syntax error:
Corresponds to such a mistake in a pattern sentence structure that is composed in either a specific language of that same coding. Because computer programs have to maintain strict syntax to execute appropriately, any elements of code that would not adhere to the programming or scripting language syntax can result inside a syntax error.
Semantic error:
That would be a logical error. This is because of erroneous logical statements. Write inaccurate logic or code of a program, which results incorrectly whenever the directives are implemented.
So, it's the right answer.
Suppose that one byte in a buffer covered by the Internet checksum algorithm needs to be decremented (e.g., a header hop count field). Give an algorithm to compute the revised checksum without rescanning the entire buffer. Your algorithm should consider whether the byte in question is low order or high order
Answer:
The algorithm required for the question is given below.
Explanation:
Step 1: The data is shown below for the algorithm.
Original checksum.Byte location is decrementable.Price to decrease by what bit.Step 2: Get a checksum compliment from one.
Step 3: Whether byte is of lesser importance to still be decremented by x.
Subtract x from those bytes.Step 4: Whether byte is of higher importance to still be decremented by x.
Subtract 2⁸×x from those bytes.Step 5: Start taking one's outcome compliment to get amended iterator checksum.
Insect population An insect population doubles every generation. Write a while loop that iterates numGeneration times. Inside the while loop, write a statement that doubles currentPopulation in each iteration of the while loop. Function Save Reset MATLAB DocumentationOpens in new tab function currentPopulation = CalculatePopulation(numGeneration, initialPopulation) % numGeneration: Number of times the population is doubled % currentPopulation: Starting population value i = 1; % Loop variable counts number of iterations currentPopulation = initialPopulation; % Write a while loop that iterates numGeneration times while ( 0 ) % Write a statment that doubles currentPopulation in % each iteration of the while loop % Hint: Do not forget to update the loop variable end end 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Code to call your function
Answer:
function currentPopulation = CalculatePopulation(numGeneration, initialPopulation)
i = 1;
currentPopulation = initialPopulation;
while(i <= numGeneration)
currentPopulation = 2* currentPopulation;
i= i+1;
end
end
Explanation:
Assign 1 to i as an initial loop value .Assign initialPopulation to currentPopulation variable.Run the while loop until i is less than numGeneration.Inside the while loop, double the currentPopulation variable.Inside the while loop, Increment the i variable also.
In this exercise we have to use the knowledge of computational language in python to describe a code, like this:
The code can be found in the attached image.
To make it easier the code can be found below as:
function currentPopulation = CalculatePopulation(numGeneration, initialPopulation)
i = 1;
currentPopulation = initialPopulation;
while(i <= numGeneration)
currentPopulation = 2* currentPopulation;
i= i+1;
end
end
See more about python at brainly.com/question/26104476
Which date formats are allowed in Excel for February 14, 2018? Check all that apply.
14-Feb-18
14-Feb
February 14, 2018
2/014/2018
02/14/18
2/14/2018
Answer:
1,2,5 and 6
Explanation:
Hope this helps!!!!!!!
Forever friend and helper,
Cammie:)
The date formats which are allowed in Microsoft Excel for February 14, 2018 are:
A. 14-Feb-18.
B. 14-Feb.
E. 02/14/18.
F. 2/14/2018.
Microsoft Excel can be defined as a software application (program) designed and developed by Microsoft Inc., to avail end users the ability to analyze and visualize spreadsheet documents.
Formatting is simply the appearance of textual information and data in a document such as an Excel spreadsheet.
In Microsoft Excel, an end user can set the display format for the following:
Number.Currency.Percentage.Date.A date provides information about the day, month and year a document was created, last modified, used, etc.
In Microsoft Excel, the date formats which are allowed for February 14, 2018 are:
14-Feb-18. 14-Feb.02/14/18. 2/14/2018.Read more: https://brainly.com/question/23822910
def c_to_f(): # FIXME return # FIXME: Finish temp_c = float(input('Enter temperature in Celsius: ')) temp_f = None # FIXME: Call conversion function # temp_f = ?? # FIXME: Print result # print('Fahrenheit:' , temp_f)
Answer:
def c_to_f(celsius): return celsius * 9/5 + 32 temp_c = float(input('Enter temperature in Celsius: ')) temp_f = None temp_f = c_to_f(temp_c) print('Fahrenheit:' , temp_f)Explanation:
The first piece of code we can fill in is the formula to convert Celsius to Fahrenheit and return it as function output (Line 2).
The second fill-up code is to call the function c_to_f and pass temp_c as argument (Line 7). The temp_c will be processed in the function and an equivalent Fahrenheit value will be returned from the function and assigned it to temp_f.
Write me some pseudocode for one pass of the Selection Sort algorithm through random values stored in an Unordered-List, or Linked-List, of values (rather than a standard "Python" List).
• How would you implement a swap using a Linked-List?
• What is the minimum number of variables required?
Answer:
Minimum of 6 variables is required
Explanation:
class LinkedList:
def __init__(self, v):
self.data = v
self.next = None
def sortSelections(first):
x = y = first
while y.next:
z = p = y.next
while p:
if y.data > p.data:
if y.next == p:
if y == first:
y.next = p.next
p.next = y
y, p = p, y
z = p
first = y
p = p.next
else:
y.next = p.next
p.next = y
x.next = p
y, p = p, y
z = p
p = p.next
else:
if y == first:
r = y.next
y.next = p.next
p.next = r
z.next = y
y, p = p, y
z = p
p = p.next
first = y
else:
r = y.next
y.next = p.next
p.next = r
z.next = y
x.next = p
y, p = p, y
z = p
p = p.next
else:
z = p
p = p.next
x = y
y = y.next
return first
def display(first):
while first:
print(first.data, end = " ")
first = first.next
if __name__ == "__main__":
print("Sorted List: ")
first = LinkedList(53)
first.next = LinkedList(14)
first.next.next = LinkedList(2)
first.next.next.next = LinkedList(9)
first.next.next.next.next = LinkedList(92)
first = sortSelections(first)
display(first)
In Java, variables of the super class class can point to objects of the subclass. For example, if Student is a super class to Athletes, then any variable (say s) of type Student can point to either Student or Athlete objects. Sometimes we want to know exactly whether s is pointing to Student or pointing to Athlete. This can be accomplished with an if statement. Complete the missing part in the following if statement so it prints YES if the variable s is currently pointing to an Athlete if (s ____________ Athlete) System.out.print("YES");
Answer:
"instanceof" is the correct answer for the above question.
Explanation:
The "instanceof" is a statement in java, which is used to check for an object that any object is derived from that class or not. The syntax of this statement is "object instanceof class name". If the object is derived from declared class, then it will result in true or otherwise it will result in false.The above question asked about that condition which is used to check that the s object is derived from the Athlete class or not so when the if condition blanks will fill from the "instanceof", then the user will get the if condition which can check. Hence "instanceof" is the correct answer.Write a function, named "wait_die_scheduler" that takes a list of actions, and returns a list of actions according to the following rules. The actions given to the scheduler will only consist of WRITE and COMMIT actions. (Hence only exclusive locks need be implemented.) Each transaction will end with a COMMIT action. Before examining each action, attempt to perform an action for each of the transactions encountered (ordered by their names). After all the actions have been examined, continue to attempt to perform an action from each transaction until there are no more actions to be done. You will need to add LOCK, UNLOCK, and ROLLBACK actions to the list of actions to be returned, according to the Wait-Die protocol. If releasing more than one lock (for instance after a COMMIT), release them in order by the name of their object. Use the deferred transaction mode (only requesting locks when needed).
To implement the `wait_die_scheduler` function according to the Wait-Die protocol for handling WRITE and COMMIT actions in transactions, we'll simulate a scheduler that ensures correct behavior with respect to locks and transaction order. The Wait-Die protocol is used to manage concurrency and handle conflicts between transactions efficiently. Below is a Python implementation of this scheduler function:
def wait_die_scheduler(actions):
# Data structures to track locks and actions
locks = {} # Dictionary to track locks by object name
results = [] # List to collect final actions to be returned
# Process the list of actions
for action in actions:
transaction_name = action[0]
action_type = action[1]
object_name = action[2]
# If action is WRITE or COMMIT
if action_type == 'WRITE' or action_type == 'COMMIT':
# Check if the transaction already has a lock on the object
if object_name in locks and locks[object_name] != transaction_name:
# Conflict detected, need to resolve based on Wait-Die protocol
# Check order of transactions for waiting or aborting
if transaction_name < locks[object_name]:
# Current transaction waits (older transaction, so wait)
results.append((transaction_name, 'WAIT', object_name))
else:
# Current transaction aborts (newer transaction, so abort)
results.append((transaction_name, 'ROLLBACK', object_name))
# Release locks held by the aborted transaction
results.extend([(locks[obj], 'UNLOCK', obj) for obj in sorted(locks.keys())])
locks.clear() # Clear all locks after rollback
else:
# No conflict, acquire lock for the transaction
locks[object_name] = transaction_name
# Add the original action to the results
results.append((transaction_name, action_type, object_name))
# If action is COMMIT, release locks held by the committed transaction
if action_type == 'COMMIT':
results.extend([(locks[obj], 'UNLOCK', obj) for obj in sorted(locks.keys())])
locks.clear() # Clear all locks after commit
# Final pass to release any remaining locks (should not normally occur)
results.extend([(locks[obj], 'UNLOCK', obj) for obj in sorted(locks.keys())])
locks.clear() # Clear all locks after processing all actions
return results
# Example usage
actions = [
('T1', 'WRITE', 'A'),
('T2', 'WRITE', 'B'),
('T1', 'COMMIT', 'A'),
('T2', 'COMMIT', 'B'),
('T1', 'WRITE', 'B'),
('T1', 'COMMIT', 'B')
]
result_actions = wait_die_scheduler(actions)
for action in result_actions:
print(action)
Explanation of the `wait_die_scheduler` function:
1. Initialization: We start by defining empty data structures (`locks` and `results`) to track locks on objects and the resulting list of actions.
2. Processing Actions: Iterate through each action in the provided list (`actions`). Each action is a tuple consisting of transaction name, action type (`WRITE` or `COMMIT`), and the object name.
3. Handling WRITE and COMMIT Actions:
- For a `WRITE` action:
- Check if the transaction already holds a lock on the object.
- If there's a conflict (another transaction holds the lock), resolve it based on the Wait-Die protocol by either making the current transaction wait or aborting it.
- For a `COMMIT` action:
- Release all locks held by the committed transaction.
4. Building Resulting Actions:
- Append the original action to the `results` list.
- If a transaction commits or aborts, add corresponding `UNLOCK` actions for all locks held by the transaction.
5. Final Cleanup: Ensure all locks are released after processing all actions.
This implementation follows the Wait-Die protocol by managing locks, resolving conflicts between transactions, and ensuring correct order of operations according to the protocol rules. Adjustments may be needed based on specific requirements or variations of the Wait-Die protocol for different scenarios.
In the lab, you wrote a four-paragraph __________ that summarized your findings, described the approach and prioritization of critical, major, and minor risk assessment elements, included a risk assessment and risk impact summary of the seven domains of a typical IT infrastructure, and provided recommendations and next steps for executive management.
a.management overview
b.risk assessment outline
c.IT infrastructure recap
Answer:
b
Explanation:
c++ design a class named myinteger which models integers. interesting properties of the value can be determined. include these members: a int data field named value that represents the integer's value. a constructor that creates a myinteger object with a specified int value. a constant getter that returns the value
Answer:
#include <iostream>using namespace std;class myinteger { private: int value; public: myinteger(int x){ value = x; } int getValue(){ return value; } };int main(){ myinteger obj(4); cout<< obj.getValue(); return 0;}Explanation:
Firstly, we use class keyword to create a class named myinteger (Line 5). Define a private scope data field named value in integer type (Line 7 - 8).
Next, we proceed to define a constructor (Line 11 - 13) and a getter method for value (Line 15 -17) in public scope. The constructor will accept one input x and set it to data field, x. The getter method will return the data field x whenever it is called.
We test our class by creating an object from the class (Line 23) by passing a number of 4 as argument. And when we use the object to call the getValue method, 4 will be printed as output.
The input is an N by N matrix of numbers that is already in memory. Each individual row is increasing from left to right. Each individual column is increasing from top to bottom. Give an O(N) worst-case algorithm that decides if a number X is in the matrix.
Final answer:
An efficient O(N) algorithm can determine if a number X is present in an N x N sorted matrix by starting from the top-right corner and moving left or down through matrix elements based on comparisons with X, eliminating one row or column at a time.
Explanation:
Suppose we have an N x N matrix, where each row is sorted in increasing order from left to right and each column is sorted in increasing order from top to bottom. To determine if a given number X is in this matrix, we can employ an efficient algorithm with a time complexity of O(N), which is much faster than checking every element in the matrix.
The algorithm starts from the top-right corner of the matrix. At each step, if the current element is greater than X, we move one step to the left. If the current element is less than X, we move one step down. If the current element is equal to X, we return true, indicating that X is found in the matrix. If we reach the left border or the bottom border of the matrix without finding X, we return false.
This algorithm works because the matrix is sorted row-wise and column-wise, allowing us to eliminate a row or a column at each step. Hence, we perform at most N steps, leading to a worst-case time complexity of O(N).
Your supervisor manages the corporate office where you work as a systems analyst. Several weeks ago, after hearing rumors of employee dissatisfaction, he asked you to create a survey for all IT employees. After the responses were returned and tabulated, he was disappointed to learn that many employees assigned low ratings to morale and management policies.
This morning he called you into his office and asked whether you could identify the departments that submitted the lowest ratings. No names were used on the individual survey forms. However, with a little analysis, you probably could identify the departments because several questions were department-related.
Now you are not sure how to respond. The expectation was that the survey would be anonymous. Even though no individuals would be identified, would it be ethical to reveal which departments sent in the low ratings? Would your supervisor’s motives for wanting this information matter?
Maintaining confidentiality in employee surveys is essential to ensure honest feedback and protect employee trust. Identifying departments with low morale raises ethical considerations, particularly when the survey was intended to be anonymous.
Workplace Confidentiality and Ethical Dilemmas
When managing confidential employee surveys, such as an attitude survey, it is crucial to maintain the confidentiality of employees' responses. This is important for cultivating trust and fostering an environment where employees feel safe to express genuine concerns. The ethical dilemma arises when considering whether to identify departments with low morale based on non-anonymized data, which could breach confidentiality agreements and potentially erode trust. The intention behind identifying these departments is a crucial element to consider: if it's for the purpose of targeted improvements without repercussions, it may be more justifiable than if it were for punitive measures.
Organizational behavior research argues for the importance of maintaining confidentiality to get honest responses and the negative impacts when surveys lead to no action. Actionability from survey results is key, but it must respect the promised confidentiality. This also relates to issues of social desirability bias, where respondents may skew their answers to appear more favorable when anonymity isn't assured. Trust both in the confidentiality and the constructive use of survey data is vital for the ongoing success of such workplace assessments.
Any effort to identify departments from the survey data should be carefully weighed against ethical considerations, and if pursued, it should be done transparently and with a clear, constructive action plan to address the issues without targeting individuals.
You are tasked to calculate a specific algebraic expansion, i.e. compute the value of f and g for the expression: ???? = (???????? − ???????????? + ???????????? − ????????) ???? = (???????????? + ????????????????) without using any intrinsic multiplication instructions, subroutines, and function calls. More formally, write MIPS assembly code that accepts four positive integers A, B, C, and D as input parameters.
Answer:
.data
prompt: .asciiz "Enter 4 integers for A, B, C, D respectively:\n"
newLine: .asciiz "\n"
decimal: .asciiz "f_ten = "
binary: .asciiz "f_two = "
decimal2: .asciiz "g_ten = "
binary2: .asciiz "g_two = "
.text
main:
#display prompt
li $v0, 4
la $a0, prompt
syscall
#Read A input in $v0 and store it in $t0
li $v0, 5
syscall
move $t0, $v0
#Read B input in $v0 and store it in $t1
li $v0, 5
syscall
move $t1, $v0
#Read C input in $v0 and store it in $t2
li $v0, 5
syscall
move $t2, $v0
#Read D input in $v0 and store it in $t3
li $v0, 5
syscall
move $t3, $v0
#Finding A^4
#Loop (AxA)
li $t6, 0
L1:
bge $t6, $t0, quit
add $s1, $s1, $t0 # A=S+A => $s1= A^2
addi $t6, $t6, 1 # i=i+1
j L1
quit:
#Loop (A^2 x A^2)
li $t6, 0
L1A:
bge $t6, $s1, quit1A
add $s5, $s5, $s1
addi $t6,$t6, 1
j L1A
#End of Finding A^4
#Finding 4xA^3
quit1A:
#Loop (4xB)
li $t6, 0
L2:
bge $t6, 4, quit2
add $s2, $s2, $t1
addi $t6, $t6, 1
j L2
quit2:
#Loop (BxB)
li $t6 , 0
L2A:
bge $t6, $t1, quit2A #loop2
add $s6, $s6, $t1 #add
addi $t6, $t6, 1 #add immediate
j L2A #loop2
quit2A: # perform proper program termination using syscall for exit
#Loop (BxB)
li $t6 , 0 #load immediate
L2AA:
bge $t6, $s2, quit2AA #loop2
add $t7, $t7, $s6 #add
addi $t6, $t6, 1 #add immediate
j L2AA #loop2
#End ofFinding 4xA^3
#Finding 3xC^2
quit2AA: # perform proper program termination using syscall for exit
#3 Loop (3 x (C x C)) FOR S3
li $t6 , 0 #load immediate
L3:
bge $t6, $t2, quit3 #loop3
add $s3, $s3, $t2 #add
addi $t6,$t6, 1 #add immediate
j L3 #loop3
quit3: # perform proper program termination using syscall for exit
#3 Loop (3 x (C x C)) FOR S3
li $t6 , 0 #load immediate
L3A:
bge $t6, 3, quit3A #loop3
add $s0, $s0, $s3 #add
addi $t6,$t6, 1 #add immediate
j L3A #loop3
#End of Finding 3xC^2
#Finding 2xD
quit3A: # perform proper program termination using syscall for exit
#4 Loop (2 x D) FOR S4
li $t6 , 0
L4:
bge $t6, 2, quit4 #loop4
add $s4, $s4, $t3 #add
addi $t6, $t6, 1 #add immediate
j L4 #Loop4
#End of Finding 2xD
#Finding AxB^2
quit4:
li $t6, 0
li $s1, 0
L5:
bge $t6, $t1, quit5
add $s1, $s1, $t1
addi $t6, $t6, 1
j L5
quit5:
li $t6, 0
li $s2, 0
L6:
bge $t6, $t0, quit6
add $s2, $s2, $s1
addi $t6, $t6, 1
j L6
#End of Finding AxB^2
#Finding C^2XD^3
quit6: #finds C^2
li $t6, 0
li $s1, 0
L7:
bge $t6, $t2, quit7
add $s1, $s1, $t2
addi $t6, $t6, 1
j L7
quit7: #finds D^2
li $t6, 0
li $s6, 0
L8:
bge $t6, $t3, quit8
add $s6, $s6, $t3
addi $t6, $t6, 1
j L8
quit8: #finds D^3
li $t6, 0
li $s7, 0
L9:
bge $t6, $t3, quit9
add $s7, $s7, $s6
addi $t6, $t6, 1
j L9
quit9: #finds C^2XD^3
li $t6, 0
li $s3, 0
L10:
bge $t6, $s1, end
add $s3, $s3, $s7
addi $t6, $t6, 1
j L10
#End of Finding C^2XD^3
end: # perform proper program termination using syscall for exit
#f is $t8
li $t8 , 0
sub $t8, $s5, $t7 # addition
add $t8, $t8, $s0 # subract
sub $t8,$t8, $s4 # subract
#g is $t9
li $t9 , 0
add $t9, $s2, $s3 # addition
#Display
#1st equation
li $v0,4 # display the answer string with syscall having $v0=4
la $a0, decimal # Gives answer in decimal value
syscall # value entered is returned in register $v0
li $v0, 1 # display the answer string with syscall having $v0=1
move $a0, $t8 # moves the value from $a0 into $t8
syscall # value entered is returned in register $v0
li $v0,4 # display the answer string with syscall having $v0=4
la $a0, newLine # puts newLine in between answers
syscall # value entered is returned in register $v0
li $v0,4 # display the answer string with syscall having $v0=4
la $a0, binary # Gives answer in binary
syscall # value entered is returned in register $v0
li $v0, 35
move $a0, $t8 # moves the value from into $a0 from $t8
syscall # value entered is returned in register $v0
li $v0,4 # display the answer string with syscall having $v0=4
la $a0, newLine # puts newLine in between answers
syscall # value entered is returned in register $v0
#2nd equation
li $v0,4 # display the answer string with syscall having $v0=4
la $a0, decimal2 # Gives answer in decimal value
syscall # value entered is returned in register $v0
li $v0, 1 # display the answer string with syscall having $v0=1
move $a0, $t9 # moves the value from $a0 into $t8
syscall # value entered is returned in reg $v0
li $v0,4 # display the answer string with syscall having $v0=4
la $a0, newLine # puts newLine in between answers
syscall # value entered is returned in register $v0
li $v0,4 # display the answer string with syscall having $v0=4
la $a0, binary2 # Gives answer in binary
syscall # value entered is returned in register $v0
li $v0, 35
move $a0, $t9 # moves the value from into $a0 from $t8
syscall # value entered is returned in register $v0
li $v0,4 # display the answer string with syscall having $v0=4
la $a0, newLine # puts newLine in between answers
syscall # value entered is returned in register $v0
#end the program
li $v0, 10
syscall
Methods inherited from the base/super class can be overridden. This means changing their implementation; the original source code from the base class is ignored and new code takes its place. Abstract methods must be overridden.
Answer:
False
Explanation:
Methods inherited from the base/super class can be overridden only if behvior is close enough. The overridding method should have same name, type and number of parameters and same return type.
Answer:
False.this statement is false because, im not sure, but its for sure false.
Methods inherited from the base/super class can be overridden only if behvior is close enough. The overridding method should have same name, type and number of parameters and same return type.
Write a function sum them() that sums a set of integers, each of which is the square or cube of a provided integer. Specifically, given an integer n from a list of values, add n2 to the total if the number’s index in nums is even; otherwise, the index is odd, so add n3 to the total.
Answer:
# sum_them function is defined
def sum_them():
# A sample of a given list is used
given_list = [1, 2, 3, 4, 5, 6, 6, 9, 10]
# The total sum of the element is initialized to 0
total = 0
# for-loop to goes through the list
for element in given_list:
# if the index of element is even
# element to power 2 is added to total
if(given_list.index(element) % 2 == 0):
total += (element ** 2)
else:
# else if index of element is odd
# element to power 3 is added to total
total += (element ** 3)
# The total sum of the element is displayed
print("The total is: ", total)
# The function is called to display the sum
sum_them()
Explanation:
The function is written in Python and it is well commented.
Image of sample list used is attached.
Develop a Python program. Define a class in Python and use it to create an object and display its components. Define a Student class with the following components (attributes): Name Student number Number of courses current semester
Answer:
class Student: def __init__(self, Name, Student_Num, NumCourse): self.Name = Name self.Student_Num = Student_Num self.NumCourse = NumCourse s1 = Student("Kelly", 12345, 4) print(s1.Name) print(s1.Student_Num) print(s1.NumCourse)Explanation:
Firstly, use the keyword "class" to create a Student class.
Next, create a class constructor (__init__) that takes input for student name, student number and number of course (Line 2) and assign the input to the three class attributes (Line 3-5). All the three class attributes are preceded with keyword self.
Next, create a student object (Line 7) and at last print all the attributes (Line 8-10).
In order to paint a wall that has a number of windows, we want to know its area. Each window has a size of 2 ft by 3 ft. Write a program that reads the width and height of the wall and the number of windows,.
Answer:
6ft
Explanation:
Step 1:
import java.util.Scanner;
class AreaOfRectangle {
public static void main (String[] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the length of Rectangle:");
double length = scanner.nextDouble();
System.out.println("Enter the width of Rectangle:");
double width = scanner.nextDouble();
//Area = length*width;
double area = length*width;
System.out.println("Area of Rectangle is:"+area);
}
}
Output
Enter the length of Rectangle:
2
Enter the width of Rectangle:
3
Area of Rectangle is:6.0
write an assembly language procedure that also performs the binary search. The C program will time multiple searches performed by both the C code and your assembly language procedure and compare the result. If all goes as expected, your assembly language procedure should be faster than the C code.
Answer:
Let’s identify variables needed for this program.
First variables will be the one which will hold the values present in the Given Numbers in Array list and key of 16-bit and it will be array ARR and KEY. variables will be holding the Messages MSG1 “KEY IS FOUND AT “, RES ” POSITION”, 13, 10,” $” and MSG2 ‘KEY NOT FOUND!!!.$’ to be printed for the User. Other variables will be holding Length of the Array and it will be LEN, So in all Six variables.
The identified variables are ARR, KEY, LEN, RES, MSG1 and MSG2.
DATA SEGMENT
ARR DW 0000H,1111H,2222H,3333H,4444H,5555H,6666H,7777H,8888H,9999H
LEN DW ($-ARR)/2
KEY EQU 7777H
MSG1 DB "KEY IS FOUND AT "
RES DB " POSITION",13,10," $"
MSG2 DB 'KEY NOT FOUND!!!.$'
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX
MOV BX,00
MOV DX,LEN
MOV CX,KEY
AGAIN: CMP BX,DX
JA FAIL
MOV AX,BX
ADD AX,DX
SHR AX,1
MOV SI,AX
ADD SI,SI
CMP CX,ARR[SI]
JAE BIG
DEC AX
MOV DX,AX
JMP AGAIN
BIG: JE SUCCESS
INC AX
MOV BX,AX
JMP AGAIN
SUCCESS: ADD AL,01
ADD AL,'0'
MOV RES,AL
LEA DX,MSG1
JMP DISP
FAIL: LEA DX,MSG2
DISP: MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START
In this Assembly Language Programming, A single program is divided into four Segments which are 1. Data Segment, 2. Code Segment, 3. Stack Segment, and 4. Extra Segment. Now, from these one is compulsory i.e. Code Segment if at all you don’t need variable(s) for your program.if you need variable(s) for your program you will need two Segments i.e. Code Segment and Data Segment.
Explanation:
The attached Logic is a C like Program to conduct a binary search we need small Algorithm Shown above in a very simple way, So Just we will covert the logic into Assembly There are many things uncommon in the programing Language. There are No While Loops or Modules but this things are to be implemented in different ways.
Create a class named College Course that includes data fields that hold the department (for example, ENG), the course number (for example, 101), the credits (for example, 3), and the fee for the course (for example, $360). All of the fields are required as arguments to the constructor, except for the fee, which is calculated at $120 per credit hour. Include a display () method that displays the course data. Create a subclass named Lab Course that adds $50 to the course fee. Override the parent class display () method to indicate that the course is a lab course and to display all the data. Write an application named UseCourse that prompts the user for course information. If the user enters a class in any of the following departments, create a LabCourse: BIO, CHM, CIS, or PHY. If the user enters any other department, create a CollegeCourse that does not include the lab fee. Then display the course data. Save the files as CollegeCourse.java, LabCourse.java, and UseCourse.java.
Answer:
File: clgCourse.java
public class clgCourse
{
private final double CREDIT_HOUR_FEE = 120.00;
private String dpt;
private int courseNo;
private int credits;
private double courseFee;
public clgCourse(String newdpt, int newcourseNo, int newCredits)
{
dpt = newdpt.toUpperCase();
courseNo = newcourseNo;
credits = newCredits;
courseFee = CREDIT_HOUR_FEE * credits;
}
public String getdpt()
{
return dpt;
}
public int getcourseNo()
{
return courseNo;
}
public int getCredits()
{
return credits;
}
public double getcourseFee()
{
return courseFee;
}
public void display()
{
System.out.println("\n Course Data");
System.out.println("Course: " + "College Course");
System.out.println("dpt: " + this.getdpt());
System.out.println("Course Number: " + this.getcourseNo());
System.out.println("Credit Hours: " + this.getCredits());
System.out.println("Course Fee: $" + this.getcourseFee());
}
}
File: LabCourse.java
public class LabCourse extends clgCourse
{
private final double LAB_FEE = 50.00;
private double labCourseFee;
public LabCourse(String newdpt, int newcourseNo, int newCredits)
{
super(newdpt, newcourseNo, newCredits);
labCourseFee = super.getcourseFee() + LAB_FEE;
}
public double getLabCourseFee()
{
return labCourseFee;
}
public void display()
{
System.out.println("\n Course Data");
System.out.println("Course: " + "Lab Course");
System.out.println("dpt: " + super.getdpt());
System.out.println("Course Number: " + super.getcourseNo());
System.out.println("Credit Hours: " + super.getCredits());
System.out.println("Course Fee: $" + this.getLabCourseFee());
}
}
File: UseCourse.java
import java.util.Scanner;
public class UseCourse
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter the dpt of the course: ");
String dept = keyboard.nextLine();
System.out.print("Enter the number of the course: ");
int number = keyboard.nextInt();
System.out.print("Enter the credit hours of the course: ");
int hours = keyboard.nextInt();
if(dept.equalsIgnoreCase("BIO") || dept.equalsIgnoreCase("CHM")
|| dept.equalsIgnoreCase("CIS") || dept.equalsIgnoreCase("PHY"))
{
LabCourse labCourse = new LabCourse(dept, number, hours);
labCourse.display();
}
else
{
clgCourse clgCourse = new clgCourse(dept, number, hours);
clgCourse.display();
}
keyboard.close();
}
}
Explanation:
Create a getdpt method that returns the dpt of the course .Create a getcourseNo method that returns the number of the course.Create a display method that displays all the data of college course .Check if the user enters any of the lab dpts (BIO, CHM, CIS, or PHY), then create a LabCourse and then display the course data .Check if the user does not enter any of the lab dpts (BIO, CHM, CIS, or PHY), then create a clgCourse and then display the course data .