Questions
Java How to read a comma separated value file using Scanner for example Scanner sc =...

Java

How to read a comma separated value file using Scanner

for example Scanner sc = new Scanner(filename);

I need to assign each value separated by a comma to different variable types.

I need a good example to know how it works and implement it in my project

Please only use Scanner to read the file

In: Computer Science

Task 6.2.1. For each publisher with more than $2000 in purchase orders, list the customer id,...

Task 6.2.1. For each publisher with more than $2000 in purchase orders, list the customer id, name, credit code, and total of the orders. Use a WHERE clause to perform the join across the five required tables.

DROP TABLE publishers;
DROP TABLE po_items;
DROP TABLE bookjobs;
DROP TABLE items;
DROP TABLE pos;

CREATE TABLE publishers (
cust_id CHAR(3) NOT NULL,
name CHAR(10),
city CHAR(10),
phone CHAR(8),
creditcode CHAR(1),
PRIMARY KEY (cust_id)
);

CREATE TABLE bookjobs (
job_id CHAR(3) NOT NULL,
cust_id CHAR(3),
job_date DATE,
descr CHAR(10),
jobtype CHAR(1),
PRIMARY KEY (job_id),
FOREIGN KEY (cust_id) REFERENCES publishers (cust_id)
);

CREATE TABLE pos (
job_id CHAR(3) NOT NULL,
po_id CHAR(3) NOT NULL,
po_date DATE,
vendor_id CHAR(3),
PRIMARY KEY (job_id, po_id),
FOREIGN KEY (job_id) REFERENCES bookjobs (job_id)
);

CREATE TABLE items (
item_id CHAR(3) NOT NULL,
descr CHAR(10),
on_hand SMALLINT,
price DECIMAL(5,2),
PRIMARY KEY (item_id)
);

CREATE TABLE po_items (
job_id       CHAR(3) NOT NULL,
po_id       CHAR(3) NOT NULL,
item_id       CHAR(3) NOT NULL,
quantity     SMALLINT,
FOREIGN KEY (job_id) REFERENCES bookjobs (job_id),
FOREIGN KEY (job_id, po_id) REFERENCES pos (job_id, po_id),
FOREIGN KEY (item_id) REFERENCES items (item_id)
);

In: Computer Science

EER diagram Draw the EER diagram for the following systems. Persons in an organization are employees...

EER diagram

Draw the EER diagram for the following systems.

Persons in an organization are employees or customers or visitors. Employees have computers.
The IT department of the company builds all its computers from components. Each computer
consists of several components like graphic cards, network cards, mother boards, memory
capsules, hard discs, etc. When a component is bought from a supplier it is given an ID number.
The finished computer is placed in a room, which may contain several computers.
Prepare an EER diagram using only the concepts listed above, that shows, as necessary,
entities, relationships, specializations and generalizations. Show the most likely cardinalities
(min, max) for all relationships.

In: Computer Science

JAVAFX You will create a GUI that solves the quadratic equation shown below. Part 1: Create...

JAVAFX

You will create a GUI that solves the quadratic equation shown below.

  • Part 1: Create the GUI 25%

  1. Create a user interface that offers the user a space to enter values for A, B, and C. (Use a different text field for each.) Be sure to either set the text in these so that the user knows which is for A, which is for B, and which is for C or add labels so that it is clear.

  1. Create a button that the user will press to generate the answers. (Or make sure it’s clear how the user should submit their values in another way.)

  1. Create a node that will display both X values that result from the math. This can be 2 labels, a single label, a Text object… whatever.

  1. Put these in a simple layout and make sure everything displays before moving on. Add enough styling so that things look neat.

  • Part 2: Add EventHandler 75%

  1. After your nodes are created but before your scene and stage commands, add

