Answer:
Explanation:
CHECK THE ANSWER IN THE ATTACHMENT CORNNER
Consider a disk queue with requests for I/O to blocks on cylinders.
98 183 37 122 14 124 65 67
Considering SSTF (shortest seek time first) scheduling, the total number of head movements is, if the disk head is initially at 53 is?
A. 224
B. 236
C. 240
D. 200
A Musician class has been built that takes the name, number of albums sold, and number of weeks that artist has been on the Top40 list. The Musician class also has a boolean instance variable isPlatinum that determines if the musician has gone platinum, meaning they’ve sold over a million copies of the same record. The Billboard class currently has a top10 ArrayList that will store the top 10 musicians as a list. In the Billboard class, create an add method that will add a musician to the list if there are less than 10 musicians in the list, and if the musician has Platinum status. If there are 10 musicians in the list, then the method should call the replace method. Otherwise, a message should be displayed to the user that the musician could not be added to the top10 list. The replace method compares the total number of weeks that the musician has been on the top40 list. If the musician with the lowest number of weeks on the top40 is lower than the number of weeks on the top40 of the new musician, then the old musician is replaced by the new one. There should be a message to the user that the old musician has been replaced by the new one. Otherwise, the user should be notified that the new musician cannot be added because they don’t have enough weeks on the top40. This method should be created in the Billboard class. Use the BillboardTester class to test if the new musicians being added are being correctly replaced, or omitted from the Top 10.
Answer:
See explaination for program code
Explanation:
Java code below:
Musician.java :
public class Musician {
private String name;
private int weeksInTop40;
private int albumsSold;
private boolean isPlatinum;
public Musician(String name, int weeksInTop40, int albumsSold) {
this.name = name;
this.weeksInTop40 = weeksInTop40;
this.albumsSold = albumsSold;
setPlatinum(albumsSold);
}
public void setPlatinum(int albumsSold) {
if(albumsSold >= 1000000) {
isPlatinum = true;
}else {
isPlatinum = false;
}
}
public int getWeeksInTop40() {
return this.weeksInTop40;
}
public String getName() {
return this.name;
}
public boolean getIsPlatinum() {
return this.isPlatinum;
}
public String toString() {
return this.name;
}
}
Billboard.java :
import java.util.ArrayList;
public class Billboard {
private ArrayList<Musician> top10 = new ArrayList<Musician>();
public void add(Musician newMusician) {
if(this.top10.size()<10 && newMusician.getIsPlatinum()==true) {
/**
* Less than 10 musician are present in the list currently
* And also the newMusician is platinum
* */
this.top10.add(newMusician);
}else {
if(newMusician.getIsPlatinum()==false) {
System.out.println("The new musician "+newMusician+" cannot be added because not enough records are sold");
}else {
/**
* We need to call the replace method
* */
replace(newMusician);
}
}
}
public void replace(Musician newMusician) {
/**
* First we need to find what is the lowest number of weeks
* an musician was there in top40.
* */
int lowestOnTop40 = Integer.MAX_VALUE;
int index=-1;
for(int i=0;i<this.top10.size();i++) {
if(this.top10.get(i).getWeeksInTop40()<lowestOnTop40) {
lowestOnTop40 = this.top10.get(i).getWeeksInTop40();
index = i;
}
}
/**
* We have at what position the lowest number of week on top value in variable
* lowestOnTop40 at index
* We need to compare this value with newMusician's number of weeks on top 40
* */
if(lowestOnTop40 < newMusician.getWeeksInTop40()) {
System.out.println("The old musician "+this.top10.get(index)+" has been replaced by new musician "+newMusician);
this.top10.set(index, newMusician);
}else {
System.out.println("The new musician "+newMusician+" cannot be added because not enough weeks on top40.");
}
}
public void printTop10() {
System.out.println(top10);
}
}
BillboardTester.java :
public class BillboardTester {
public static void main(String[] args) {
Billboard top10 = new Billboard();
top10.add(new Musician("Beyonce", 316, 100000000));
top10.add(new Musician("The Beatles", 365, 600000000));
top10.add(new Musician("Drake", 425, 150000000));
top10.add(new Musician("Pink Floyd", 34, 250000000));
top10.add(new Musician("Mariah Carey", 287, 200000000));
top10.add(new Musician("Rihanna", 688, 250000000));
top10.add(new Musician("Queen", 327, 170000000));
top10.add(new Musician("Ed Sheeran", 536, 150000000));
top10.add(new Musician("Katy Perry", 317, 143000000));
top10.add(new Musician("Justin Bieber", 398, 140000000));
//This musician should not be added to the top10 because they don't have enough records sold
top10.add(new Musician("Karel the Dog", 332, 60));
//This musician should replace the artist
top10.add(new Musician("Tracy the Turtle", 332, 150000000));
//This musician should not replace an artist, but is a Platinum artist
top10.add(new Musician("Alex Eacker", 100, 23400000));
top10.printTop10();
}
}
A professor wants to know if students are getting enough sleep. Each day, the professor observes whether the students sleep in class, and whether they have red eyes. The professor has the following domain theory:
• The prior probability of getting enough sleep, with no observations, is 0.7.
• The probability of getting enough sleep on night t is 0.8 given that the student got enough sleep the previous night, and 0.3 if not.
• The probability of having red eyes is 0.2 if the student got enough sleep, and 0.7 if not.
• The probability of sleeping in class is 0.1 if the student got enough sleep, and 0.3 if not.
Answer:
Each day, the professor observes whether the students sleep in class, and whether they have red eyes. The professor has the following domain theory: • The prior probability of getting enough sleep, with ... The probability of having red eyes if the student did not get enough sleep. • The probability of sleeping in class is if the ...
Explanation:
Consider a Web form that a student would use to input student information and rèsumè information into a career services application at your university. Sketch out how this form would look and identify the fields that the form would include. What types of validity checks would you use to make sure that the correct information is entered into the system?
Answer:
valid check: Completeness check, Format check, Range check, Consistency check
Explanation:
Form validations required are:
Completeness check:-all fields are filled accordingly
Format check:-Each field entered data is correct format or not
Range check:-Range of data min or max
Consistency check:-Entering consistent data
Database check
Fields are:
Text Boxes,Drop down list box,radio button,check box,button,slider(if you want to rate or show interest of a subject),combo box(group together radio buttons/check boxes/sliders).
See attachment please for the sketch
JAVA
Given an array of Student names, create and return an array of Student objects.
I wrote some code but I'm not sure if I'm doing this right (see the attachment).
Answer:
Answer is in the attached screenshot!
Explanation:
Iterate through the given input strings, create a student class with the given name, assign the output array to the value of the class created from the given input string. Finally, return the array.
What is technology??
Answer:
Technology is the skills, methods, and processes used to achieve goals. People can use technology to: Produce goods or services. Carry out goals, such as scientific investigation or sending a spaceship to the moon. Solve problems, such as disease or famine.
Explanation:
Good Luck!
Technology refers to the application of scientific knowledge, tools, and techniques for practical purposes.
Technology involves the creation, development, and utilization of various systems, methods, processes, and devices to solve problems, improve efficiency, enhance productivity, and achieve specific goals in different domains.
Technology encompasses a wide range of fields and disciplines, including engineering, computer science, electronics, telecommunications, biotechnology, information technology, and more. It involves the design, production, and utilization of tangible and intangible artifacts, such as machinery, software, infrastructure, systems, algorithms, and networks.
Technology is constantly evolving and advancing, driven by research, innovation, and human creativity. It plays a significant role in shaping societies, economies, and cultures, influencing various aspects of our lives.
Overall, technology encompasses the tools, knowledge, and systems that enable the practical application of scientific understanding to address challenges, improve efficiency, and enhance human experiences in the modern world.
Learn more about Technology here:
https://brainly.com/question/9171028
#SPJ6
For the description below, develop an E-R diagram:
A book is identified by its ISBN number, and it has a title, a price, and a date of publication. It is published by a publisher, each of which has its own ID number and a name. Each book has exactly one publisher, but one publisher typically publishes multiple books over time. A book is written by one or multiple authors. Each author is identified by an author number and has a name and date of birth. Each author has either one or multiple books; in addition, occasionally data are needed also regarding prospective authors who have not yet published any books. A book can be part of a series, which is also identified as a book and has its own 2 ISBN number. One book can belong to several sets and a set consists of at least one but potentially many books.
An E-R diagram for a library database would include entities for books, publishers, authors, and series, with relationships defined between them. A many-to-many relationship between authors and books, as well as books and series, requires the use of Junction Tables to effectively manage these complex relationships.
Development of an E-R Diagram Based on a Description
A book is identified by its ISBN number, and it has a title, price, and date of publication. Each book is published by a publisher that has a unique ID number and name. There is a one-to-many relationship between publishers and books since each book has exactly one publisher, but a publisher can publish multiple books. Conversely, a book is written by authors, and each author has an author number, name, and date of birth, indicating a many-to-many relationship between authors and books. To address this, we introduce a Junction Table to split the many-to-many into two one-to-many relationships. Each author could have written multiple books, and each book could have multiple authors.
Furthermore, books can be part of a series, with a series being identified as a book with its own ISBN number. A single book can belong to multiple series, creating a many-to-many relationship between books and series. Again, a Junction Table is needed to properly manage this relationship. The database also includes information about prospective authors who haven't published books yet, signifying the importance of having an authors' table regardless of publication status.
The Entity Relationship Modeling (ERM) process begins with determining the purpose of the database and listing all the necessary entities. These entities are then connected through relationships, with Junction Tables being used to resolve many-to-many relationships. Important attributes and keys for each entity are identified, ensuring that adequate information is recorded and can be retrieved effectively.
1) Your program must contain functions to: deposit, withdraw, balance inquiry and quit. 2) Based on the selection made by the user the functions must be called with the following criteria: a. A user can deposit any amount of money in their account. The function must display the new balance after depositing. by. A person can withdraw an amount as long as it is lower than or equal to his current balance. The function must also display a warning if the new balance is below $100. Must not allow the user to withdraw if amount is great than current balance. Before this function ends - the new balance must be displayed. c. Balance inquiry function must display the balance.
Answer:
import java.util.Scanner;
public class num6 {
static double balance = 10000.5; //Current Balance
//The main Method
public static void main(String[] args) {
//Request User Input
System.out.println("Enter 1 for deposit \nEnter 2 for Withdraw\nEnter 3 for Balance Enquiry\n0 to quit ");
Scanner in = new Scanner(System.in);
int op = in.nextInt();
//Check to determine the Operation the user wants
if(op == 1){
System.out.println("Enter amount to deposit");
double depositeAmount = in.nextDouble();
deposit(depositeAmount); //Call the deposit method
}
if(op == 2){
System.out.println("Enter amount to Withdraw");
double withdrawAmount = in.nextDouble();
//validate the withdraw amount
if(withdrawAmount > balance){
System.out.println("Insuffucient fund");
System.out.println("Your current balance is "+balance);
}
else {
withdraw(withdrawAmount);//Call withdraw Method
}
}
if(op == 3){
balanceEnquiry();
}
}
//Deposit Method
public static double deposit(double depositAmount){
double newBalance = balance + depositAmount;
System.out.println("You deposited "+depositAmount+"Your new balance is "+newBalance);
return newBalance;
}
//Withdraw Method
public static double withdraw(double withdrawAmount){
double newBalance = balance - withdrawAmount;
System.out.println("You Withdrew "+withdrawAmount+"Your new balance is "+newBalance);
if(newBalance < 100){
System.out.println("Your Balance is low");
}
return newBalance;
}
//Balance Enquiry Method
public static void balanceEnquiry(){
System.out.println("Your current balance is "+balance);
}
}
Explanation:
This is solved in Java programming language
See code explation provided as comments
Write a complete program that declares an array of 1000 integers and initializes each element in the array to have a value equal to the index of that element. That is, the value at index 0 should be 0, the value at index 1 should be 1, the value at index 2 should be 2, and so on. Then, ask the * user for a single integer input. Triple the value of each element in the * array whose value is divisible by that user input. You do not need to print out the array or anything else except for the user input prompt. You can assume that the user will input an integer when prompted.
Answer:
see explaination
Explanation:
import java.util.Scanner;
class Main
{
public static void main (String[] args)
{
int []A = new int[1000]; // Declaration of array which will store 1000 integers
for( int i = 0; i<1000; i++ )
A[i] = i; // will initialise elements of array equal to their index
System.out.print("Enter a value: ");
Scanner sc = new Scanner(System.in);
int num = sc.nextInt(); // Prompts the user to enter value
for( int i = 0; i<1000; i++ )
{
if( A[i]%num==0 ) //checks if the element is divisible by the entered value
A[i] = 3*A[i]; // Triples the value and reassigns to the same element
}
}
}
Write a program that accepts an ISBN number and displays whether it is valid or not. An ISBN (International Standard Book Number) is a ten digit code which uniquely identifies a book. The first nine digits represent Group, Publisher and Title of the book and the last digit is used as a checksum (to check whether the given ISBN is valid). Each of the digits can take any value between 0 and 9. In addition, the last digit may also take a value X (stands for 10). To verify an ISBN, calculate 10 times the first digit, plus 9 times the second digit, plus 8 times the third and so on until we add 1 time the last digit. If the number 11 can divide the sum (no remainder), the code is a valid ISBN.
Answer:
is_isbn = True
total = 0
number = input("Enter the ISBN: ")
if len(number) != 10:
is_isbn = False
for i in range(9):
if 0 <= int(number[i]) <= 9:
total += int(number[i]) * (10 - i)
else:
is_isbn = False
if number[9] != 'X' and int(number[9]) > 9:
is_isbn = False
if number[9] == 'X':
total += 10
else:
total += int(number[9])
if total % 11 != 0:
is_isbn = False
if is_isbn:
print("It is a valid ISBN")
else:
print("It is NOT a valid ISBN")
Explanation:
Initialize the variables, total and is_isbn - keeps the value for the number if it is valid or not
Ask the user for the ISBN number
If number's length is less than 10, it is not valid, set is_isbn to false
Then, make calculation to verify the ISBN
Check the last digit, if it is not "X" and greater than 10, it is not valid, set is_isbn to false
Again, check the last digit, if it is "X", add 10 to the total, otherwise add its value
Check if total can divide 11 with no remainder. If not, it is not valid, set is_isbn to false
Finally, depending on the is_isbn variable, print the result
public class Test { public static void main(String[] args) { try { method(); System.out.println("After the method call"); } catch (ArithmeticException ex) { System.out.println("ArithmeticException"); } catch (RuntimeException ex) { System.out.println("RuntimeException"); } catch (Exception e) { System.out.println("Exception"); } } static void method() throws Exception { System.out.println(1 / 0); } }
Answer:
"ArithmeticException" is the correct answer for the above question.
Explanation:
Missing Information : The above question does not hold that "what is the output of the program".
The above question has a class that holds the two functions one function is the main function which calls the other function in a try-catch block.The method function holds one run time exception which is 1/0 which is an arithmetic exception.It can be handle by the help of an arithmetic class object which is defined in the first catch block.Hence the print function of this catch is executed and prints "ArithmeticException".Write a program with functions that accepts a string as an argument and returns the number of vowels that the string contains. The application should have another function that accepts a string as an argument and return the number of consonants that the string contains. The application should let the user enter a string and should display the number of vowels and the number of consonants it contains.
Answer:
import java.util.Scanner;
public class num11 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter a word or phrase");
String word = in.nextLine();
//Calling the methods
System.out.println("Total vowels in "+word+" are "+numVowels(word));
System.out.println("Total consonants in "+word+" are "+numConsonants(word));
}
public static int numVowels(String word){
//Remove spaces and convert to lowercase
//Assume that only correct character a-z are entered
String newWord = word.toLowerCase().replaceAll(" ","");
int vowelCount = 0;
for(int i = 0; i <= newWord.length()-1; i++){
if(newWord.charAt(i)=='a'||newWord.charAt(i)=='e'||newWord.charAt(i)=='i'
||newWord.charAt(i)=='o'||newWord.charAt(i)=='u'){
vowelCount++;
}
}
return vowelCount;
}
public static int numConsonants(String word){
//Remove spaces and convert to lowercase
//Assume that only correct character a-z are entered
String newWord = word.toLowerCase().replaceAll(" ","");
int consonantCount = 0;
//Substract total vowels from the length of the word to get the consonants
consonantCount = newWord.length()-numVowels(word);
return consonantCount;
}
}
Explanation:
Create two methods vowelCount() and consonantCount() both accepts a string parameter and returns an intvowelCount() Uses a for loop to count the occurrence of the vowels (a,e,i,o,u) in the string and returns the count.consonantCount calls vowelCount and subtracts the vowelCount from the string lengthIn the main Method the user is prompted to enter a stringThe two methods are called to return the number of vowels and consonantsObserve also that it is assumed that user entered only strings containing the character a-Z. Observe also that the string is converted to all lower cases and whitespaces removed.a. Assume a computer has a physical memory organized into 64-bit words. Give the word address and offset within the word for each of the following byte addresses:
0, 9, 27, 31,120, and 256.
b. Extend the above exercise by writing a computer program that computes the answer. The program should take a series of inputs that each consist of two values: a word size specified in bits and a byte address. For each input, the program should generate a word address and offset within the word. Note: although it is specified in bits, the word size must be a power of two bytes.
Answer:
Check the explanation
Explanation:
For 9th byte , it is from 8*8 bit to 9"8th bit so each word consists of 64 bits , to find word address u have to divide 8*8 by 64.
Offset within word = 9*8modulo 64.
For 27th byte , word address = 8*27/64.
Offset within word = 27* 8 modulo 64
For 21th byte , word address = 8*31/64
Offset within the word = 31*8 modulo 64
For 120 , word address = 8*120/64
Offset within the word = 120*8 modulo 64.
Create a class CitiesAndCountries with at least three methods: class CitiesAndCountries: def add_country(self, country_name): """ :param country_name: name of new country :return: True if added, False if duplicate """ def add_city(self, country_name, city_name): """ :param country_name: must be a country in the already defined countries :param city_name: name of new city. :return: True if added, False if not added """ def find_city(self, city_name): """ :param city_name: get all cities with that name, in all different countries :return: list of countries which have a city with that name, empty list if none """
Answer:
Check the explanation
Explanation:
class CitiesAndCountries:
"""
This is the class which maintains a dictionary of the Countries with the cites in them.
"""
def __init__(self):
"""
Constructor for the class CitiesAndCountries.
It defines a dictionary to store the names of the countries and a list of the cities which are in them
Example of the the following dictionary when it is populated:
citiesandcountries = {"india":["bhopal", "mumbai", "nagpur"], "usa":["new york", "seatlle"]
Keeping the names in lowercase helps in search
"""
self.citiesandcountries = {} # This is the dictionary which stores the information
def add_country(self, country_name):
"""
The add_country function to add countries to our list.
:param country_name: Name of the country to add to the dictionary
:return: True if added to the dictionary, False if it is already present in the dictionary
"""
if country_name.lower() not in self.citiesandcountries.keys():
self.citiesandcountries[country_name.lower()] = [] # Storing the country name in lower case helps in
# searching
return True
else: # You could omit the else statement and directly return False, but it adds to readability.
return False
def add_city(self, country_name, city_name):
"""
This function adds the cities names to the dictionary corresponding to their countries.
:param country_name: Country to which the city belongs
:param city_name: Name of the city to be added
:return: True if the country is present in the dictionary and the city is added to the list, else False
"""
if country_name.lower() in self.citiesandcountries.keys():
self.citiesandcountries[country_name.lower()].append(city_name.lower())
return True
else:
return False
def find_city(self, city_name):
"""
This function is used to retrive a list of countries where the city with the given name is present
:param city_name: Name of the city.
:return: A list of all the countries where the city if present.
"""
countries_with_city = []
for country in self.citiesandcountries.keys():
if city_name.lower() in self.citiesandcountries[country]:
countries_with_city.append(country.title())
return countries_with_city
Consider a demand-paging system with the following time-measured utilizations: CPU utilization 20% Paging disk 97.7% Other I/O devices 5% For each of the following, indicate whether it will (or is likely to) improve CPU utilization. Explain your answers. a. Install a faster CPU. b. Install a bigger paging disk. c. Increase the degree of multiprogramming. d. Decrease the degree of multiprogramming. e. Install more main memory. f. Install a faster hard disk or multiple controllers with multiple hard disks. g. Add prepaging to the page-fetch algorithms. h. Increase the page size.
Answer:
see explaination please
Explanation:
a. Install a faster CPU. Answer:NO
Optional: a faster CPU reduces the CPU utilizationfurther since the CPU will spend more time waiting for a process toenter in the ready queue.
b. Install a bigger paging disk. Answer:NO
Optional: the size of the paging disk does not affect theamount of memory that is needed to reduce the pagefaults.
c. Increase the degree of multiprogramming Answer:NO
Since each process would have fewer frames available andthe page fault rate would increase
d. Decrease the degree of multiprogramming.Answer: YES
Optional: by suspending some of the processes, the otherprocesses will have more frames in order to bring their pages inthem, hence reducing the page faults.
e. Install more main memory. Answer:Likely
Optional: more pages can remain resident and do notrequire paging to or from the disks.
f. Install a faster hard disk or multiplecontrollers with multiple hard disks. Answer:Likely
(Optional)
g. Add prepaging to the page-fetchalgorithms.Answer: Likely
(Optional.)
h. Increase the page size. Answer:NO
Since each process would have fewer frames available and the page fault rate would increase
Employee Payroll Summary: PYTHON 3 CODE WITHOUT USING ARRAY AND CORRECT INDENTATION WITH ALL VARIABLES DECLARED WINDOWS
For this assignment, you will write a program that reads employee work data from a text file, and then calculates payroll information based on this file. The text file contains one line of text for each employee. Each line consists of the following data (delimited by tabs):
employee’s name
employee’s hourly wage rate
hours worked Monday
hours worked Tuesday
hours worked Wednesday
hours worked Thursday
hours worked Friday
Answer:
Check the explanation
Explanation:
If raw_input() shows some error in Python v3 then call input() instead of raw_input().
def menu():
option = 'n'
while option not in ['r','p','d','h','l','q']:
print("Menu of choices:")
print("\t(r)ead employee data")
print("\t(p)rint employee payroll")
print("\t(d)isplay an employee by name")
print("\tfind (h)ighest paid employee")
print("\tfind (l)owest paid employee")
print("\t(q)uit")
option = input("Please enter your choice: ")
if option not in ['r','p','d','h','q']:
print("Invalid choice. Please try again\n")
return option
def readEmployees(names,wages,hours):
fileRead = 0
try:
filename = input("Enter the file name: ")
f = open(filename,"r")
for line in f:
values = line.split("\t")
names.append(values[0])
wages.append(float(values[1]))
i=0
total = 0
while i < 5:
total = total + float(values[2+i])
i = i+1
hours.append(total)
fileRead = 1
f.close()
except ValueError:
print("Bad data in file " + filename)
except IOError:
print("Error reading file " + filename)
return fileRead
def printPayroll(names,wages,hours):
print("")
print("Name"+" "+"Hours"+" "+"Pay")
print("----"+" "+"-----"+" "+"---")
i = 0
sortedNames = names
sortedNames.sort()
totalpay = 0
for name in sortedNames:
i = names.index(name)
pay = hours[i] * wages[i]
name = names[i]
totalpay = totalpay + pay
name = repr(name).ljust(10)
name = name.replace("'","")
print( name + repr(hours[i]).ljust(9) + repr(pay).ljust(6))
i = i + 1
print("\nTotal payroll = $" + str(totalpay))
def displayName(names,wages,hours):
name = ""
i=0
size = len(names)
name = input("Enter the employee's name: ")
while i < size:
if names[i].lower() == name.lower():
wage = wages[i]
hour = hours[i]
break
i = i +1
if i == size:
print("Employee not found")
else:
print(name + " worked " + str(hour) + " hours at $" + str(wage) + " per hour, and earned $" + str(wage * hour) + "\n")
def showHighLow(names,wages,hours, ind):
highestIndex = 0
if ind == 'h':
i =1
size = len(names)
wage = 0;
while i < size:
wage = hours[i] * wages[i]
if wage > (hours[highestIndex] * wages[highestIndex]):
highestIndex = i
i = i + 1
print(names[highestIndex] + " earned $" + str(hours[highestIndex] * wages[highestIndex]) + "\n")
elif ind == 'l':
lowestIndex = 0;
i =1
size = len(names)
wage = 0;
while i < size:
wage = hours[i] * wages[i]
if wage < (hours[lowestIndex] * wages[lowestIndex]):
lowestIndex = i
i = i + 1
print(names[lowestIndex] + " earned $" + str(hours[lowestIndex] * wages[lowestIndex]) + "\n")
def main():
option = 'n'
names = list()
wages = list()
hours = list()
fileRead = 0
while option != 'q':
option = menu()
if option == 'r':
fileRead = readEmployees(names,wages,hours)
elif option == 'p':
if fileRead == 0:
print("Employee data has not been read.")
print("Please read the file before making this choice")
else:
printPayroll(names,wages,hours)
elif option == 'd':
if fileRead == 0:
print("Employee data has not been read.")
print("Please read the file before making this choice")
else:
displayName(names,wages,hours)
elif option == 'h':
if fileRead == 0:
print("Employee data has not been read.")
print("Please read the file before making this choice")
else:
showHighLow(names,wages,hours,'h')
elif option == 'l':
if fileRead == 0:
print("Employee data has not been read.")
print("Please read the file before making this choice")
else:
showHighLow(names,wages,hours,'l')
elif option == 'q':
print("GoodBye")
if __name__ == "__main__":
main()
Kindly check the OUTPUT in the attached image below.
1. An integer in C (int) is represented by 4 bytes (1 byte = 8 bits). Find the largest integer that can be handled by C. Verify that number by computer (try to printf that number, and printf that number +1). No programming is required for this. Hint: (a) Conversion from binary to decimal: 3 2 1 0 2 1101 =1 2 + 0 2 +1 2 +1 2 = 8 + 0 + 2 +1 10 =11 (b) If an integer is represented by 1 byte (8 bits), the maximum integer number is 1111111 (Seven 1's as one bit must be reserved for a sign). 6 5 0 2 1111111 =1 2 +1 2 ++1 2 1 2 1 7 = − =128 −1 (c) The number looks like a telephone number in Dallas.
Answer:
Check the explanation
Explanation:
In C, int requires 4 butes to sotre a integer number. that means it requires 4*8 = 32 bits. The maximum number can be stored using 32 bits is
[tex](11111111111111111111111111111111)_2[/tex]
The first digit is used for sign. decimal equivalent to this number can be computed as
[tex](1111111111111111111111111111111)_2= 1\times2^{30}+1\times2^{29}+...+1\times2^0[/tex]
=[tex]1\times2^{31}-1[/tex]
= [tex]2147483647-1=2147483646[/tex]
That means int can store a up to 2147483646.
Testing with C code
#include<stdio.h>
int main()
{
int a = 2147483647; // a with max number
printf("%d\n",a);// printing max number
a = a+1;// adding one to the number
printf("%d\n",a);// printing the number after adding one
return 0;
}
THE OUTPUT
$ ./a.out
2147483647
-2147483648
The largest integer that can be represented by an int in C is 2,147,483,647. Adding 1 to this maximum value leads to an integer overflow, resulting in the smallest possible integer that can be handled in C, which is -2,147,483,648.
Explanation:In C, an integer (int) is typically represented using 4 bytes, or 32 bits. However, one bit is reserved for indicating the sign of the integer (positive or negative), leaving 31 bits for the numerical value. In binary notation, the maximum number that can be represented with 31 bits all set to 1 is 231-1. By direct calculation, this is 2,147,483,647. Therefore, the largest integer that can be represented by an int in C is 2,147,483,647.
When you try to add 1 to this maximum value (e.g., printf the number 2,147,483,647 + 1), the result will not be as expected because it leads to an integer overflow. Instead, it would give you the smallest possible integer that can be handled in C, which is -2,147,483,648.
Learn more about C Programming here:https://brainly.com/question/34799304
#SPJ3
A technician needs to be prepared to launch programs even when utility windows or the Windows desktop cannot load. What is the program name for the System Information utility?
Answer:
Windows includes a tool called Microsoft System Information (Msinfo32.exe). This tool gathers information about your computer and displays a comprehensive view of your hardware, system components, and software environment, which you can use to diagnose computer issues.
Explanation:
Write a CREATE TABLE statement for the DEPARTMENT table. Save and Run this statement. 2. Write a CREATE TABLE statement for the EMPLOYEE table including constraints. Email is required and is an alternate key Cascade updates but not deletions from DEPARTMENT to EMPLOYEE. Save and Run this statement. 3. Write a CREATE TABLE statement for PROJECT table. - Cascade updates but not deletions from DEPARTMENT to PROJECT
Answer:
Check the explanation
Explanation:
Please find the sql statements (as numbered in the question) below:
1. DEPARTMENT TABLE
CREATE TABLE DEPARTMENT (
DepartmentName varchar (50),
BudgetCode varchar (50),
OfficeNumber varchar (50),
OfficeNumber varchar (50),
Phone varchar (50)
);
2. EMPLOYEE TABLE
CREATE TABLE EMPLOYEE (
EmployeeNumber varchar (50),
FirstName varchar (50),
LastName varchar (50),
Phone varchar (50),
Email varchar (50) NOT NULL UNIQUE,
DepartmentName varchar (50) FOREIGN KEY REFERENCES DEPARTMENT(DepartmentName) ON UPDATE CASCADE
);
3. PROJECT TABLE
CREATE TABLE PROJECT (
ProjectID varchar (50),
Name varchar (50),
MaxHours FLOAT,
Date() AS StartDate,
Date() AS EndDate,
DepartmentName varchar (50) FOREIGN KEY REFERENCES DEPARTMENT(DepartmentName) ON UPDATE CASCADE
);
Hex value 0xC29C3480 represents an IEEE-754 single-precision (32 bit) floating-point number. Work out the equivalent decimal number. Show all workings (e.g. converting exponent and mantissa).
Answer:
According to IEEE-754 standard,equivalent decimal of 32 bit floating point number is 78.1025390625
Explanation:
To convert the 32 bit floating point number from hexadecimal to decimal, following steps will be completed.
1. Convert this hexadecimal value "C29C3480" into binary number. Each digit in hexadecimal will convert into 4 bits of binary.
There
C= 1100
2 = 0010
9 = 1001
C = 1100
3 = 0011
4= 0100
8 = 1000
0 = 0000
So the number will be converted as given below:
1100 0010 1001 1100 0011 0100 1000 0000
2. Arrange the bits in order
1 = Sign bit = 32nd bit
10000101 = Exponent bits = From 31st to 23rd bits
00111000011010010000000 = Fraction bits= From 22nd to 0th bit
As the 32nd bit, which is sign bit, is 1, so given number is negative.
3. Convert the Exponent bits into decimal values
10000101 = 1x2⁷+0x2⁶+0x2⁵+0x2⁴+0x2³+1x2²+0x2¹+1x2⁰
= 1x2⁷ + 1x2² + 1x2⁰
= 128 + 4 + 1 = 133
4. Calculate Exponent Bias
exponent bias = 2ⁿ⁻¹ - 1
there n is total number of bits in exponent value of 32 bit number, Now in this question n=8, because there are total 8 bits in exponent.
so, exponent bias = 2⁸⁻¹ - 1 = 2⁷-1= 128-1= 127
e = decimal value of exponent - exponent bias
e = 133 - 127 = 6
5. Convert Fraction part into Decimal
Mantissa=0x2⁻¹+0x2⁻²+1x2⁻³+1x2⁻⁴+1x2⁻⁵+0x2⁻⁶+0x2⁻⁷+0x2⁻⁸+0x2⁻⁹+1x2⁻¹⁰+1x2⁻¹¹+0x2⁻¹²+1x2⁻¹³+0x2⁻¹⁴+0x2⁻¹⁵+1x2⁻¹⁶+0x2⁻¹⁷+0x2⁻¹⁸+0x2⁻¹⁹+0x2⁻²⁰+0x2⁻²¹+0x2⁻²²+0x2⁻²³
= 1x2⁻³+1x2⁻⁴+1x2⁻⁵+1x2⁻¹⁰+1x2⁻¹¹+1x2⁻¹³+1x2⁻¹⁶
= 0.125 + 0.0625 + 0.03125 + 0.0009765625 + 0.00048828125 + 0.00012207031 + 0.00001525878
Mantissa = 0.22035217284
6. Convert the number into decimal
Decimal number = (-1)^s x (1+Mantissa) x 2^e
there
s is the sign bit which is 1,
and
e =6.
so,
decimal number = (-1)^1 x (1+0.22035217284 ) x 2⁶
= -1 x 1.22035217284 x 64
= -78.1025390625
Write a program that calculates the balance of a savings account at the end of a period of time. It should ask the user for the annual interest rate, the starting balance, and the number of months that have passed since the account was established. A loop should then iterate once for every month, performing the following: A) Ask the user for the amount deposited into the account during the month. (Do not accept negative numbers.) This amount should be added to the balance. B) Ask the user for the amount withdrawn from the account during the month. (Do not accept negative numbers.) This amount should be subtracted from the balance. C) Calculate the monthly interest. The monthly interest rate is the annual interest rate divided by twelve. Multiply the monthly interest rate by the balance, and add the result to the balance. After the last iteration, the program should display the ending balance, the total amount of deposits, the total amount of withdrawals, and the total interest earned.
Answer:
Check the explanation
Explanation:
# include <iostream>
#include<iomanip>
using namespace std;
int main ()
{double start,balance,rate,deposit=0,withdraw=0,amt,sum,totInterest=0,interest;
int i;
cout<<setprecision(2)<<fixed;
cout<<"Enter starting balance: ";
cin>>balance;
start=balance;
cout<<"Enter annual interest rate: ";
cin>>rate;
rate/=12.;
for(i=1;i<=3;i++)
{cout<<"For month "<<i<<endl;
sum=balance;
cout<<"Enter total amount deposit: ";
cin>>amt;
while(amt<0)
{cout<<"Must not be negative-retry\n";
cout<<"Enter total amount deposit: ";
cin>>amt;
}
deposit+=amt;
balance+=amt;
cout<<"Enter total amount withdrawn: ";
cin>>amt;
while(amt<0||amt>balance)
{cout<<"Must not be negative, or greater than balance ($"<<balance<<")-retry\n";
cout<<"Enter total amount withdrawn: ";
cin>>amt;
}
withdraw+=amt;
balance-=amt;
interest=(sum+balance)/2.*rate;
totInterest+=interest;
balance+=interest;
}
cout<<"Starting balance at the beginning of the three month period: $"<<start<<endl;
cout<<"total deposits made during the three months: $"<<deposit<<endl;
cout<<"total withdrawals made during the three months: $"<<withdraw<<endl;
cout<<"total interest posted to the account during the three months $"<<totInterest<<endl;
cout<<"final balance: $"<<balance<<endl;
system("pause");
return 0;
}
Kindly check the output in the attached image below.
The major objective of this lab is to practice class and object-oriented programming (OOP), and separate files: 1. We will reuse lab 6, a direct current simulator with extensions to let you practice OOP. Pay special attention to the difference between procedural programming and OOP. 2. This is the first time you break a program into several files such that you do not need to have all functions included in one program. The idea of breaking a program into several files has many benefits that will be explained in lecture notes and ZyBook reading assignment. It is NOT the purpose of this lab to train your logical thinking capability. We select a simple problem to help you fully understand OOP and separate files in an efficient manner.
Answer:
Implementation of resistor.cpp
#include "resistor.h"
Ohms::Ohm()
{
// default constructor
voltage=0;
}
Ohms::Ohm( double x) // parameterised constructor
{
voltage = x; // voltage x set to the supply voltage in the private data field called voltage
}
Ohms:: setVoltage(double a)
{
voltage = a;// to set supply voltage in private data field called voltage
}
Ohms::setOneResistance( String s, double p)
{
cin>>p; //enter the resistance value
if(p<=0) // if resistance is less than or equals to 0
return false
else // if re
cin.getline(s);
}
Ohms::getVoltage()
{
return voltage; //return voltage of ckt
}
Ohms::getCurrent()
{
return current; //return current of ckt
}
Ohms:: getNode()
{
return resistors; //return resistors of ckt
}
Ohms::sumResist()
{
double tot_resist = accumulate(resistors.begin(),resistors.end(),0); //std::accumulate function for calculating sum //of vectors and following are the starting and ending points
return tot_resist;
}
Ohms::calcCurrent()
{
if(current <=0) // if current is less than or equal to 0
return false;
else // if current is greater than 0
return true;
}
Ohms:: calcVoltageAcross()
{
if(voltage<=0) // if voltage is less than or equal to 0
return false;
else //if voltage greater than 0
return true;
}
Explanation:
in the case of main.cpp its simple just make a class object and remember to include resistors.cpp with it for which the second last picture describes the process precisely. (Hint: Use theunit test case functions in the main.cpp).
As you can see node is a structure consisting of member variables, followed by a class Ohms representing a DC circuit.
By looking at these pictures, it is needed to implement the main.cpp and resistor.cpp files. The user defined header file resistor.h already consists of all contents of Class Ohm, struct node. You don't need to modify it in anyway in such case.
Consider a one-way authentication technique based on asymmetric encryption: A --> B: IDA B --> A: R1 A --> B: E(PRa, R1) Explain the protocol. What type of attack is this protocol susceptible to?
Answer:
See explaination
Explanation:
A protocol in computing can be defined as a standard set of rules that allow electronic devices to communicate with each other. These rules include what type of data may be transmitted, what commands are used to send and receive data, and how data transfers are confirmed. You can think of a protocol as a spoken language.
Please kindly check attachment for for the details of the answer.
Here, A-->B : ID means protocol is issued authentic A to B.
Then B--> A : R1 here, R1 take care about only A can encrypt R1 ensure that only A can take authentication challenge.Last A--> B : E (PRa, R1) here, A's public key is take care to decrypt.(b). According to the question it is based on asymmetric key encryption technique, Let us assume any third-party K could use the given below assumption:
Let us suppose A sign a message, and this message, K show to any other party D.so, in this case if A used public or private key for authentication and signature.Then, in this case attacks occurrence chance is happen, so man middle attack will be happen.Learn more about:
https://brainly.com/question/17495888
Obtain a file name from the user, which will contain data pertaining to a 2D array Create a file for each of the following: averages.txt : contains the overall average of the entire array, then the average of each row reverse.txt : contains the original values but each row is reversed flipped.txt : contains the original values but is flipped top to bottom (first row is now the last row etc.) If the dimensions of array are symmetric (NxN), create a diagonal.txt: contains the array mirrored on the diagonal
Answer:
see explaination
Explanation:
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
string filename, file1, file2, file3, file4;
cout << "Enter the filename : ";
getline(cin, filename);
int row, col;
ifstream ifile;
ifile.open(filename.c_str());
if(!ifile)
{
cout << "File does not exist." << endl;
}
else
{
ifile >> row >> col;
float mat[row][col], diag[row][col];
for(int i=0; i<row; i++)
{
for(int j=0; j<col; j++)
ifile >> mat[i][j];
}
cout << "Enter the filename to save averages : ";
getline(cin, file1);
ofstream avgFile(file1.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
float t_avg = 0, avg = 0;
for(int i=0; i<row; i++)
{
avg = 0;
for(int j=0; j<col; j++)
{
avg += mat[i][j];
}
t_avg += avg;
avg = avg/col;
avgFile << std::fixed << std::setprecision(1) << "Row " << i+1 << " average: " << avg << endl;
}
t_avg = t_avg / (row*col);
avgFile << std::fixed << std::setprecision(1) << "Total average: " << t_avg << endl;
cout << "Enter the filename to store reverse matrix : ";
getline(cin, file2);
ofstream revFile(file2.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
for(int i=0; i<row; i++)
{
for(int j=col-1; j>=0; j--)
{
revFile << std::fixed << std::setprecision(1) << mat[i][j] << " ";
}
revFile << endl;
}
cout << "Enter the filename to store flipped matrix : ";
getline(cin, file3);
ofstream flipFile(file3.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
for(int i=row-1; i>=0; i--)
{
for(int j=0; j<col; j++)
{
flipFile << std::fixed << std::setprecision(1) << mat[i][j] << " ";
}
flipFile << endl;
}
cout << "Enter the filename to store diagonal matrix : ";
getline(cin, file4);
ofstream diagFile(file4.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
for(int i=0; i<row; i++)
{
for(int j=0; j<col; j++)
{
diag[j][i] = mat[i][j];
}
}
for(int i=0; i<col; i++)
{
for(int j=0; j<row; j++)
{
diagFile << std::fixed << std::setprecision(1) << diag[i][j] << " ";
}
diagFile << endl;
}
}
return 0;
}
For the following two transactions and the initial table values as shown complete the missing blanks in the transaction log below:
Part_ID
Desrption
OnHand
OnOrder
57
Assembled Foo
5
0
987
Foo Fastener
12
7
989
Foo Half
7
0
BEGIN TRANSACTION;
UPDATE Part SET OnHand = OnHand + 7, OnOrder = OnOrder – 7 WHERE Part_ID = 987;
COMMIT;
BEGIN TRANSACTION;
UPDATE Part SET OnHand = OnHand - 4 WHERE Part_ID = 987;
UPDATE Part SET OnHand = OnHand - 2 WHERE Part_ID = 989;
UPDATE Part SET OnHand = OnHand + 1 WHERE Part_ID = 57;
COMMIT
TRL_ID
TRX_ID
PREV_PTR
NEXT_PTR
OPERATION
TABLE
ROW ID
ATTRIBUTE
BEFORE VALUE
AFTER VALUE
1787
109
NULL
START
****
1788
109
1787
UPDATE
PART
987
OnHand
12
1789
109
UPDATE
PART
987
OnOrder
7
1790
109
NULL
COMMIT
****
1791
110
NULL
START
****
Final answer:
The provided transaction log represents updates made to the 'Part' table in a database, recording the details of each transaction and the changes made to specific rows.
Explanation:
The transaction log provided represents a series of updates made to the 'Part' table in a database. Each transaction is recorded with a unique 'TRL_ID' and 'TRX_ID'. The 'OPERATION' column indicates the type of operation performed (e.g., START, UPDATE, COMMIT). The 'TABLE' column specifies the table that was updated, and the 'ROW ID' column represents the specific row that was modified. The 'BEFORE VALUE' and 'AFTER VALUE' columns show the original and final values of the updated attribute.
Suppose that the data mining task is to cluster points (with (x, y) representing location) into three clusters, where the points are A1(4, 8), A2(2, 4), A3(1, 7), B1(5, 4), B2(5, 7), B3(6, 6), C1(3, 7), C2(7, 8). The distance function is Euclidean distance. Suppose initially we assign A1, B1, and C1as the center of each cluster, respectively. Please use the k-means algorithmand show your R code.(a)the three cluster centers after the first round of execution. (b)the final points in the three clusters after the algorithm stops.
Answer:
Explanation:
K- is the working procedure:
It takes n no. of predefined cluster as input and data points.
It also randomly initiate n centers of the clusters.
In this case the initial centers are given.
Steps you can follow
Step 1. Find distance of each data points from each centers.
Step 2. Assign each data point to the cluster with whose center is nearest to this data point.
Step 3. After assigning all data points calculate center of the cluster by taking mean of data points in cluster.
repeat above steps until the center in previous iteration and next iteration become same.
A1(4,8), A2(2, 4), A3(1, 7), B1(5, 4), B2(5,7), B3(6, 6), C1(3, 7), C2(7,8)
Centers are X1=A1, X2=B1, X3=C1
A1 will be assigned to cluster1, B1 will be assigned to cluster2 ,C1 will be assigned to cluster3.
Go through the attachment for the solution.
The k-means algorithm is used to cluster data points into partitions based on their attributes, using the Euclidean distance function. After the first round of execution, the cluster centers are A1(4, 8), B1(5, 4), and C1(3, 7). The final points in the three clusters after the algorithm stops may include A1(4, 8), A2(2, 4), A3(1, 7), B1(5, 4), B2(5, 7), B3(6, 6), C1(3, 7), and C2(7, 8).
Explanation:The k-means algorithm is used to cluster data points into partitions based on their attributes. In this case, we are clustering points in a two-dimensional space (x, y) into three clusters using the Euclidean distance function. The k-means algorithm involves initializing the cluster centers, iteratively recalculating the centroids, and reassigning the data points to the new centroids. The algorithm continues until convergence or a certain number of iterations.
(a) After the first round of execution, the three cluster centers are A1(4, 8), B1(5, 4), and C1(3, 7).
(b) The final points in the three clusters after the algorithm stops might be A1(4, 8), A2(2, 4), A3(1, 7) in one cluster, B1(5, 4), B2(5, 7), B3(6, 6) in another cluster, and C1(3, 7), C2(7, 8) in the third cluster. The exact assignment of points to clusters may vary depending on the distance calculations and convergence criteria used in the algorithm.
10 10 105 Each process is assigned a numerical priority, with a higher number indicating a higher relative priority. In addition to the process listed above, the system also has an idle task (which consumes no CPU resources and is identified as P idle). This task has priority 0 and is scheduled whenever the system has no other available processes to run. The length of a time quantum is 10 units. If a process is preempted by a higher-priority process, the preempted process is placed at the end of the queue. (Hint: Draw a Gantt chart.) (a) What is the turnaround time for each process? (25 pts) (b) What is the waiting time for each process? (25 pts)
Answer:
see explaination and attachment
Explanation:
We can say that a Gantt chart is a visual view of tasks scheduled over time. Gantt charts are used for planning projects of all sizes and they are a useful way of showing what work is scheduled to be done on a specific day.
see attachment for the detailed step by step solution.
You created several workbooks (Accounting, Finance, Management, and Marketing) in the same folder as the main workbook SchoolOfBusiness. What formula correctly links to cell D20 in the Fall 2018 worksheet within the Finance workbook?
Answer:
='[Finance.xlsx]Fall2018'!$D$20
Explanation:
The formula that will correctly links to cell D20 in the Fall 2018 worksheet within the Finance workbook is given as:
='[Finance.xlsx]Fall2018'!$D$20
This will perform the operation and produce the required output.
Privacy laws in other countries are an important concern when performing cloud forensics and investigations. You've been assigned a case involving PII data stored on a cloud in Australia. Before you start any data acquisition from this cloud, you need to research what you can access under Australian law. For this project, look for information on Australia's Privacy Principles (APP), particularly Chapter 8: APP 8 – Cross-border disclosure of personal information. Write a 2 to 3 page paper (not including title and reference pages) using APA format summarizing disclosure requirements for getting consent from data owners, and any exceptions allowed by this law. Writing Requirements
Answer:
See the explanation for the answer.
Explanation:
Australian regulations makes extremely difficult for the enterprises to move organizations sensitive data to the cloud which is storing outside the Australian network. These are all managed by the Office of Australian Information Commissioner(OAIC) which provides oversight on the data privacy regulations designed to govern the dissemination of the sensitive information.
One rule they applied under this is The Australian National Privacy Act 1988 which tells how the organizations collect, use, secure, store the information. The National Privacy Principles in the Act tells how organizations should use the people's personal information. The NPP has a rule that An organization must take the responsibility to hold the information without misuse or modified by unauthorized access. They require enterprises to put security service level agreements with the cloud service providers that define audit rights, data location, access rights when there is cross border disclosure of information.
In later time they introduced a new principle called The Privacy Amendment Act 2012. This principle gives set of new rules along with the changes in the many rules in the previous act and also this is having a set of new principles those are called Australian Privacy Principles (APP).
In this there is principle for cross border disclosure of personal information which is APP8. This rule regulates the disclosure or transfer of personal information by an agency or company to a different location outside the country.
Before disclosure the information outside they have to take responsible steps that the company outside the Australia must not breach the APP 's.
Given a collection of n nuts, and a collection of n bolts, each arranged in an increasing order of size, give an O(n) time algorithm to check if there is a nut and a bolt that have the same size. You can assume that the sizes of the nuts and bolts are stored in the arrays NUTS[1::n] and BOLTS[1::n], respectively, where NUTS[1] < < NUTS[n] and BOLTS[1] < < BOLTS[n]. Note that you only need to report whether or not a match exists; you do not need to report all matches.
To check for a matching pair of nuts and bolts in O(n) time, perform a linear scan using two indices since the arrays are sorted. Increment the indices appropriately and return true if a match is found before either index exceeds n, otherwise return false.
To solve the problem of finding if there is a matching pair of nuts and bolts in an O(n) time complexity, you can employ a simple linear scan. Since the arrays NUTS and BOLTS are both sorted in increasing order, you can iterate over them simultaneously to check for a match.
Algorithm:
Initialize two indices, i and j, to 1.While i and j are both less than or equal to n, compare NUTS[i] with BOLTS[j]:If NUTS[i] is equal to BOLTS[j], a match is found, and you can return true.If NUTS[i] is less than BOLTS[j], increment i to check the next nut.If BOLTS[j] is less than NUTS[i], increment j to check the next bolt.If no match is found by the time either i or j exceeds n, return false as no matching pair exists.This algorithm is guaranteed to run in O(n) since each list is traversed at most once.