he Sleeping Teaching AssistantA university computer science department has a teaching assistant (TA) whohelps undergraduate students with their programming assignments duringregular ofFce hours. The TA’s ofFce is rather small and has room for only onedesk with a chair and computer. There are three chairs in the hallway outsidethe ofFce where students can sit and wait if the TA is currently helping anotherstudent. When there are no students who need help during ofFce hours, theTA sits at the desk and takes a nap. If a student arrives during ofFce hoursand Fnds the TA sleeping, the student must awaken the TA to ask for help. If astudent arrives and Fnds the TA currently helping another student, the studentsits on one of the chairs in the hallway and waits. If no chairs are available, thestudent will come back at a later time
In: Computer Science
: Write a paragraph to reflect on what you have learned about Microsoft access in terms of the difference between relational databases versus spreadsheets. Discuss ways in which a relational database could be useful for your work (if you have a job) or for your personal or professional projects (if you are a full-time student)
In: Computer Science
Assignment 4, Fraction Comparable
Instructions
For this assignment, you will be updating the Fraction class from Assignment 1. To get started, you can either make a copy of your Assignment 1 Fraction.java or download the Fraction.java template at the bottom of this assignment.
You will need to update Fraction so that it implements the Comparable interface. This will require adding an implements statement to the class declaration as well as the compareTo method. You will also add a simplify method which reduces a fraction to its lowest terms and, to help you with this, a static method gcd which finds the greatest common divisor of two integers.
The requirements of the methods to be added are as follows:
When you have successfully written your simplify method, you should add calls to this method at the end of the Fraction(int n, int d) constructor and the add method. This will ensure that fractions are always stored in their simplest possible form.
To test your code, download the runner class student_fraction_runner.java (Links to an external site.) into the same folder that holds your Fraction.java. Execute the method student_fraction_runner.main, and verify that the output matches the sample run listed below. Remember to change the runner to test with other values to make sure your program fits all the requirements. We will use a similar but different runner to grade the program.
When you are ready, paste your entire Fraction.java class in the box below, click run to test the output, and click submit when you are satisfied with your results.
Note: once you have completely finished the assignment feel free to add more methods (e.g. multiply) or extend the functionality of your Fraction class to include, for example, negative fractions. Make sure you submit your assignment first before making any changes like this.
Sample Run
Fraction 1: 4/5 Fraction 2: 3/2 Fraction 3: 4/5 Compare fraction 1 to fraction 2: -1 Compare fraction 2 to fraction 1: 1 Compare fraction 1 to fraction 3: 0 Compare fraction 3 to fraction 1: 0 Compare fraction 2 to fraction 3: 1 Compare fraction 3 to fraction 2: -1
Milestones
As you work on this assignment, you can use the milestones below to inform your development process:
Milestone 1: Write the static gcd method and test this by calling it on pairs of integers from another class.
Milestone 2: Write the simplify method (you will probably find it useful to call the gcd method). Add calls to this method at the end of the constructor and the add method.
Milestone 3: Implement the Comparable interface and write the method compareTo. Download the runner file and ensure the results are as expected.
In: Computer Science
Site map for your e-commerce site. How many webpages this site has? What’s the name of each page? (You may use a rectangle box to represent a page).
In: Computer Science
I'm trying to Generate number every 3 seconds and update the currenet number.I'm able to generate number every 3 seconds; However, the current number isn't update. I apperciate any help.
public static void main(String[] args) {
Runnable helloRunnable = new Runnable() {
public void run() {
CurrentNum=task2();
System.out.println("Result ==== "+CurrentNum);
}
};
ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
executor.scheduleAtFixedRate(helloRunnable, 0, 3, TimeUnit.SECONDS);
System.out.println("CurrentNum ==== "+CurrentNum);
}
public static int task2() {
// create instance of Random class
Random rand = new Random();
// Generate random integers in range 0 to 999
int rand_int1 = rand.nextInt(1000);
return rand_int1;
}
outPut:
CurrentNum ==== 0
Result ==== 631
Result ==== 789
Result ==== 958
I want the output tobe:
Result ==== 631
CurrentNum ==== 631
Result ==== 789
CurrentNum==== 789In: Computer Science
In: Computer Science
Question: Use backtracking algorithm design to write Java code to solve the subset problem: given a set of distinct integers, return all possible subsets. for example, input: new int[] {1,2,3}
output: [], [3], [2], [2,3], [1], [1,3], [1,2], [1,2,3]
In: Computer Science
Visual Basic program in visual studio please
Write a function that checks whether a string has a number based. Use what we learned about Asc to complete the following:
Function CheckLength (S As String) As Boolean
‘add a do loop to start at first character
‘if Ascii current character is between Asc (“0”) and Asc (“9”)
‘then we have a hit Return True
‘else check the next character
‘if loop is over, that means no hit was found Return False
End Function
Use this function in an application that allows the user to enter the string/text that should be tested by your CheckLength function.
Please submit your completed application.
In: Computer Science
Dirac's Theorem states that "A simple graph with n vertices (n >= 3) is Hamiltonian if every vertex has degree n / 2 or greater". Show that K n,n is Hamiltonian for all n >= 3
In: Computer Science
2. Compare and compare the matrix multiplication algorithm and the Floyd-Warshall algorithm to find all pairs shortest paths from the perspective below.
In: Computer Science
You are the network administrator for your organization. Your DHCP server (Server1) has a scope of 10.10.16.0 to 10.10.16.254 with a subnet mask of /20.
How would the Get-DhcpServerv4Scope ensure that all of the client computers obtain an IP address from Server1.
In: Computer Science
python3
Let x0,...,xn−1 be n numbers stored in the list x. The median of x, denoted median(x) is the “middle”-value of the numbers in x in the sense that half of the numbers in x are less than the median and the other half of the numbers in x are greater than the median. Let y denote a copy of x sorted in ascending order. Then median(x)=(y[n+1 2 −1] if n is oddy [n 2−1]+y[n 2] 2 if n is even. Complete the function my_median with the following specifications: • It that takes in one parameter, x, which is a list of numbers. • It returns median(x). • Do not alter x. Evaluating your function my_median(x) should not change the value of the list x. • Do not use Python’s built-in median function.
In: Computer Science
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
using namespace std;
// Define a Person class, including age, gender, and
yearlyIncome.
class Person {
public:
Person();
void Print();
void SetData(int a); // FIXME Also set gender and yearly
income
void SetGender(string gender);
void SetIncome(int income);
int GetAge();
string GetGender();
int GetIncome();
private:
int age;
string gender;
int yearlyIncome;
};
// Constructor for the Person class.
Person::Person() {
age = 0;
gender = "default";
yearlyIncome = 0;
return;
}
// Print the Person class.
void Person::Print() {
cout << "Age = " << this->age
<< ", gender = " << this->gender
<< ", yearly income = " << this->yearlyIncome
<< endl;
return;
}
// Set the age, gender, and yearlyIncome of a Person.
void Person::SetData(int a) { // FIXME Also set gender and yearly
income
this->age = a;
return;
}
void Person::SetGender(string gender){
this->gender = gender;
}
void Person::SetIncome(int income){
this->yearlyIncome = income;
}
// Get the age of a Person.
int Person::GetAge() {
return this->age;
}
string Person::GetGender(){
return this->gender;
}
int Person::GetIncome() {
return this->yearlyIncome;
}
// Get a filename from program arguments, then make a Person for
each line in the file.
bool ReadPeopleFromFile(int argc, char* argv[],
vector<Person> &people) {
Person tmpPrsn;
ifstream inFS;
int tmpAge = 0;
string tmpGender = "";
int tmpYI = 0;
if (argc != 2) {
cout << "\nUsage: [EXECUTABLE FILE] [TEXT DATA FILE], e.g.
myprog.exe dev_people.txt" << endl;
return true; // indicates error
}
cout << "Opening file " << argv[1] <<
".\n";
inFS.open(argv[1]); // Try to open file
if (!inFS.is_open()) {
cout << "Could not open file " << argv[1] <<
".\n";
return true; // indicates error
}
while (!inFS.eof()) {
inFS >> tmpAge;
inFS >> tmpGender;
inFS >> tmpYI;
tmpPrsn.SetData(tmpAge); // FIXME Also set gender and yearly
income
tmpPrsn.SetGender(tmpGender);
tmpPrsn.SetIncome(tmpYI);
tmpPrsn.Print();
people.push_back(tmpPrsn);
}
inFS.close();
cout << "Finished reading file." << endl;
return false; // indicates no error
}
// Ask user to enter age range.
void GetUserInput(int &ageLowerRange, int &ageUpperRange,
string &gender, int &yILowerIncome,int &yIHigherIncome)
{
cout<<"\nEnter lower range of age: ";
cin >> ageLowerRange;
cout << "Enter upper range of age: ";
cin >> ageUpperRange;
cout << "Enter the gender: ";
cin >> gender;
cout << "Enter the lower range of yearlyIncome: ";
cin >> yILowerIncome;
cout << "Enter the higher range of yearlyIncome: ";
cin >> yIHigherIncome;
return;
}
// Return people within the given age range.
vector<Person> GetPeopleInAgeRange(vector<Person> ppl,
int lowerRange, int upperRange) {
unsigned int i = 0;
vector<Person> pplInAgeRange;
int age = 0;
for (i = 0; i < ppl.size(); ++i) {
age = ppl.at(i).GetAge();
if ((age >= lowerRange) && (age <= upperRange))
{
pplInAgeRange.push_back(ppl.at(i));
}
}
return pplInAgeRange;
}
// Return people with same Gender.
vector<Person>
GetPeopleWithSpecificGender(vector<Person> ptntlCstmrs,string
gender){
vector<Person> pplWithSameGender;
string gndr;
for (int i=0;i<ptntlCstmrs.size();i++){
gndr = ptntlCstmrs.at(i).GetGender();
if (gndr.compare(gender) == 0){
pplWithSameGender.push_back(ptntlCstmrs.at(i));
}
}
return pplWithSameGender;
}
// Return people within the given income range.
vector<Person> GetPeopleInIncomeRange(vector<Person>
ptntlCstmrs,int lowerRange, int higherRange){
vector<Person> pplInIncomeRange;
int range = 0;
for (int i=0;i<ptntlCstmrs.size();i++){
range = ptntlCstmrs.at(i).GetIncome();
cout << range << endl;
if ((range >= lowerRange) && (range <=
higherRange)){
pplInIncomeRange.push_back(ptntlCstmrs.at(i));
}
}
return pplInIncomeRange;
}
int main(int argc, char* argv[]) {
vector<Person> ptntlCstmrs;
bool hadError = false;
int ageLowerRange = 0;
int ageUpperRange = 0;
string gender;
int yILowerIncome = 0;
int yIHigherIncome = 0;
hadError = ReadPeopleFromFile(argc, argv, ptntlCstmrs);
if( hadError ) {
return 1; // indicates error
}
GetUserInput(ageLowerRange, ageUpperRange, gender,
yILowerIncome, yIHigherIncome );
ptntlCstmrs = GetPeopleInAgeRange(ptntlCstmrs, ageLowerRange,
ageUpperRange);
ptntlCstmrs =
GetPeopleWithSpecificGender(ptntlCstmrs,gender);
ptntlCstmrs =
GetPeopleInIncomeRange(ptntlCstmrs,yILowerIncome,yIHigherIncome);
cout << "\nNumber of potential customers =
"<<ptntlCstmrs.size() << endl;
return 0;
}
this is my code for my assignment, my professor said i'm missing
Based on that rubric, it looks like the code is missing two
things:
* Person class in separate files
* Output persons with user-entered gender works for "any"
can someone help me with this?
In: Computer Science
Need someone to fix my code: based on this version, give me another version without adding struct student.
#include <iostream>
#include <iomanip>
using namespace std;
struct student
{
double firstQuizz;
double secondQuizz;
double midTerm;
double finalTerm;
double overallScore;
char gradeLetter;
string name;
};
void getStudentData(student &s);
void calcPercentage(student &s);
void gradeLetter(student &s);
void display(student s[],int n);
int main()
{
int n;
cout<<"enter the number of students"<<endl;
cin>>n;
struct student students[n];
int i; struct student istudent;
for(i=0;i<n;i++)
{
cout<<":: Student#"<<(i+1)<<"
::"<<endl;
getStudentData(students[i]);
}
for(i=0;i<n;i++)
{
calcPercentage(students[i]);
gradeLetter(students[i]);
}
display(students,n);
return 0;
}
void getStudentData(student &s)
{
cin.ignore();
cout<<"Student name?";
getline(cin,s.name);
cout<<"Enter marks in first quizz :";
cin>>s.firstQuizz;
cout<<"Enter marks in second quizz :";
cin>>s.secondQuizz;
cout<<"Enter marks in mid term :";
cin>>s.midTerm;
cout<<"Enter marks in final term :";
cin>>s.finalTerm;
}
Programming language: C++
void calcPercentage(student &s)
{
double overAllScore = (s.firstQuizz + s.secondQuizz)*5 * 0.25 +
s.midTerm * 0.25 + s.finalTerm* 0.50;
s.overallScore=overAllScore;
}
void gradeLetter(student &s)
{
double average=s.overallScore;
char gradeLetter;
if (average >= 90 && average<=100)
gradeLetter = 'A';
else if (average >= 80 && average < 90)
gradeLetter = 'B';
else if (average >= 70 && average < 80)
gradeLetter = 'C';
else if (average >= 60 && average < 70)
gradeLetter = 'D';
else if (average < 60)
gradeLetter = 'F';
s.gradeLetter=gradeLetter;
}
void display(student s[],int n)
{
//setting the precision to two
decimal places
std::cout << std::setprecision(2) <<
std::fixed;
cout<<setw(15)<<left<<"Name"<<setw(15)<<right<<"Overall
Score"<<setw(15)<<right<<"Grade
Letter"<<endl;
cout<<setw(15)<<left<<"----"<<setw(15)<<right<<"-------------"<<setw(15)<<right<<"------------"<<endl;
for(int i=0;i<n;i++)
{
cout<<setw(15)<<left<<s[i].name<<setw(15)<<right<<s[i].overallScore<<setw(15)<<right<<s[i].gradeLetter<<endl;
}
}
Programming language: C++
Requirement: based on this version, give me another version without adding struct student.
In: Computer Science