an event handler. I would like it to be an ActionEvent type.

  1. Inside of the handle method, you will get the values from A, B, and C and solve for both X values. Make sure you store A, B, and C as doubles, not integers. Display the two answers that you get back to the GUI. There will be times where X will have no values. Handle this as addressed below.

  1. Be sure to check first to see if A has a 0 in it. If it does, the math should not be performed and the user should be informed that A cannot be 0.  

  1. Also check to see if the discriminant is negative. This is the part that occurs under the square root. We know that if it’s negative, then finding the square root of it will result in an imaginary number. Your program won’t crash if this happens but Java will display either ??? or NaN. Have the program check the discriminant before continuing with the math and display a custom message if the discriminant is negative.

  1. The only acceptable printed outcomes are: a message saying A cannot be 0; a message saying that the inputted values will result in an imaginary number; or the two X values that result from the equation.  

  1. One final task: Make sure both X answers are formatted to three decimal places. You can use String.format(), which was covered in Lab 1, the DecimalFormat class, or any other means for displaying 3 decimal places accurately.

Test values are below.

A: 3.0, B: 5.0, C: -2.0 → X = -2.000 and X = 0.333

A: -3.0, B: 10.0, C: 8.0 → X = 4.000 and X = -0.666

In: Computer Science

I am trying to create a program That works with two other programs in c++ and...

I am trying to create a program That works with two other programs in c++ and a makefile.

Only Shape.cpp can be modified. and it needs to work on a unix machine. It isn't running on my machine. And gives me an error message that it doesn't recomize cin and endl

The program will accept a character and an X and Y coordinate. Dependign on the Charactor, It will then tell you what Cells that shape occupies.

I almost have the program working, but I am getting several bugs. Can someone fix the Shape.cpp file, and tell me what they did to fix it?

Thanks.

all: testShape

CXXFLAGS=-g -Wall

Shape.o: Shape.cpp Shape.h
testShape.o: testShape.cpp Shape.h

testShape: testShape.o Shape.o
   $(CXX) -o $@ $^ $(LDFLAGS)

clean:
   rm -f *.o testShape

// end of makefile

//
// testShape.cpp
//DO NOT MODIFY

#include "Shape.h"
#include
#include
using namespace std;

int main()
{
Shape *t1, *t2;
char ch;
int x,y;

try
{
cin >> ch >> x >> y;
t1 = Shape::makeShape(ch,x,y);
t1->print();
cin >> ch >> x >> y;
t2 = Shape::makeShape(ch,x,y);
t2->print();
t2->move(1,-1);
t2->print();

if ( t1->overlap(*t2) )
cout << "overlap" << endl;
else
cout << "no overlap" << endl;

delete t1;
delete t2;
}
catch ( invalid_argument &exc )
{
cout << exc.what() << ": " << ch << " " << x << " " << y << endl;
}
}

//end of testshape

//
// Shape.h
// DO NOT MODIFY

#ifndef SHAPE_H
#define SHAPE_H
class Shape
{
public:
virtual ~Shape(void);
virtual char name(void) const = 0;
virtual int size(void) const = 0;
void print(void) const;
void move (int dx, int dy);
bool overlap(const Shape &t) const;
static Shape *makeShape(char ch,int posx,int posy);
protected:
int *x, *y;
};

class O: public Shape
{
public:
O(int posx, int posy);
virtual char name(void) const;
virtual int size(void) const;
};

class I: public Shape
{
public:
I(int posx, int posy);
virtual char name(void) const;
virtual int size(void) const;
};

class L: public Shape
{
public:
L(int posx, int posy);
virtual char name(void) const;
virtual int size(void) const;
};

class S: public Shape
{
public:
S(int posx, int posy);
virtual char name(void) const;
virtual int size(void) const;
};

class X: public Shape
{
public:
X(int posx, int posy);
virtual char name(void) const;
virtual int size(void) const;
};

class U: public Shape
{
public:
U(int posx, int posy);
virtual char name(void) const;
virtual int size(void) const;
};
#endif

//end of shape.h

// THIS IS THE FILE I NEED HELP WITH Shape.cpp

#ifndef SHAPE_CPP
#define SHAPE_CPP

#include "Shape.h"

// Constructor for O
O::O(int posx, int posy)
{
   x = new int[1];
   y = new int[1];

   x[0] = posx;
   y[0] = posy;
}

