Answer:
3 Segments,
First segment : seq = 43, ack=80
Second Segment : seq = 80, ack=44
Third Segment: seq = 44, ack=81
Explanation:
Three segments will be sent as soon as the user types the letter ‘C’ and the he waits for a few seconds to type the letter ‘R’.
In our Telnet example, 42 and 79 for the client and server were the starting sequence number. Since the letter 'R' is typed and the starting seq is 42 is incremented by 1 byte. Therefore the sequence number in the first segment is 43 and the acknowlegement number is 80.
The second segment is sent from the server to the client. It echoes back the letter ‘C’. 43 is put in the acknowledgment field and tells the client that it has successfully received everything up through byte 42 and is now waiting for bytes 43 onward. This second segment has the sequence number 79 which is incremented by 1 byte. Therefore the sequence number in the second segment is 80 and the acknowlegement number is 44.
The third segment is sent from the client to the server. Its acknowledges the data it has received from the server. It has 80 in the acknowledgment number field because the client has received the stream of bytes up through byte sequence number 79 and it is now waiting for bytes 80 onward. This is also incremented by 1 byte. Therefore the sequence number in the second segment is 44 and the acknowlegement number is 81.
Final answer:
In a Telnet session, each keystroke is sent as a separate segment. Therefore, typing 'R' after 'C' sends one segment with a sequence number incremented by one from the previous, and an acknowledgment number also increased by one to acknowledge receipt of the previously received segment.
Explanation:
When the user types the letter 'R' after typing 'C' in a Telnet session, generally a single segment is sent for each keystroke because Telnet operates in character mode. In this mode of operation, every character generates a pair of segments: one from the client to the server (the telnet command) and one from the server to the client (the acknowledgment).
The sequence number in the segment sent after typing 'R' would be incremented by one compared to the previous segment's sequence number because each character sent is considered one byte of data. Similarly, the acknowledgment number would be set to one more than the last received segment's sequence number, acknowledging the successful receipt of that segment.
If we assume the initial sequence number is 'X' for the first segment carrying the 'C' and the server acknowledges with 'Y', then for the 'R' segment, the sequence number would be 'X+1' and the acknowledgment field would have 'Y+1' if no other data was sent or received in the interim.
Write a program that takes as input an arithmetic expression followed by a semicolon ";". The program outputs whether the expression contains matching grouping symbols. For example, the arithmetic expressions {25 + (3 – 6) * 8} and 7 + 8 * 2 contains matching grouping symbols. However, the expression 5 + {(13 + 7) / 8 - 2 * 9 does not contain matching grouping symbols. If the expression contains matching grouping symbols, the program output should contain the following text: Expression has matching grouping symbol If the expression does not contain matching grouping symbols, the program output should contain the following text:
Answer:
See explaination for the details of the answer.
Explanation:
#include <iostream>
#include <stack>
using namespace std;
int main(){
string str;
cout<<"Enter a String: ";
std::getline (std::cin,str);
bool flag=true;
stack<char> st;
for(int i=0;i<str.size();i++){
if( (str.at(i)>='0' && str.at(i)<='9') || str.at(i)=='+' || str.at(i)=='-' || str.at(i)=='/'|| str.at(i)=='*' || str.at(i)==' ' ){
// cout<<str.at(i) <<"came"<<endl;
continue;
}
if( str.at(i)=='{' || str.at(i)=='(' ){
st.push(str.at(i));
}
else if(!st.empty() &&((st.top() == '{' && str.at(i) == '}') || (st.top() == '(' && str.at(i) == ')')))
st.pop();
else{
flag=false;
break;
}
}
if(!st.empty()){
cout<<"Does not match"<<"\n";
}else{
if(flag)
cout<<"Match"<<"\n";
else
cout<<"Does not match"<<"\n";
}
return 0;
}
See attachment for the output.
Answer the following Python Interview questions • How is Python an interpreted language? • What is the difference between Python Arrays, lists, tuples, and records? Explain it with examples • What does [::-1] do? Explain it with an example • How can you randomize the items of a list in place in Python? • What is the difference between range & xrange?Explain it with an example • What advantages do NumPy arrays offer over (nested) Python lists? • How to add values to a python array? Explain it with an example • What is split used for? Explain it with an example
Answer:
1. Python is called as interpreted language. However as a programming language it is not fully compiled nor interpreted language. Python program runs from direct source code which makes it byte code interpreted.
An Interpreter is the one which takes the code and performs the actions specified in the code. It turns the code into intermediate language which is again translated to machine language understood by the processor. Interpreted or compiled are the property of the implementation and not of the language.
2. Array : It is a collection of same data type elements stored at contagious memory location. It is handled in python with module array. All the elements of array must be of same data type. In order to manipulate same data types arrays are used.
Ex: array1 = a.array ('i', [10, 20, 30]) this is a array of integer type.
Lists : Python lists are ordered data structure and are like non homogeneous dynamic sized arrays. It may contain integers, strings, boolean, or objects.
Ex: List1 = [70, 89, 98] , List2 = ["Rose", "Lilly", "Jasmine"]
List3 = [1, 10, 100, 'Test', 'Test1']
Tuple : It is a collection of objects separated by commas and they are immutable. It is static which makes them faster.
Ex: tupule1 = ('element1', 'element2')
List and Tuple in Python are the class of data structure. The list is dynamic, whereas tuple has static characteristics.
Lists are mutable but tuples are not.
tuples are mainly used to access the elements where as lists are used in operations like insertion and deletion.
Iterations are time consuming in list where as it is faster in tuples.
tuples don't have inbuilt methods but list has many builtin methods.
tuples takes slightly less memory that lists in Python
Records: Records data structure will have fixed number of fields and each field may have a name and different type. Immutable records are implemented using named tuple.
3. Syntax of slice in python is list[<start>:<stop>:<step>] and it can be used on tuples and lists.
so X [::-1] means that it will start from the end towards the first element by taking each of the elements.
for ex: X = '9876'
X [::-1] will result in '6789'.
Means it will reverse all the elements in the array.
4. Items of list can be shuffled with the random.shuffle() function of a random module.
Syntax is : random.shuffle(x, random)
x- It is a sequence to shuffle and can be list or tuple.
random- it is a optional argument which returns random float number between 0.1 to 1.0.
5. range() – Range function returns a range object which is a type of iterable object.
xrange() – xrange function returns the generator object that can be used to display numbers only by looping. Only particular range is displayed on demand and hence called “lazy evaluation“.
• Return type of range () is range object whereas that of xrange() is xrange object.
• Variable to store the range using range () takes more memory but xrange takes comparative less memory.
• Range returns the list but xrange returns the xrange object. Hence operations on list can be applied for range but not on xrange.
• Xrange is faster to implement than range as xrange evaluates only generator objects.
• Xrange is depreciated in Python 3 and above.
For ex :
x = range (10, 100)
y= xrange (10, 100)
#To know the return type we can print it
print ( return type of range () is : “)
print (type (x))
print ( return type of xrange () is : “)
print (type (y))
Output will be list and xrange respectively.
6. NumPy's arrays are more compact than Python lists
reading and writing items is also faster with NumPy.
Memory taken by python lists are way higher than NumPy arrays.
Python lists don’t support vectorized operation.
Since lists can contain objects of different types its type information must be stored and executed every time operation is performed on it.
Memory taken by python lists are a lot higher than that of NumPy Arrays.
Reading and writing of elements in NumPy arrays are faster than lists.
NumPy arrays are compact and accumulate lesser storage.
Numpy is convenient and efficient.
For ex :
Metrics operations are easy in NumPy.
Checkerboard pattern can be done using NumPy.
7. Attached as Image
8. split() method returns a list of strings after breaking the given string by the specified separator. It is splitting of string into list with each word is a list item.
Syntax : str.split ( separator, maxsplit)
Separator : its is delimiter used and by default whitespace is used as separator.
Maxsplit : Maximum number of times to split the string. By default it has no limit.
For ex:
text = 'apples and oranges are different '
print(text.split())
output will be : ['apples', 'and', 'oranges', 'are', 'different' ]
Explanation:
Answer:
It Is C to shorten it The answer is C
Explanation:
Please construct a program that reads the content from the file numbers.txt. There are two lines in the file, each is an integer number. Print out the two numbers and their sum in an equation as below: Content in numbers.txt: 45 28 Output of the program: 45 28
Answer:
file = open("numbers.txt")
numbers = []
for line in file:
numbers.append(int(line))
print("The numbers in the file: " + str(numbers[0]) + " " + str(numbers[1]))
print("The sum of the numbers: " + str(numbers[0] + numbers[1]))
Explanation:
The code is in Python.
Open the file named numbers.txt
Create an empty list, numbers, to hold the numbers in the file
Create a for loop that iterates through file and adds the number inside the file to the list
Print numbers
Calculate and print the sum of the numbers
Final answer:
To read two integers from a file and print their sum, use a Python script to open the file, convert the strings to integers, calculate the sum, and print the results with the equation format.
Explanation:
To construct a program that reads the content from the file numbers.txt and prints out the two numbers along with their sum, you would need to use a programming language. Below is an example of how you might write such a program in Python:
with open('numbers.txt', 'r') as file:
numbers = file.read().splitlines()
num1 = int(numbers[0])
num2 = int(numbers[1])
sum_of_numbers = num1 + num2
print(f"{num1} + {num2} = {sum_of_numbers}")
This program opens the file numbers.txt, reads its content line by line, converts the lines to integers, and then calculates their sum. Finally, it prints out the numbers and the sum in the format specified. It is assumed that numbers.txt contains one number per line and that these can be converted directly to integers.
Using the world_x database you installed in Module 1, list the countries and the capitals of each country. Modify your query to limit the list to those countries where less than 30% of the population speaks English. Be sure to identify the literary sources you used to look up any SQL syntax you used to formulate your query. Submit your query and query results Word file.
Answer:
SELECT country.Name, city.Name
FROM country
JOIN countrylanguage ON country.Code = countrylanguage.CountryCode
JOIN city ON country.Capital = city.ID
WHERE countrylanguage.Language = 'English'
AND countrylanguage.Percentage < 30;
Explanation:
SELECT is used to query the database and get back the specified fields.
City.Name is an attribute of city table.
country.Name is an attribute of country table.
FROM is used to query the database and get back the preferred information by specifying the table name.
country , countrylanguage and city are the table names.
country and countrylanguage are joined based ON country.Code = countrylanguage.CountryCode
countrylanguage and city are joined based ON country.Capital = city.ID
WHERE is used to specify a condition based on which the data is to be retrieved. The conditions are as follows:
countrylanguage.Language = 'English'
countrylanguage.Percentage < 30;
Write a program to simulate the design process of the course. First, create a struct for the course which consists of following members: course number (int type, e.g. 1200), course start date (int type, e.g. 20200107), course hours (int type, how many hours per week) and lecturer ID (int type). Second, create a struct for lecturer, which has following members: lecturer ID (int type), lecturer office hours (int type, how many office hours per week) and course teaching(array[int] type). Third, create a struct for student, which as following members: student ID (int type), course taken (array[int type). Then answer following questions 1, 2 and 3 based on these structures: 1. The department decide to offer three courses in a semester: 1000, 1100 and 1200. Please create these courses with structs you defined above. Their information is given below: Course number Course start date Course hours Lecturer ID 1000 20200107 2 100 1100 20200113 4 200 1200 20200203 4 100 2. Department also assigned two lecturers to teach these courses. Please create documents for lecturers and print out the information for both lectures on the screen. Note: Each lecturer will be assigned 2 hours office hours for each course he/she teaches. 3. A student, whose ID is 2000, are considering taking 2 courses among above courses. Please print out how many course hours he/she needs to take each week. Note, simply add up the course hours from table in question 1 will not be considered as correct answer. Your program should first ask this student to input the course number he/she registered, then print the total course hours. 4. Conduct an experiment with Arduino using an Angle Rotary Sensor and a Servo (connect sensors to Arduino appropriately). The Angle Rotary Sensor must control the movement of the Servo. In other words, when you change the angle of the Rotary Angle Sensor (0 to 300 degrees), the Servo will rotate the short white blade accordingly after mapping the Angle Rotary Sensor value (0 to 300 to a Servo position (0 to 180). Also, display the angle degree of the Angle Rotary Sensor and the position of the Servo on the Serial Monitor window. Use Serial.print function to print on the Serial Monitor window, which can be open by clicking on the icon- on the upper right area of the Arduino window. Also, you need to use the following statement in the setup function: Serial.begin(9600);
Answer:
#include <iostream>
using namespace std;
struct Course
{
int courseNumber;
int courseStartDate;
int courseHours;
int lecturerId;
};
struct Lecturer
{
int lecturerId;
int officeHours;
Course courseTeaching[2];
};
struct Student
{
int studentId;
Course coursesTaken[2];
};
int main()
{
Course courseObj1, courseObj2, courseObj3;
courseObj1.courseNumber = 1000;
courseObj1.courseStartDate = 20200107;
courseObj1.courseHours = 2;
courseObj1.lecturerId = 100;
courseObj2.courseNumber = 1100;
courseObj2.courseStartDate = 20200113;
courseObj2.courseHours = 4;
courseObj2.lecturerId = 200;
courseObj3.courseNumber = 1200;
courseObj3.courseStartDate = 20200203;
courseObj3.courseHours = 4;
courseObj3.lecturerId = 100;
Lecturer lecturerObj1, lecturerObj2;
lecturerObj1.lecturerId = 100;
lecturerObj1.officeHours = 2;
lecturerObj1.courseTeaching[0] = courseObj1;
lecturerObj1.courseTeaching[1] = courseObj3;
lecturerObj2.lecturerId = 200;
lecturerObj2.officeHours = 2;
lecturerObj2.courseTeaching[0] = courseObj2;
Student student;
student.studentId = 2000;
student.coursesTaken[0] = courseObj1;
student.coursesTaken[1] = courseObj3;
cout << "1. Lecturer ID: " << lecturerObj1.lecturerId << "\tOffice Hours: " << lecturerObj1.officeHours << endl;
for(int i = 0; i < 2; i++)
cout << "COURSE " << (i + 1) << ":\n---------\n" << "Course Number: " << lecturerObj1.courseTeaching[i].courseNumber << endl << "Course start date: " << lecturerObj1.courseTeaching[i].courseStartDate << endl << "Course hours: " << lecturerObj1.courseTeaching[i].courseHours << endl << "Lecturer ID: " << lecturerObj1.courseTeaching[i].lecturerId << endl;
cout << "\n2. Lecturer ID: " << lecturerObj2.lecturerId << "\tOffice Hours: " << lecturerObj2.officeHours << endl;
for(int i = 0; i < 1; i++)
cout << "COURSE " << (i + 1) << ":\n---------\n" << "Course Number: " << lecturerObj2.courseTeaching[i].courseNumber << endl << "Course start date: " << lecturerObj2.courseTeaching[i].courseStartDate << endl << "Course hours: " << lecturerObj2.courseTeaching[i].courseHours << endl << "Lecturer ID: " << lecturerObj2.courseTeaching[i].lecturerId << endl;
int courseNumber;
cout << "\n Enter the course number: ";
cin >> courseNumber;
int index = -1;
int len = sizeof(student.coursesTaken) / sizeof(student.coursesTaken[0]);
int totalHours = 0;
for(int i = 0; i < len; i++)
{
if(student.coursesTaken[i].courseNumber == courseNumber)
{
totalHours += student.coursesTaken[i].courseHours;
}
}
if(totalHours == 0)
cout << "\n Student is not registered to this course!\n";
else
cout << "\nStudent " << student.studentId << " needs " << totalHours << " hours per week of this course.\n";
return 0;
}
Explanation:
Create the 3 objects of Course class and set their properties respectively.Create the 2 objects of Lecturer class and set their properties respectively.Create an object of Student class and set their properties respectively.Run a for loop and check whether the current courseNumber is already added and then increment the total number of hours for that course.Finally check if totalHours is equal to 0 or not and then display the suitable message accordingly.Given the following SQL Query, which columns would you recommend to be indexed? SELECT InvoiceNumber, InvoiceDate, Invoice_Total, Invoice_Paid, Invoice_Total - Invoice_Paid as Balance FROM Invoice WHERE Invoice_Date >= "2015-07-20" and Salesman_Id = "JR" ORDER BY DESC Invoice_Total Drag the correct answers to one of the three pockets.
Answer:
Invoice_Date and Salesman Id
Explanation:
As the WHERE clause looking at the Invoice_Date and Salesman Id columns so they should be indexed for the following reasons.
Uniquely identifiable records are guaranteed by the unique indexes in the database.Data can be quickly retrieved.The usage of indexes results in much better performance.It can help with quick presorted list of records.Write the pseudocode for the following: A function called fahrenheitToCelsius that accepts a Real Fahrenheit temperature, performs the conversion, and returns the Real Celsius temperature. A function called celsiusToFahrenheit that accepts a Real Celsius temperature, performs the conversion, and returns the Real Fahrenheit temperature. A main module that asks user to enter a Fahrenheit temperature, calls the fahrenheitToCelsius function, and displays the Celsius temperature with a user-friendly message. It then asks the user to enter a Celsius temperature, calls the celsiusToFahrenheit function, and displays the Fahrenheit temperature with a user-friendly message.
Final answer:
The pseudocode provided defines two functions, fahrenheitToCelsius and celsiusToFahrenheit, which perform temperature conversions between Fahrenheit and Celsius, and a main module for user interaction to perform and display the conversions.
Explanation:
Here is the pseudocode for two temperature conversion functions and a main module to interact with the user.
Function: fahrenheitToCelsius
Input: Real fahrenheitTemperature
Output: Real celsiusTemperature
Begin
Set celsiusTemperature to (fahrenheitTemperature - 32) * (5.0 / 9.0)
Return celsiusTemperature
End
Function: celsiusToFahrenheit
Input: Real celsiusTemperature
Output: Real fahrenheitTemperature
Begin
Set fahrenheitTemperature to (celsiusTemperature * (9.0 / 5.0)) + 32
Return fahrenheitTemperature
End
Main Module
Begin
Display "Enter a Fahrenheit temperature: "
Input fahrenheitTemperature
Set celsiusTemperature to fahrenheitToCelsius(fahrenheitTemperature)
Display "The equivalent Celsius temperature is: " + celsiusTemperature
Display "Enter a Celsius temperature: "
Input celsiusTemperature
Set fahrenheitTemperature to celsiusToFahrenheit(celsiusTemperature)
Display "The equivalent Fahrenheit temperature is: " + fahrenheitTemperature
End
SOLVE IN C:
"Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequence. Create a for loop that compares the two strings starting from index 0. For each match, add one point to userScore. Upon a mismatch, exit the loop using a break statement. Assume simonPattern and userPattern are always the same length. Ex: The following patterns yield a userScore of 4:simonPattern: RRGBRYYBGYuserPattern: RRGBBRYBGYplease use comments to explain each step!! #include #include int main(void) { char simonPattern[50]; char userPattern[50]; int userScore; int i; userScore = 0; scanf("%s", simonPattern); scanf("%s", userPattern);**YOUR ANSWER GOES HERE** printf("userScore: %d\n", userScore); return 0;}
Answer:
#include <stdio.h>
#include <string.h>
int main(void) {
char simonPattern[50];
char userPattern[50];
int userScore;
int i;
userScore = 0;
scanf("%s", simonPattern);
scanf("%s", userPattern);
for(i = 0;simonPattern[i]!='\0';i++){
if(simonPattern[i]!=userPattern[i]){
userScore=i;
break;
}
}
printf("userScore: %d\n", userScore);
return 0;
}
Explanation:
Use a for loop that runs until it does not reach the end of simonPattern.Check whether the current index of simonPattern and userPattern are not equal and then assign the value of i variable to the userScore variable and break out of the loop.Finally display the user score.Create a class that holds data about a job applicant. Include a name, a phone number, and four Boolean fields that represent whether the applicant is skilled in each of the following areas: word processing, spreadsheets, databases, and graphics. Include a constructor that accepts values for each of the fields. Also include a get method for each field. Create an application that instantiates several job applicant objects and pass each in turn to a Boolean method that determines whether each applicant is qualified for an interview. Then, in the main() method, display an appropriate method for each applicant. A qualified applicant has at least three of the four skills. Save the files as JobApplicant.java and TestJobApplicants.java.
Answer:
Explanation:
I don't know about the answer in java.
This is what I did in C#. Find attached the answer
public class JobApplication
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private string phoneNumber;
public string PhoneNumber
{
get { return phoneNumber; }
set { phoneNumber = value; }
}
private bool isSKilledInWordProcessing;
public bool IsSkilledInWordProcessing
{
get { return isSKilledInWordProcessing; }
set { isSKilledInWordProcessing = value; }
}
private bool isSkilledInSpreadsheets;
public bool IsSkilledInSpreadsheets
{
get { return isSkilledInSpreadsheets; }
set { isSkilledInSpreadsheets = value; }
}
private bool isSkilledInDatabases;
public bool IsSkilledInDatabases
{
get { return isSkilledInDatabases; }
set { isSkilledInDatabases = value; }
}
private bool isSkilledInGraphics;
public bool IsSkilledInGraphics
{
get { return isSkilledInGraphics; }
set { isSkilledInGraphics = value; }
}
public JobApplication(string name, string phoneNumber, bool isSKilledInWordProcessing,
bool isSkilledInSpreadsheets, bool isSkilledInDatabases, bool IsSkilledInGraphics)
{
Name = name;
PhoneNumber = phoneNumber;
IsSkilledInDatabases = isSkilledInDatabases;
IsSkilledInGraphics = isSkilledInGraphics;
IsSkilledInWordProcessing = IsSkilledInWordProcessing;
IsSkilledInSpreadsheets = isSkilledInSpreadsheets;
}
}
class Program
{
static void Main(string[] args)
{
JobApplication jobApplication1 = new JobApplication("Emmanuel Man", "+39399399", false, true, true, true);
CheckIfQualified(jobApplication1);
}
static void CheckIfQualified(JobApplication jobApplication)
{
if(jobApplication.IsSkilledInSpreadsheets && jobApplication.IsSkilledInGraphics
&& jobApplication.IsSkilledInWordProcessing && jobApplication.IsSkilledInDatabases)
{
Console.WriteLine("The applicant, " + jobApplication.Name + " is qualified for the job");
} else if (jobApplication.IsSkilledInSpreadsheets && jobApplication.IsSkilledInGraphics
&& jobApplication.IsSkilledInWordProcessing)
{
Console.WriteLine("The applicant, " + jobApplication.Name + " is qualified for the job");
}
else if (jobApplication.IsSkilledInSpreadsheets && jobApplication.IsSkilledInGraphics
&& jobApplication.IsSkilledInDatabases)
{
Console.WriteLine("The applicant, " + jobApplication.Name + " is qualified for the job");
} else if (jobApplication.IsSkilledInWordProcessing && jobApplication.IsSkilledInGraphics
&& jobApplication.IsSkilledInDatabases)
{
Console.WriteLine("The applicant, " + jobApplication.Name + " is qualified for the job");
}else if (jobApplication.IsSkilledInWordProcessing && jobApplication.IsSkilledInSpreadsheets
&& jobApplication.IsSkilledInDatabases)
{
Console.WriteLine("The applicant, " + jobApplication.Name + " is qualified for the job");
}
else
{
Console.WriteLine("The applicant, " + jobApplication.Name + " is not qualified for the job");
}
}
}
Answer:
import java.util.Scanner;
public class TestJobApplicant{
public static void main(String[] args)
{
JobApplicant applicant1 = new JobApplicant("Ted","555-1234", true, false, false, false);
JobApplicant applicant2 = new JobApplicant("Lily", "655-1235", true, false, true, false);
JobApplicant applicant3 = new JobApplicant("Marshall", "755-1236", false, false, false, false);
JobApplicant applicant4 = new JobApplicant("Barney", "855-1237", true, true, true, false);
JobApplicant applicant5 = new JobApplicant("Robin", "955-1238", true, true, true, true);
String qualifiedMessage = "is qualified for an interview. ";
String notQualifiedMessage = "is not qualified for an interview at this time. ";
if (isQualified(applicant5))
display(applicant5, qualifiedMessage);
else
display(applicant5, notQualifiedMessage);
}
public static boolean isQualified(JobApplicant applicant) {
int count = 0;
boolean isQualified;
final int MIN_SKILLS = 3;
if(applicant.getWord())
count += 1;
if(applicant.getSpreadsheet())
count += 1;
if(applicant.getDatabase())
count += 1;
if(applicant.getGraphics())
count += 1;
if(count >= MIN_SKILLS)
isQualified = true;
else
isQualified = false;
return isQualified;
}
public static void display(JobApplicant applicant, String message) {
System.out.println(applicant.getName() + " " + message +" Phone: " + applicant.getPhone());
}
}
class JobApplicant {
private String name, phone;
private boolean word, spreadsheet, database, graphics;
public JobApplicant(String name, String phone, boolean word, boolean spreadsheet, boolean database, boolean graphics){
this.name = name;
this.phone = phone;
this.word = word;
this.spreadsheet = spreadsheet;
this.database = database;
this.graphics = graphics;
}
public String getName() {return name;}
public String getPhone() {return phone;}
public boolean getWord() {return word;}
public boolean getSpreadsheet() {return spreadsheet;}
public boolean getDatabase() {return database;}
public boolean getGraphics() {return graphics;}
}
Explanation:
Inside the JobApplicant class:
- Declare the variables
- Initialize the constructor
- Create the get methods for each variable
Inside the TestJobApplicant class:
- Create an isQualified method that checks if given applicant is qualified for the job.
- Create a display method that prints the name, message and phone number for the applicant
Inside the main:
- Initialize the applicant objects and messages
- Call the isQualified method with an applicant to see the result
What is the output of the following C++ program?
#include
#include
using namespace std;
class baseClass
{
public:
void print() const;
baseClass(string s = " ", int a = 0);
//Postcondition: str = s; x = a;
protected:
int x;
private:
string str;
};
class derivedClass: public baseClass
{
public:
void print() const;
derivedClass(string s = "", int a = 0, int b = 0);
//Postcondition: str = s; x = a; y = b;
private:
int y;
};
int main()
{
baseClass baseObject("This is the base class", 2);
derivedClass derivedObject("DDDDDD", 3, 7);
baseObject.print();
derivedObject.print();
system("pause");
return 0;
}
void baseClass::print() const
{
cout << x << " " << str << endl;
}
baseClass::baseClass(string s, int a)
{
str = s;
x = a;
}
void derivedClass::print() const
{
cout << "Derived class: " << y << endl;
baseClass::print();
}
derivedClass::derivedClass(string s, int a, int b) :
baseClass("Hello Base", a + b)
{
y = b;
}
Answer:
0 This is base class
Derived class: 9
16 Hello Base
Explanation:
The header files #include <iostream> #include <string> was wrongly included in the question this had to be edited.
After properly editing the programme to remove errors, the expected output when you run the code is:
0 This is base class
Derived class: 9
16 Hello Base
Final answer:
The C++ program demonstrates class inheritance and method overriding. The output for the baseClass object is "2 This is the base class", and for the derivedClass object is "Derived class: 7" followed by "10 Hello Base".
Explanation:
The provided C++ program defines two classes, baseClass and derivedClass, which demonstrate basic inheritance and method overriding. The main() function creates instances of these classes and calls their print() methods. The output of this program is determined by the details of the print methods.
When baseObject.print() is called, it triggers baseClass::print(), outputting the value of x and str for the base object, which are initialized in the baseClass constructor. The output would be "2 This is the base class".
Calling derivedObject.print() triggers derivedClass::print(), which first outputs the phrase "Derived class: " and the value of y from the derivedClass object, followed by the properties of the base class part of the same object, as per the constructor which passed "Hello Base", a (x in the base class), and the sum a + b. The resulting output would be "Derived class: 7" followed by "10 Hello Base" on a new line.
Modify an array's elements Write a for loop that iterates from 1 to numberSamples to double any element's value in dataSamples that is less than minValue. Ex: If minVal = 10, then dataSamples = [2, 12, 9, 20] becomes [4, 12, 18, 20]. Function Save Reset MATLAB DocumentationOpens in new tab function dataSamples = AdjustMinValue(numberSamples, userSamples, minValue) % numberSamples: Number of data samples in array dataSamples % dataSamples : User defined array % minValue : Minimum value of any element in array % Write a for loop that iterates from 1 to numberSamples to double any element's % value in dataSamples that is less than minValue dataSamples = userSamples; end 1 2 3 4 5 6 7 8 9 10 Code to call your function
Answer:
See explaination for program code
Explanation:
%save as AdjustMinValue.m
%Matlab function that takes three arguments
%called number of samples count, user samples
%and min vlaue and then returns a data samples
%that contains values which are double of usersamples
%that less than min vlaue
%
function dataSamples=AdjustMinValue(numberSamples, userSamples, minValue)
dataSamples=userSamples;
%for loop
for i=1:numberSamples
%checking if dataSamples value at index,i
%is less than minValue
if dataSamples(i)<minValue
%set double of dataSamples value
dataSamples(i)= 2*dataSamples(i);
end
end
end
Sample output:
Note:
File name and calling method name must be same
--> AdjustMinValue(4, [2,12,9,20],10)
ans =
4 12 18 20
Write a program that converts a temperature from Celsius to Fahrenheit. It should (1) prompt the user for input, (2) read a double value from the keyboard, (3) calculate the result, and (4) format the output to one decimal place. For example, it should display "24.0 C = 75.2 F". Here is the formula. Be careful not to use integer division! F = C × 9 5 + 32
Answer:
celsius = float(input("Enter the celcius value: "))
f = 1.8 * celsius + 32
print(str(celsius) + " C = "+ str(f) + " F")
Explanation:
The code is in Python.
Ask the user for the input, celsius value
Convert the celsius value to fahrenheit using the given formula
Print the result as in shown in the example output
Answer:
See explaination
Explanation:
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
double tempF, tempC;
cout<<"Enter a degree in Celsius: ";
cin>>tempC;
tempF = tempC*(9/5.0)+32;
cout<<setprecision(1)<<fixed;
cout<<tempC<<" C = "<<tempF<<" F"<<endl;
return 0;
}
Write a program that asks the user to enter two dates (in YYYY-MM-DD format), and then prints which date is earlier. Your program should print an error message if the user enters an invalid date (like 2019-15-99).
Answer:
import java.util.*;
public class Dates {
public static void main(String[] args) {
String January,February, March, April, May, June, July,
August, September,October, November, December, month;
January = February = March = April = May = June = July =
August = September = October = November = December = month = null;
Scanner myScanner = new Scanner(System.in);
System.out.print("Enter date in the format mm/dd/yyyy: ");
String input = myScanner.next();
String months = input.substring(0,1);
int monthInt = Integer.parseInt(months);
if (monthInt == 01){
month = January;
}
else if (monthInt == 02){
month = February;
}
else if (monthInt == 03){
month = March;
}
else if (monthInt == 04){
month = April;
}
else if (monthInt == 05){
month = May;
}
else if (monthInt == 06){
month = June;
8.17 Lab: Strings of a Frequency Write a program that reads whitespace delimited strings (words) and an integer (freq). Then, the program outputs the strings from words that have a frequency equal to freq in a case insensitive manner.
The program reads whitespace-delimited strings and an integer frequency, then outputs strings with the specified frequency in a case-insensitive manner using a frequency counting approach.
In this programming task, the goal is to create a program that reads whitespace-delimited strings and an integer frequency (freq). The program should then output the strings from the input that have a frequency equal to the specified freq in a case-insensitive manner.
To achieve this, the program needs to:
1. Read input: Use an input mechanism to read whitespace-delimited strings and the integer frequency.
2. Count frequency: Maintain a data structure, such as a dictionary or a hashmap, to store the frequency of each string. While reading the input strings, update the frequency count accordingly.
3. Filter strings: Iterate through the stored strings and output only those with a frequency equal to the specified freq. Ensure case-insensitivity by converting all strings to lowercase during comparison.
Here's a Python example:
```python
def find_strings_with_frequency(words, freq):
word_count = {}
# Count the frequency of each word
for word in words:
word_lower = word.lower()
word_count[word_lower] = word_count.get(word_lower, 0) + 1
# Output strings with the specified frequency
result = [word for word, count in word_count.items() if count == freq]
return result
# Example usage
input_words = input("Enter whitespace-delimited strings: ").split()
input_freq = int(input("Enter frequency: "))
output_strings = find_strings_with_frequency(input_words, input_freq)
print("Strings with frequency {}: {}".format(input_freq, output_strings))
```
This program takes user input for whitespace-delimited strings and an integer frequency, processes the input, and outputs strings with the specified frequency in a case-insensitive manner.
What output will be produced by the following code?
public class SelectionStatements { public static void main(String[] args)
{ int number = 25; if(number % 2 == 0)
System.out.print("The condition evaluated to true!");
else
System.out.print("The condition evaluated to false!"); } }
Answer:
The condition evaluated to false!
Explanation:
lets attach line numbers to the given code snippet
public class SelectionStatements { public static void main(String[] args) { int number = 25; if(number % 2 == 0) System.out.print("The condition evaluated to true!"); else System.out.print("The condition evaluated to false!"); } }In Line 3: An integer number is declared and assigned the value 25Line 4 uses the modulo operator (%) to check if the number (25) is evenly divided by 2. This however is not true, so line 5 is not executedThe else statement on line 6- 7 gets executedJAVA PROGRAMMING
Arrays are useful to process lists.
A top-level domain (TLD) name is the last part of an Internet domain name like .com in example.com. A core generic top-level domain (core gTLD) is a TLD that is either .com, .net, .org, or .info. A restricted top-level domain is a TLD that is either .biz, .name, or .pro. A second-level domain is a single name that precedes a TLD as in apple in apple.com.
The following program repeatedly prompts for a domain name, and indicates whether that domain name consists of a second-level domain followed by a core gTLD. Valid core gTLD's are stored in an array. For this program, a valid domain name must contain only one period, such as apple.com, but not support.apple.com. The program ends when the user presses just the Enter key in response to a prompt.
1-Run the program and enter domain names to validate.
2-Extend the program to also recognize restricted TLDs using an array, and statements to validate against that array. The program should also report whether the TLD is a core gTLD or a restricted gTLD. Run the program again.
import java.util.Scanner;
public class GtldValidation {
public static void main (String [ ] args) {
Scanner scnr = new Scanner(System.in);
// Define the list of valid core gTLDs
String [ ] validCoreGtld = { ".com", ".net", ".org", ".info" };
// FIXME: Define an array named validRestrictedGtld that has the names
// of the restricted domains, .biz, .name, and .pro
String inputName = "";
String searchName = "";
String theGtld = "";
boolean isValidDomainName = false;
boolean isCoreGtld = false;
boolean isRestrictedGtld = false;
int periodCounter = 0;
int periodPosition = 0;
int i = 0;
System.out.println("\nEnter the next domain name ( to exit): ");
inputName = scnr.nextLine();
while (inputName.length() > 0) {
searchName = inputName.toLowerCase();
isValidDomainName = false;
isCoreGtld = false;
isRestrictedGtld = false;
// Count the number of periods in the domain name
periodCounter = 0;
for (i = 0; i < searchName.length(); ++i) {
if (searchName.charAt(i) == '.') {
++periodCounter;
periodPosition = i;
}
}
// If there is exactly one period that is not at the start
// or end of searchName, check if the TLD is a core gTLD or a restricted gTLD
if ((periodCounter == 1) &&
(searchName.charAt(0) != '.') &&
(searchName.charAt(searchName.length() - 1) != '.')) {
isValidDomainName = true;
}
if (isValidDomainName) {
// Extract the Top-level Domain name starting at the period's position. Ex:
// If searchName = "example.com", the next statement extracts ".com"
theGtld = searchName.substring(periodPosition);
i = 0;
while ((i < validCoreGtld.length) && (!isCoreGtld)) {
if(theGtld.equals(validCoreGtld[i])) {
isCoreGtld = true;
}
else {
++i;
}
}
// FIXME: Check to see if the gTLD is not a core gTLD. If it is not,
// check to see whether the gTLD is a valid restricted gTLD.
// If it is, set isRestrictedGtld to true
}
System.out.print("\"" + inputName + "\" ");
if (isValidDomainName) {
System.out.print("is a valid domain name and ");
if (isCoreGtld) {
System.out.println("has a core gTLD of \"" + theGtld + "\".");
}
else if (isRestrictedGtld) {
System.out.println("has a restricted gTLD of \"" + theGtld + "\".");
}
else {
System.out.println("does not have a core gTLD."); // FIXME update message
}
}
else {
System.out.println("is not a valid domain name.");
}
System.out.println("\nEnter the next domain name ( to exit): ");
inputName = scnr.nextLine();
}
return;
}
}
Answer:
See explaination
Explanation:
import java.util.Scanner;
public class GtldValidation {
public static void main (String [ ] args) {
Scanner scnr = new Scanner(System.in);
// Define the list of valid core gTLDs
String [ ] validCoreGtld = { ".com", ".net", ".org", ".info" };
// FIXME: Define an array named validRestrictedGtld that has the names
// of the restricted domains, .biz, .name, and .pro
String [] validRestrictedGtld={".biz",".name",".pro"};
String inputName = "";
String searchName = "";
String theGtld = "";
boolean isValidDomainName = false;
boolean isCoreGtld = false;
boolean isRestrictedGtld = false;
int periodCounter = 0;
int periodPosition = 0;
int i = 0;
System.out.println("\nEnter the next domain name (<Enter> to exit): ");
inputName = scnr.nextLine();
while (inputName.length() > 0) {
searchName = inputName.toLowerCase();
isValidDomainName = false;
isCoreGtld = false;
isRestrictedGtld = false;
// Count the number of periods in the domain name
periodCounter = 0;
for (i = 0; i < searchName.length(); ++i) {
if (searchName.charAt(i) == '.') {
++periodCounter;
periodPosition = i;
}
}
// If there is exactly one period that is not at the start
// or end of searchName, check if the TLD is a core gTLD or a restricted gTLD
if ((periodCounter == 1) &&
(searchName.charAt(0) != '.') &&
(searchName.charAt(searchName.length() - 1) != '.')) {
isValidDomainName = true;
}
if (isValidDomainName) {
// Extract the Top-level Domain name starting at the period's position. Ex:
// If searchName = "example.com", the next statement extracts ".com"
theGtld = searchName.substring(periodPosition);
i = 0;
while ((i < validCoreGtld.length) && (!isCoreGtld)) {
if(theGtld.equals(validCoreGtld[i])) {
isCoreGtld = true;
}
else {
++i;
}
}
// FIXME: Check to see if the gTLD is not a core gTLD. If it is not,
// check to see whether the gTLD is a valid restricted gTLD.
// If it is, set isRestrictedGtld to true
}
System.out.print("\"" + inputName + "\" ");
if (isValidDomainName) {
System.out.print("is a valid domain name and ");
if (isCoreGtld) {
System.out.println("has a core gTLD of \"" + theGtld + "\".");
}
else if (isRestrictedGtld) {
System.out.println("has a restricted gTLD of \"" + theGtld + "\".");
}
else {
System.out.println("does not have a core gTLD."); // FIXME update message
}
}
else {
System.out.println("is not a valid domain name.");
}
System.out.println("\nEnter the next domain name (<Enter> to exit): ");
inputName = scnr.nextLine();
}
return;
}
}
Write a function that takes an integer, val, as an argument. The function asks the user to enter a number. If the number is greater than val, the function displays Too high. and returns 1; if the number is less than val, the function displays Too low. and returns –1; if the number equals val, the function displays Got it! and returns 0. Call the function repeatedly until the user enters the right number.
Answer:
import java.util.*;
public class num2 {
public static void main(String[] args) {
//Set the Value of the argument
int val = 5;
//Call the method
int returnedNum = testInteger(val);
//Use a While to continously call the method as long as the returned value is not 0
while(returnedNum != 0){
int rt = testInteger(val);
//Break out of loop when the user enters correct value and the return is 0
if(rt == 0){
break;
}
}
}
//The Method definition
public static int testInteger(int val){
//Prompt and receive user input
System.out.println("Enter a number");
Scanner in = new Scanner(System.in);
int userNum = in.nextInt();
//Check different values using if and else statements
if(userNum > val){
System.out.println("Too High");
return 1;
}
else if(userNum < val){
System.out.println("Too Low");
return -1;
}
else{
System.out.println("Got it");
return 0;
}
}
}
Explanation:
This is solved with Java Programing Language
Pay close attention to the comments provided in the code
The logic is using a while loop to countinually prompt the user to enter a new number as long as the number entered by the user is not equal to the value of the argument already set to 5.
Answer:
def high_low(val):
number = int(input("Enter a number: "))
if number > val:
print("Too high")
return 1
elif number < val:
print("Too low")
return -1
elif number == val:
print("Got it!")
return 0
val = 7
while True:
if high_low(val) == 0:
break
Explanation:
The code is in Python.
Create a function called high_low that takes one parameter, var
Ask the user for a number. Check the number. If the number is greater than 1, smaller than 1 or equal to 1. Depending on the number, print the required output and return the value.
Set the value to a number. Create a while loop iterates until the user enters the correct number, when the return value of the function is equal to 0, that means the user entered the correct number. Otherwise, it keeps asking the number and prints the appropriate message.
Define a JavaScript function named showGrades which does not have any parameters. Your function should create and return an array containing 3 Numbers. The values for each of these entries should be: get the value from the div whose id is "GradeA" and store it at index 0 of your array; get the value from the div whose id is "Passing" and store it at index 1 of your array; and get the value from the div whose id is "Learning" and store it at index 2 of your array. Your must then encode the array as a JSON blob and return that JSON blob.
Answer:
see explaination
Explanation:
//selective dev elements by id name
var gradeA = document.querySelector("#GradeA");
var passing = document.querySelector("#Passing");
var learning = document.querySelector("#Learning");
//function showGrades
function showGrades() {
var arr = [];
//converting string to int and inserting into array
arr[0] = parseInt(gradeA.textContent);
arr[1] = parseInt(passing.textContent);
arr[2] = parseInt(learning.textContent);
//creating json blob
var blob = new Blob(new Array(arr), {type:"text/json"});
return blob;
}
List 3 specific uses for an Excel spreadsheet in the field you are going into. Give specific examples of how you could or have used Excel in the field. Choose examples that you are familiar with, remembering that personal stories always makes a post more interesting
Answer:
The answer to this question can be defined as below:
Explanation:
The three uses of the spreadsheet can be described as follows:
In Business:
All organizations use Excel, which uses daily by Microsoft Excel, as a key feature of the Microsoft Office company Desktop Suite. Spreadsheets preparation manuals contain worksheets for documents and tablets.In Auditing:
It is a function, that be can provide you with several methods for inspecting by constructing 'short cuts' obstacles. Multiple functions have been helpful, and that you have reduced returns with the time it takes for something to be hung up.In nursing:
All related to figures should be available in a list. Health staff may very well use them to calculate their patients, profits and costs. You should keep a list of clients and medication. They may have to keep hospital-based, clients are at the healing facility on weekends, subtle features of hours employed by medical staff and various items.Suppose that you sort a large array of integers by using a merge sort. Next you use a binary search to determine whether a given integer occurs in the array. Finally, you display all of the integers in the sorted array. a. Which algorithm is faster, in general: the merge sort or the binary search? Explain in terms of Big O notation. b. Which algorithm is faster, in general: the binary search or displaying the integers? Explain in terms of Big O notation.
Answer:
See explaination
Explanation:
Merge sort working-
1.type of recursive sorting algorithm.
2.divides given array into halves.
3. Sort each halves. Merge this halves to give a sorted array.
4. Recursive call continues till array is divided and each piece has only one element.
5. Merge this small pieces to get a sorted array.
Binary search-
1. It is a search algorithm.
2. Requires a sorted array to work on.
3.Works repetively dividing a half portion of list that could contain item until it has narrowed down the possible location to just one.
Comparing Merge sort and Binary Search using Big O notation-
Merge Sort - O(n*log(n)) in all scenario whether best, average or worst case.
Binary Search- O(log(n)) in average and worst case. O(1) in best case.
So seeing the above comparison Binary search is faster.
Comparing Binary search and displaying the integers-
Binary Search- O(log(n)) in average and worst case. O(1) in best case.
Displaying the integer-O(1) if already initialized, O(n) in case of loop or function.
So seeing above one can conclude that binary search is fast. But in best case both works in a similar manner.
Consider a set of mobile computing clients in a certain town who each
need to be connected to one of several possible base stations. We’ll
suppose there are n clients, with the position of each client specified
by its (x, y) coordinates in the plane. There are also k base stations; the
position of each of these is specified by (x, y) coordinates as well.
For each client, we wish to connect it to exactly one of the base
stations. Our choice of connections is constrained in the following ways.
There is a range parameter r—a client can only be connected to a base
station that is within distance r. There is also a load parameter L—no
more than L clients can be connected to any single base station.
Your goal is to design a polynomial-time algorithm for the following
problem. Given the positions of a set of clients and a set of base stations,
as well as the range and load parameters, decide whether every client can
be connected simultaneously to a base station, subject to the range and
load conditions in the previous paragraph
Answer: answer given in the explanation
Explanation:
We have n clients and k-base stations, say each client has to be connected to a base station that is located at a distance say 'r'. now the base stations doesn't have allocation for more than L clients.
To begin, let us produce a network which consists of edges and vertex
Network (N) = (V,E)
where V = [S, cl-l, - - - - cl-n, bs-l - - - - - - bs-k, t]
given that cl-l, - - - - - cl-n represents nodes for the clients
also we have that bs-l, - - - - - bs-k represents the nodes for base station
Also
E = [ (s, cl-i), (cl-i,bs-j), (bs-j,t)]
(s, cl-i) = have capacity for all cl-i (clients)
(cl-i,bs-j) = have capacity for all cl-i clients & bs-j (stations)
⇒ using Fond Fulkorson algorithm we find the max flow in N
⇒ connecting cl-i clients to bs-j stations
like (cl-i, bs-j) = 1
if f(cl-i, bs-j) = 0
⇒ say any connection were to produce a valid flow, then
if cl-i (clients) connected f(s,cl-i) = 1 (o otherwise)
if cl-i (clients) connected to bs-j(stations) f(cl-i,bs-j) = 1 (o otherwise)
f(bs-j,t) = no of clients (cl-i) connected to bs-j
⇒ on each node, the max flow value (f) is longer than the no of clients that can be connected.
⇒ create the connection between the client and base station i.e. cl-l to base bs-j iff f(cl-i, bs-j) = 1
⇒ when considering the capacity, we see that any client cannot directly connect to the base stations, and also the base stations cannot handle more than L clients, that is because the load allocated to the base statsion is L.
from this, we say f is the max no of clients (cl-i) that can be connected if we find the max flow, we can thus connect the client to the base stations easily.
cheers i hope this helps
What is the purpose of a Program Epic?
Answer:
An Epic is a container for a Solution development initiative large enough to require analysis, the definition of a Minimum Viable Product (MVP), and financial approval prior to implementation. Implementation occurs over multiple Program Increments (PIs) and follows the Lean startup 'build-measure-learn' cycle.
Explanation:
Hope this is what your looking for
The purpose of a Program Epic is to represent business capabilities that address various user needs.
What is Program Epic ?
An Epic is a holder for a Solution improvement drive sufficiently enormous to require examination, the meaning of a Minimum Viable Product (MVP), and monetary endorsement preceding execution. Execution happens over numerous Program Increments (PIs) and follows the Lean startup 'assemble measure-learn' cycle.
A program epic obliged to a solitary delivery train, conveyed by different groups, and crossing numerous PI emphases. Program Epics can address business abilities that address different client needs. Include: Functionality that meets explicit partner needs.
Thus, the purpose is explained.
Learn more about Program Epic
https://brainly.com/question/15450565
#SPJ2
numbers that the user inputs. You must use JoptionPane to input the three numbers. A first method must be called and used to develop logic to find the smallest of the three numbers. A second method must be used to print out that smallest number found.
Input the three numbers. A first method must be called and used to develop logic to find the smallest of the three numbers. A second method must be used to print out that smallest number found.
Explanation:
Input of 3 numbers.Then the numbers are checked to print the smallest one.import java.util.Scanner;
public class Exercise1 {
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Input the first number: ");
double x = in.nextDouble();
System.out.print("Input the Second number: ");
double y = in.nextDouble();
System.out.print("Input the third number: ");
double z = in.nextDouble();
System.out.print("The smallest value is " + smallest(x, y, z)+"\n" );
}
public static double smallest(double x, double y, double z)
{
return Math.min(Math.min(x, y), z);
}
}
Differences between the Services in career paths leading up to a joint assignment may surprise new staff Service members in joint assignments. This demonstrates which key element to remember when working with other services?
Answer:
Prior Experience Working with Senior Officers versus Little or None.
Explanation:
Differences and disparities between the Services in career paths leading up to a joint assignment may surprise new staff officers in joint assignments.
For example, Army and Air Force officers will likely come to a joint assignment with prior junior officer experience as an administrative “exec” to a senior officer at the O-5 and above level.
In contrast, Navy, Marine Corps and Coast Guard officers will have had no such experience unless selected for one of the highly competitive Flag Aide or Aide-de-Camp billets to an O-7 or above who rates such an aide.
Having an experience working with senior officers and when a person has little or none shows the key element to remember when working with other services.
What is the aim of joint operations?The act of working together in a joint project helps to provide some amount of guidance for the use of authority.
Note that having a previous experience in working with senior officers and when a person has little or none can be obviously shown when working with other services.
Learn more about Career from
https://brainly.com/question/9719007
Open IDLE. Create a new script file (File-->New File, Ctrl n on Windows, Cmd n on macOS). On the first line, place your name in a comment. Create a program that does the following: Requests an integer number from the user This number will determine the number of rows that will be displayed Print out a header row Displays the current row number, that number multiplied by ten, then multiplied by 100, then multiplied by 1000, in tabular format Repeat this until the required number of rows have been displayed This program must account for the user having stated zero (0) rows should be displayed Your output should resemble the following: Python Output 5
Answer:
program:
#your name
print("{:10} {:10} {:10}".format("Number","Square","Cube"))
print("{:<10} {:<10} {:<10}".format(0,0,0))
print("{:<10} {:<10} {:<10}".format(1,1,1))
print("{:<10} {:<10} {:<10}".format(2,2**2,2**3))
print("{:<10} {:<10} {:<10}".format(3,3**2,3**3))
print("{:<10} {:<10} {:<10}".format(4,4**2,4**3))
print("{:<10} {:<10} {:<10}".format(5,5**2,5**3))
print("{:<10} {:<10} {:<10}".format(6,6**2,6**3))
print("{:<10} {:<10} {:<10}".format(7,7**2,7**3))
print("{:<10} {:<10} {:<10}".format(8,8**2,8**3))
print("{:<10} {:<10} {:<10}".format(9,9**2,9**3))
print("{:<10} {:<10} {:<10}".format(10,10**2,10**3))
output:
Number Square Cube
0 0 0
1 1 1
2 4 8
3 9 27
4 16 64
5 25 125
6 36 216
7 49 343
8 64 512
9 81 729
10 100 1000
An array of String objects, words, has been properly declared and initialized. Each element of words contains a String consisting of lowercase letters (a–z). Write a code segment that uses an enhanced for loop to print all elements of words that end with "ing".
As an example, if words contains {"ten", "fading", "post", "card", "thunder", "hinge", "trailing", "batting"}, then the following output should be produced by the code segment.
fading trailing batting
Write the code segment as described above. The code segment must use an enhanced for loop.
Answer:
Explanation:
#include <iostream>
using namespace std;
int main()
{
string cwords[8]={"ten", "fading", "post", "card", "thunder", "hinge", "trailing", "batting"};
string temp="";
for (int i=0; i<8; i++)
{
temp=cwords[i];
int j=temp.length();
if (temp[j-3]=='i' && temp[j-2]=='n' && temp[j-1]=='g')
{
cout<<temp<<endl;
}
}
return 0;
}
The code segments must use an enhanced for loop given in the coding language.
What are code segments?A code segment is a chunk of an object file or the corresponding area of the program's source code that is used for programming. It is also referred to as a text segment or simply as text.
#include <iostream>
using namespace std;
int main()
{
string cwords[8]={"ten", "fading", "post", "card", "thunder", "hin-ge", "trailing", "batting"};
string temp="";
for (int i=0; i<8; i++)
{
temp=cwords[i];
int j=temp.length();
if (temp[j-3]=='i' && temp[j-2]=='n' && temp[j-1]=='g')
{
cout<<temp<<endl;
}
}
return 0;
}
Therefore, the code segments are written above.
To learn more about code segments, refer to the link:
https://brainly.com/question/20063766
#SPJ2
In this task, you will perform normalization on a crude table so that it could be stored as a relational database.
The staff at 'Franklin Consulting' have to routinely visit their clients in other cities. Franklin have a fleet of cars available for staff travels. During their trips, the staff sometimes need to fill up the car fuel. Upon returning from the trip, the staff claim that expenses back by providing the fueling receipt and some other essential information. The accountant records all of that information in a spreadsheet. Below are the spreadsheet column headers and a sample of data from each column.
Column Name
Example Data
Trip ID
4129
Staff name
Sarah James
Car details
Toyota Land Cruiser 2015
License Plate
1CR3KT
Odometer reading
25,067
Service station
Coles Express
Station address
27 Queen St, Campbelltown, NSW 2560
Fill up time
30 Jan 2020, 2:45 pm
Fuel type
Unleaded 95
Quantity litres
55
Cost per litre
$1.753
Total paid
$96.42
Given the information in above table,
1. Draw a dependency diagram to show the functional dependencies existing between columns. State any assumptions you make about the data and the attributes shown in the table. (3 marks)
2. Show the step by step process of decomposing the above table into a set of 3NF relations. (5 marks)
3. Review the design of your 3NF relations and make necessary amendments to define proper PKs, FKs and atomic attributes. Any additional relations may also be defined at this stage. Make sure all of your attributes conform to the naming conventions. (3 marks)
4. Draw the Crow’s Foot ERD to illustrate your final design. (4 marks)
Answer:
Check the explanation
Explanation:
(1.) The functional dependencies based on assumptions are as follows:-
Trip determines which staff was there in the trip, the car used for the trip, the quantity of fuel used in the trip, the fill up time and the total paid of the trip.
Service station refers to its address
Car details consist of the details of license plate, odometer reading and the fuel type used in the car
fuel type and the fill up time will help to determine the cost of the fuel at that time
cost of the fuel and the quantity of fuel used will determine the total paid
From the above assumptions the functional dependencies are as follows:-
Trip ID -> Staff Name, Car Details, Service Station, Quantity, Fill Up Time, Total Paid
Service Station -> Station Address,
Car Details -> License Plate, Odometer reading, Fuel Type
Fuel Type, Fill up Time -> Cost per litre
Cost per Litre, Quantity -> Total Paid
(2.) Initially the relation is as follows:-
R (Trip ID, Staff Name, Car Details, License Plate, Odometer Reading, Service Station, Station Address, Fill up Time, Fuel type, Quantity, Cost per Litre, Total Paid)
For 1 NF there should not be composite attributes,in the above relation Staff Name and Station Address are composite attributes therefore it will be decomposed as follows:-
R (Trip ID, Staff First Name,Staff Last Name, Car Details, License Plate, Odometer Reading, Service Station, Street, City, State, Zip Code, Fill up Time, Fuel type, Quantity, Cost per Litre, Total Paid)
For 2 NF there should not be partial dependency that is non prime attribute should not dependent upon any 1 prime attribute of candidate key, since in the given relation there is only 1 candidate key which is only Trip ID, therefore the relation is already in 2 NF.
For 3 NF there should not be transitive dependency that is non prime attribute should not dependent upon the other non prime attribute, if it is present then the relation will be decomposed into sub relations, the given relation is not in 3 NF therefore it will be decomposed as follows:-
R1 (Trip ID, Staff First Name, Staff Last Name, Car Details, Service Station, Quantity, Fill up time, Total paid)
R2 (Service Station, Street, City, State, Zip Code)
R3 (Car Details, License Plate, Odometer reading, Fuel Type)
R4 (Fuel Type, Fill up Time, Cost per litre)
R5 (Cost per Litre, Quantity, Total Paid)
(3.) After the 3 NF we add the primary and foreign key constraints as follows:-
R1 (Trip ID, Staff First Name, Staff Last Name, Car Details, Service Station, Quantity, Fill up time, Total paid)
R2 (Service Station, Street, City, State, Zip Code)
R3 (Car Details, License Plate, Odometer reading, Fuel Type)
R4 (Fuel Type, Fill up Time, Cost per litre)
R5 (Cost per Litre, Quantity, Total Paid)
In the above relational schema the primary keys are represented with bold and foreign keys by italic
(4.) The ER diagram of the above relational schema using crow's foot notation are as shown in the attached image below:-
Write a program to read 10 integers from an input file and output the average, minimum, and maximum of those numbers to an output file. Take the name of the input file and output file from the user. Make sure to test for the conditions 1. if the count of numbers is less than 10 in the input file, then your average should reflect only for that many numbers 2. if the count of numbers is more than 10 in the input file, then your average should reflect only for ten numbers only.
Answer:
#include <iostream>
#include <climits>
#include<fstream>
using namespace std;
int main ()
{
fstream filein;
ofstream fileout;
string inputfilename, outputfilename;
// ASk user to enter filenames of input and output file
cout<<"Enter file input name: ";
cin>>inputfilename;
cout<<"Enter file output name: ";
cin>>outputfilename;
// Open both file
filein.open(inputfilename);
fileout.open(outputfilename);
// Check if file exists [Output file will automatically be created if not exists]
if(!filein)
{
cout<<"File cannot be opened"<<endl;
return 0;
}
int min = INT_MAX;
int max = INT_MIN; //(Can't use 0 or any other value in case input file has negative numbers)
int count = 0; // To keep track of number of integers read from file
double average = 0;
int number;
// Read number from file
while(filein>>number)
{
// If min > number, set min = number
if (min>number)
{
min = number;
}
// If max < number. set max = number
if(max<number)
{
max = number;
}
// add number to average
average = average+number;
// add 1 to count
count+=1;
// If count reaches 10, break the loop
if(count==10)
{
break;
}
}
// Calculate average
average = average/count;
// Write result in output file
fileout<<"Max: "<<max<<"\nMin: "<<min<<"\nAverage: "<<average;
// Close both files
filein.close();
fileout.close();
return 0;
}
Design and implement a GUI application that uses text fields to obtain two integer values (one text field for each value) along with a button named "display" to display the sum and product of the values. Assume that the user always enters valid integer values as inputs.
Answer:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim sum, product, num1, num2 As Integer
num1 = Val(TextBox1.Text)
num2 = Val(TextBox2.Text)
sum = num1 + num2
product = num1 * num2
TextBox3.Text = sum
TextBox4.Text = product
End Sub
End Class
Explanation:The solution is implemented in Visual Basic Programming LanguageTwo textboxes are created to receive the user's input and two textboxes for displaying sum and product respectivelyEach of these controls are appropriately labeled (See the attached GUI interface)The Sum is calculated by adding the values from textbox1 and 2The product is calculated by multiplying bothProvided below is the implementation of the hashtable data structure we went over together in class. You are to implement the rehash method, which will be called with a new size for the internal buckets array. rehash will create a new buckets array, copy all the key/value pairs from the old buckets array into the new one, using linked list chains as before to support collisions, then switch to using the new buckets array. rehash should run in O(N) time, where N is the number of key/value pairs,. Your implementation of rehash should not make use of any other hashtable or list methods (other than those demonstrated in __setitem__ and __getitem__). Note that the first and last lines of rehash are given; you should not alter them.
Answer:
numBuckets = 47
def create():
global numBuckets
hSet = []
for i in range(numBuckets):
hSet.append([])
# print "[XYZ]: create() hSet: ", hSet, " type(hSet): ",type(hSet)
return hSet
def hashElem(e):
global numBuckets
return e % numBuckets
def insert(hSet,i):
hSet[hashElem(i)].append(i)
# print "[XYZ]: insert() hSet: ", hSet, " type(hSet): ",type(hSet)
def remove(hSet,i):
newBucket = []
for j in hSet[hashElem(i)]:
if j != i:
newBucket.append(j)
hSet[hashElem(i)] = newBucket
print "[XYZ]: remove() i: ", i," hashElem[i]: ", hashElem(i), " hSet[hashElem(i): ", hSet[hashElem(i)]
def member(hSet,i):
return i in hSet[hashElem(i)]
def testOne():
s = create()
for i in range(40):
insert(s,i)
print "[XYZ]: S: ", s
insert(s,325)
insert(s,325)
insert(s,9898900067)
print "[XYZ]: S: ", s
print "[XYZ]: ,member(s,325): ",member(s,325)
remove(s,325)
print "[XYZ]: After Remove, member(s,325): ",member(s,325)
print "[XYZ]: member(s,9898900067)",member(s,9898900067)
testOne()