char O::name() const
{
   return 'O';
}

int O::size() const
{
   return 1;
}

// Constructor for I
I::I(int posx, int posy)
{
   x = new int[2];
   y = new int[2];

   x[0] = x[1] = posy;
   y[0] = posy;
   y[1] = posy+1;
}

char I::name() const
{
return 'I';
}
int I::size() const
{
   return 2;
}


// Constructor for L
L::L(int posx, int posy)
{
   x = new int[3];
   y = new int[3];

   x[0] = x[2] = posx;
   y[0] = y[1] = posy;

   x[1] = posx+1;
   y[2] = posy+1;
}

char L::name() const
{
   return 'L';
}
int L::size() const
{
   return 3;
}

// Constructor for S
S::S(int posx, int posy)
{
   x = new int[4];
   y = new int[4];

   x[0] = posx;
   x[1] = posx+1;
   x[2] = posx+2;
   x[3] = posx+3;

   y[0] = y[1] = posy;
   y[2] = y[3] = posy+1;
}

char S::name() const
{
   return 'S';
}
int S::size() const
{
   return 4;
}

/*
   Constructor for X
   the constructor initialises the cell co-ordinates

   X is spread across 5 cells

           *
       *   * *
           *

   The Numbering of cells is done from bottom-top and left to right
   (x[0], y[0]) is the position of bottom most cell
   (x[1], y[1]) is the position of left most cell of the 2nd row from bottom
   (x[2], y[2]) is the position of the middle cell in the 2nd row from bottom
   ....
*/
X::X(int posx, int posy)
{
   x = new int[5];
   y = new int[5];
   x[0] = x[2] = x[4] =posx;
   x[1] = posx-1;
   x[3] = posx+1;

   y[0] = posy;
   y[1] = y[2] = y[3] = posy+1;
   y[4] = posy+2;
}

char X::name() const
{
   return 'X';
}
int X::size() const
{
   return 5;
}

// Constructor for U
U::U(int posx, int posy)
{
   x = new int[7];
   y = new int[7];
   x[0] = x[3] = x[5] = posx;
   x[1] = posx+1;
   x[2] = x[4] = x[6] = posx+2;

   y[0] = y[1] = y[2] = posy;
   y[3] = y[4] = posy+1;
   y[5] = y[6] = posy+2;
}

char U::name() const
{
   return 'U';
}
int U::size() const
{
   return 7;
}

void Shape::print() const
{
   //get the size of the object i.e no of cells across which this is spread
   int sz = size();

   // get the type of object i.e O, L, X...
   char n = name();

   cout<

   //Print all the cell co-ordinates for this object
   for(int i = 0 ; i < sz ; i++)
   {
       cout<<"("<        if(i != sz-1)
           cout<<" ";
   }
   cout< }

void Shape::move(int dx, int dy)
{
   int sz = size();

   for(int i = 0 ; i < sz ; i++)
   {
       x[i] += dx;
       y[i] += dy;
   }

}

/*
   This function checks if the object(this) and t overlap

   * First add all the cells of t to a set
   * the iterate over all the cells of (this) and check
   if they are already present in the set
   * If any of the cell is already present , objects overlap
   and return true
*/
bool Shape::overlap(const Shape &t) const
{
   set > st;
   int sz1 = t.size();
   int sz2 = size();

   for(int i = 0 ; i < sz1 ; i++)
   {
       st.insert(make_pair(t.x[i], t.y[i]));
   }

   for(int i = 0 ; i < sz2 ; i++)
   {
       if(st.find(make_pair(x[i], y[i]))!= st.end())
           return true;
   }
   return false;
}

/*
   This function creates a new object of type ch
*/
Shape * Shape::makeShape(char ch, int posx, int posy)
{
   if(ch == 'O')
       return new O(posx, posy);
   else if(ch == 'I')
       return new I(posx, posy);
else if(ch == 'L')
   return new L(posx, posy);
else if(ch == 'S')
   return new S(posx, posy);
else if(ch == 'X')
   return new X(posx, posy);
else if(ch == 'U')
   return new U(posx, posy);
else
   throw std::invalid_argument("Invalid syntax.");
}

// base class virtual destructor
Shape::~Shape()
{
   delete [] x;
   delete [] y;
}
#endif

In: Computer Science

Last week we observed a shopkeeper going about their daily routine and made some observations. This...

Last week we observed a shopkeeper going about their daily routine and made some observations. This week we will collect some user requirements either through an interview or a questionnaire (Your choice although the interview is much faster).

Find out what the shopkeepers challenges are, how their work can be made easier (think stock keeping, accounting, sales, ordering the possibilities are endless). Concentrate on one area and using the information you collect extract the requirements for the system. Using this information, create a persona for the shopkeeper.

  1. Proposed system per your understanding
  2. Extracted Requirements
  3. Shopkeeper Persona - Should have at a minimum: Photo, User Quote(If any), Bio, Personality, Challenges (Frustrations) and key goals

In: Computer Science

Write the c++ program of Bisection Method and False Position Method and newton Raphson method in...

Write the c++ program of Bisection Method and False Position Method and newton Raphson method in a one program using switch condition .Like :

cout<<"1.Bisection Method \n 2.False Position Method\n3.Newton Raphson method"<<endl; if press 1 then work Bisection Method code if press 2 then workFalse Position Method if press 3. work Newton Raphson method .so please writhe the code in c++ using switch case.and the equation given down consider the equation in the given.Note: Must showt the all the step of output all the iteration step shown in the program .in program must shown all the step of iteration result like every iteration x1,x2,x3 must be shown in program.

f(x)=3x-cosx-1;

Please in every itaration must be shown the output then finally Got the root

In: Computer Science

Write a function that has two parameters as input: the list of subtitles and the separator...

Write a function that has two parameters as input: the list of subtitles and the separator string. On the output it returns a single string being a combination of input string separated by a separator.

Example:

call: combine (List("This","is", "string"),"-")

result: "This-is-string"



In: Computer Science

Q3# Briefly provide the answers to the following questions? (a) Define overfitting. (b) List causes of...

Q3# Briefly provide the answers to the following questions?

(a) Define overfitting.

(b) List causes of overfitting in neural networks.

(c) How can overfitting be avoided in neural nertworks?

In: Computer Science

Please I need answer for all four questions please. ONLY ANSWER IF YOU CAN BE ABLE...

Please I need answer for all four questions please. ONLY ANSWER IF YOU CAN BE ABLE TO ANSWER TO 4 QUESTIONS. I DONT REALLY NEED LONG ANSWERS.

1.Describe why your nested Virtual Machine has a different DHCP server from your HOST Virtual Machine.

2. Describe why you would set your VM up using the host-mode network.

3. What is the difference between physical core and logical processors

4. What is memory ballooning and how should it be used in virtualization?

THANKS

In: Computer Science

a) Explain the relationship between "programming to interfaces" and "loose coupling," why we care about these...

a) Explain the relationship between "programming to interfaces" and "loose coupling," why we care about these two things, and why it is not possible to create completely decoupled code.

b) Given the fact that we care about these two concepts, why might this imply that the new operator is problematic for creating flexible code?

In: Computer Science

This is the question about Verilog. the H/W question is "Explain about 'always syntax' in verilog...

This is the question about Verilog.

the H/W question is "Explain about 'always syntax' in verilog with the simple verilog example."

  

In: Computer Science

Learning Objectives Writing classes that represent objects Define object's state (Instance variables) Define objects constructors Write...

Learning Objectives

  • Writing classes that represent objects
  • Define object's state (Instance variables)
  • Define objects constructors
  • Write getter (accessor) and setter (mutator) methods.

As in previous labs, please write the Java code for each of the following exercises in BlueJ. For each exercise, write a comment before the code stating the exercise number.

Make sure you are using the appropriate indentation and styling conventions

Exercise 1 (15 Points)

  • In BlueJ, create a new project called Lab5
  • In the project create a class called DogDemo with a static method called makeDogs
  • Create a second class in the same project called Dog that will represent a single dog (just a class header and an empty body for now).
  • In the makeDogs method, create a Dog object called myDog. Note that the Dog and DogDemo classes are now connected by a dotted arrow in the project window to show that DogDemo depends on (uses) the Dog class.

Exercise 2 (20 Points)

  • In the Dog class, create a variable at the class level (also called instance data or a field) that will represent the dog's name (a String).
  • Declare this variable as private. This puts the Dog class in charge of how the name gets updated. This variable is not DIRECTLY accessible from outside the Dog class.
  • In the declaration of the variable, initialize it to "Lassie".
  • Create a toString method that returns the dog's name.
  • In the makeDogs method of the DogDemo class, print the Dog object you created. Run the makeDogs method.

Exercise 3 (15 Points)

  • This would be OK if all dogs were named Lassie!! Each instance of Dog (each Dog object) will have its own name variable, which contain different values. So create a constructor in the Dog class that accepts a parameter which is used to set the name variable.
  • In the makeDogs method, create a new dog and pass in the name "Lassie" to its constructor.
  • Create a second Dog object with a different name, "Rover" for example.
  • Print the two dog objects.

Exercise 4 (15 Points)

  • Add another field to the Dog class representing the dog's breed (a String) and one representing the dog's age (an int). Both fields should be private.
  • Modify the Dog constructor to set these values as well, based on parameters.
  • Define a new Dog objects in makeDogs and give them a name, breed and age.
  • Modify the toString method to return a string in the following form:

Fido is a 3-year-old German Sheppard

  • Test the updated makeDogs method. Think through what is happening at each step.

Exercise 5 (10 Points)

  • Add standard "getter" methods for all three fields. Remember that getter methods just returns the value of a private instance variable (field). This will make the value of a private variable accessible ONLY through this method.
  • In the makeDogs method, get and print just the breed of one of your created objects.
  • Then get and print just the name of another one of the created objects.

Exercise 6 (10 Points)

  • In Dog, add a "setter" method for the age field. Don't change the age if the parameter is less than 1.
  • In the makeDogs method, try to set the age of yourDog to 0, then print the Dog object to make sure the age did not change.
  • Then set the age of yourDog to 4 and print it again.

Exercise 7 (15 Points)

  • You may have heard the expression "That's 21 in dog years" or something similar. The idea is to come up with a number to make it easy to compare a dog's age to that of a human in terms of overall life span. The calculation used is real age multiplied by 7. So a dog that's 3 years old is "21 in dog years".
  • Add a method in Dog called getDogYears that returns the dog's age in dog-years. Do NOT create another field for this. Just return the dog's current age multiplied by 7.
  • In the makeDogs method, print each dog's age in dog-years:

Rover is 28 in dog-years.

In: Computer Science

Given the python code below, show output: class MyClass: i = ["1010"] def f(self, name): self.i.append(str("470570"))...

Given the python code below, show output:

class MyClass:

i = ["1010"]


def f(self, name):

self.i.append(str("470570"))

self.name = name

return 'CPS'

if __name__ == "__main__":

x = MyClass()   

print(x.f("U"))   
print(x.name)   
print(x.i)      

y = MyClass()  

print(y.f("D"))   
print(y.name)  

print(y.i)

In: Computer Science

1. what mask in register F would cause the Simple Assembler instruction [and RA, RA, RF]...

1. what mask in register F would cause the Simple Assembler instruction [and RA, RA, RF] to put 0 in the most significant bit of register A without disturbing the other bits?

2. Suppose registers E and F contained AA and CC, respectively. What bit pattern would be in register D after executing the Simple Assembler instruction [xor RD,RE,RF]?

3. Suppose registers E and F contained AA and CC, respectively. What bit pattern would be in register D after executing the Simple Assembler instruction [and RD,RE,RF]?

4. If registers 0 and 1 contain the patterns B5 and F0, respectively, what will be in register 1 after executing the Simple Assembler instruction [move R0,R1]?

In: Computer Science