Please separate this code with different header files thank you.
#include<iostream>
//bismark
using namespace std;
public:
class Circle {
private double radius;
private char color;
private boolean filled;
public Circle(double radius, char color, boolean
filled) {
super();
this.radius = radius;
this.color = color;
this.filled = filled;
}
public Circle() {
super();
this.radius = 0;
this.color = 'W';
this.filled = false;
}
public Circle(double radius) {
super();
this.radius = radius;
this.color = 'W';
this.filled = false;
}
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public char getColor() {
return color;
}
public void setColor(char color) {
this.color = color;
}
public boolean isFilled() {
return filled;
}
public void setFilled(boolean filled) {
this.filled = filled;
}
public double getCircumference(double r)
{
return 2 * 3.14*r;
}
public double getArea(double r)
{
return 3.14*r*r;
}
}
In: Computer Science
problem 1 Write a function to search an item named searchkey in an array of 20 elements. Assumed the array has all integer value and also the search item is an integer.
problem 2 Now consider the array is sorted. Modify the above script (from question 1) in a way so that dont have to search the item in every position of the array( not looking 20 times considering worst case scenario).
thanks in advance
In: Computer Science
Prove that the following problem is in NP: Given a digraph G over n vertices (n is an even number), does G contain 2 vertex-disjoint simple cycles in which each cycle is of length n/2?
In: Computer Science
A Private Poly Clinic in City wish to develop software to automate their Patient Monitoring system for storing the details of the patients visited the clinic. Develop a system to meet the following requirements:
|
Patient Id |
Fees in (OMR) |
Gender |
|
P001 |
15 |
M |
|
P002 |
10 |
F |
|
P003 |
20 |
M |
|
P004 |
8 |
F |
|
P005 |
12 |
M |
Read the fees paid by ‘N’ patients into a one dimensional array in random order. Develop an algorithm, flow chart and write a C program to arrange the fees read in ascending order. Display the result with appropriate statements.
In: Computer Science
Assume the following declarations have been made:
-----------------------------------
char item[50];
char guess;
-----------------------------------
Furthermore, suppose that all of the elements of an item have
already been initialized, and that the user has already entered a
value for guess.
Write a code fragment to find and print out each index i for which
item[i] is the same as guess.
Be sure to specify any additional necessary variable declarations.
As an example, consider the case where the rst 10 elements of item
are (in order)
'a', 'b', 'c', 'd', 'a', 'b', 'b', 'c', 'f', 'a',
and the remaining elements are all 'y'. If guess were 'b', then
your code should print out the following indices:
1 5 6
In: Computer Science
Python 3.5:
Consider the Account class that we developed previously.
Task 1:
Review the code in the constructor in the Account class. What happens if we attempt to make a new account with a negative balance? Use exception handling to raise an exception if a balance less that 0 is given. Add a message to the constructor saying "Warning! Your balance is equal to or less than 0!".
Task 2:
Next, in the Account class's withdraw() method, add code to check if the amount given exceeds the account's balance. If it does, then raise a ValueError. Add a message to the withdraw() method saying "ERROR: Insufficient funds!". The balance in the account should remain unchanged.
Also, add code to check if the amount of withdrawal is zero. You should raise a ValueError if the amount is less than or equal to zero.
Note: you must submit the entire class definition.
For example:
| Test | Output |
| try: account1 = Account(1122, 0, 3.35) except ValueError as x: print (x) |
Warning! Your balance is equal to or less than 0. |
| try: account2 = Account(1122, 100, 3.35) account2.withdraw(200) except ValueError as x: print (x) print(account2.get_balance()) |
ERROR: Insufficient funds! 100 |
| try: account2 = Account(1122, 100, 3.35) account2.withdraw(0) except ValueError as x: print (x) print(account2.get_balance()) |
ERROR: Invalid amount! 100 |
Account Code:
------------------------------------------------------
class Account:
def __init__(self, id, balance: int=None, annual_interest_rate:
int=None):
if balance > 0:
self.__id = id
if balance == None:
self.__balance = 100
else:
self.__balance = balance
if annual_interest_rate == None:
self.__annualInterest = 0
else:
self.__annualInterest = annual_interest_rate
else:
raise ("Warning! Your balance is equal to or less than 0!")
def get_id(self):
return self.__id
def get_balance(self):
return self.__balance
def get_annual_interest_rate(self):
return self.__annualInterest
def get_monthly_interest_rate(self):
return (self.__annualInterest/12)
def get_monthly_interest(self):
return (self.__balance * (self.__annualInterest/12)/100)
def deposit(self, amount: int=None):
if amount == None:
deposit = 0
else:
deposit = amount
self.__balance = self.__balance + amount
return
def withdraw(self, amount: int=None):
if amount == None:
withdraw = 0
else:
withdraw = amount
self.__balance = self.__balance - withdraw
return
def get_balance(self):
return self.__balance
In: Computer Science
1. Draw a use case diagram for the selected project and identify the classes in the domain with attributes, functions, and relationships among classes. (State your assumptions clearly).
2. Design a database for the selected project. Please draw the following diagrams necessary to develop your database.
a. ER-diagram (Entity-relationship diagram)
b. Normalization of the database up to 3rd normal form. (Only if needed, if not needed justify).
My selected project is:
Develop a system to automate membership details and time allocation for swimmers in a swimming club. All users should take membership and pay monthly for usage. Usage could be with a coach or without. The program should produce and income report for a given month
In: Computer Science
Complex numbers using overload constructor and private parameters in C++
I don't know why my code does not compile......
please DO NOT CHANGE THE MAIN....
complexDriver.cpp
#include <iostream>
#include "complex.h"
using namespace std;
int main( ) {
// Ex) complex(4.0, 3.0) means 4.0+3.0i.
complex c1, c2( 1.2, 4.9 ), c3( 2.2, 1.0 ), c4( -7.0, 9.6 ),
c5(8.1, -4.3),
c6(0.0, -7.1), c7(6.4), c8(0.0, 1.0), c9(0.0, 4.1), c10(0.0, -1.0),
c11;
cout << "c1 = " << c1 << endl;
cout << "c2 = " << c2 << endl;
cout << "c3 = " << c3 << endl;
cout << "c4 = " << c4 << endl;
cout << "c5 = " << c5 << endl;
cout << "c6 = " << c6 << endl;
cout << "c7 = " << c7 << endl;
cout << "c8 = " << c8 << endl;
cout << "c9 = " << c9 << endl;
cout << "c10 = " << c10 << endl;
cout << "c11 = " << c11 << endl;
}
complex.h
#ifndef COMPLEX_H
#define COMPLEX_H
#include <iostream>
using std::istream;
using std::ostream;
class complex{
// Stream I/O
friend ostream& operator<<(ostream &, const complex
&);
friend istream& operator>>(istream&,
complex&);
public:
double getReal() const; // getter
void setReal(double x); // setter
double getImaginary() const;
void setImaginary(double y);
// Ex) complex(4.0, 3.0) means 4.0+3.0i.
complex(double x= 0.0, double y= 0.0); // default constructor
private:
double Real;
double Imaginary;
};
#endif // COMPLEX_H
complex.cpp
#include <iostream>
#include "complex.h"
using std::cout;
using std::endl;
double complex::getReal() const{ // getter
return Real;
}
void complex::setReal(double x){ // setter
Real = x;
}
double complex::getImaginary() const{
return Imaginary;
}
void complex::setImaginary(double y){
Imaginary = y;
}
// X= real part, Y = imaginary part. real number = X+Yi
// Ex) complex(4.0, 3.0) means 4.0+3.0i.
complex::complex(double x, double y){ // default constructor
setReal(x);
setImaginary(y);
}
// Stream I/O
ostream& operator<<(ostream &out, const complex
&c){
out<< c.x<<"+"<< c.y<< "i";
return out;
}
In: Computer Science
Instructions: Digital submission in PDF format (you can use Word
or Markdown to create these and then convert to PDF). Your
submission must include all R code.
I will be testing all of your code by copying and pasting into my R
session, so make sure it works. Your solutions should be a
narrative that incorporates R code (i.e. tell a story). R code by
itself is not sufficient. This must be entirely an original work
done by you. Copying someone else’s work (possibly found online) is
not acceptable.
Assignment:
1) In homework 2, you gave the name of a site you would like to scrape. Follow through with this (you may change the site if you wish). The point of this exercise will be to ultimately provide an interesting visualization of the data which needs to be included in your solution. For this problem, the data must be scraped. Provide why you chose this site, and how someone would find your visualization useful (in other words, justify why anyone would care about this).
In: Computer Science
Given the information below, create the fully labeled Crow's Foot ERD using a specialization hierarchy where appropriate (use Visio). The ERD must contain all primary keys, foreign keys, and main attributes. Business rules are defined as follows: A small company sells products on-line. Each product is supplied by one supplier. Each supplier delivers only one product. Each product belongs to one of the following categories: Books, Movies, or CDs. All products have common attributes - a product code, a title and a price- and attributes that are unique for each group of products. The list of such attributes includes but is not limited to the following: the publisher name (books), the format (movies), and the rating (CDs). In addition, customers may purchase a book (hardcover or paperback) or its' electronic version. For regular books, the company wants to record the number of pages per book. For electronic books, the format and the size of the file must be recorded.
In: Computer Science
1, If we want to display output from a command, such as DIR or TYPE, one screen at a time, we can use what kind of command?
> MORE
| PAGE
| MORE
>> PAGE
2, To delete a directory that contains subdirectories and/or files, we will use what command:
DEL directory name /S
MD directory name /S
RD directory name /S
RMDIR directory name
3, When we are using certain tools (e.g. WMIC, DISKPART, and NETSH) in the Interactive Mode, most of the internal Command Prompt commands, such as CLS and CD, would not work. However, which command will work?
BYE
EXIT
| MORE
START
4, When we use this command in a batch file, the user must pick from the available options because Command Prompt won't let s/he pick anything else:
CHOICE
IF ELSE
FOR
SET
In: Computer Science
Hi Can someone explain how the the output was achieved in details for this java question?
public class Example
{
public static void main(String [] args)
{
int a = 6, b = 5, i , num1, num2;
for (i = 1; i <= 3; ++i)
{
num1 = method1(a, b);
num2 = method2 (a, b);
System.out.println (num1 + " " + num2);
a = a + 2;
b = b - 1;
}
}
public static int method1 (int c, int d)
{
c = c + d;
return c;
}
public static int method2 (int e, int f)
{
f = f + e * 2 ;
return f ;
}
}
output
run:
11 17
12 20
13 23
In: Computer Science
Python
1. Change the order of an input string based on Unicode equivalent.
Write a function Reorder that will take an input string of a maximum length of 20 characters and create a new string that reorders the string based on it’s binary Unicode character equivalent, e.g. ‘a’ = 0x61, ‘A’ = 0x41, from smallest value to largest value. In this example, ‘A’ would come before ‘a’, as 0x41 is a smaller number than ox61. Note, use python logical operators to do the comparison. Do not try to create a Unicode lookup table. For your code, use the string “sum=(x*259)/average” as your input string to your function.
In: Computer Science
Show the values contained in the instance variables elements and numElements of the sample collection after the following sequence of operations:
ArrayCollection<String> sample = new ArrayCollection<String>; sample.add("A"); sample.add("B"); sample.add("C"); sample.add("D"); sample.remove("B");
//---------------------------------------------------------------------------
// ArrayCollection.java by Dale/Joyce/Weems Chapter 5
//
// Implements the CollectionInterface using an array.
//
// Null elements are not allowed. Duplicate elements are
allowed.
//
// Two constructors are provided: one that creates a collection of
a default
// capacity, and one that allows the calling program to specify the
capacity.
//---------------------------------------------------------------------------
package ch05.collections;
public class ArrayCollection<T> implements
CollectionInterface<T>
{
protected final int DEFCAP = 100; // default capacity
protected T[] elements; // array to hold collection’s
elements
protected int numElements = 0; // number of elements in this
collection
// set by find method
protected boolean found; // true if target found, otherwise
false
protected int location; // indicates location of target if
found
public ArrayCollection()
{
elements = (T[]) new Object[DEFCAP];
}
public ArrayCollection(int capacity)
{
elements = (T[]) new Object[capacity];
}
protected void find(T target)
// Searches elements for an occurrence of an element e such
that
// e.equals(target). If successful, sets instance variables
// found to true and location to the array index of e. If
// not successful, sets found to false.
{
location = 0;
found = false;
while (location < numElements)
{
if (elements[location].equals(target))
{
found = true;
return;
}
else
location++;
}
}
public boolean add(T element)
// Attempts to add element to this collection.
// Returns true if successful, false otherwise.
{
if (isFull())
return false;
else
{
elements[numElements] = element;
numElements++;
return true;
}
}
public boolean remove (T target)
// Removes an element e from this collection such that
e.equals(target)
// and returns true; if no such element exists, returns
false.
{
find(target);
if (found)
{
elements[location] = elements[numElements - 1];
elements[numElements - 1] = null;
numElements--;
}
return found;
}
public boolean contains (T target)
// Returns true if this collection contains an element e such
that
// e.equals(target); otherwise, returns false.
{
find(target);
return found;
}
public T get(T target)
// Returns an element e from this collection such that
e.equals(target);
// if no such element exists, returns null.
{
find(target);
if (found)
return elements[location];
else
return null;
}
public boolean isFull()
// Returns true if this collection is full; otherwise, returns
false.
{
return (numElements == elements.length);
}
public boolean isEmpty()
// Returns true if this collection is empty; otherwise, returns
false.
{
return (numElements == 0);
}
public int size()
// Returns the number of elements in this collection.
{
return numElements;
}
}
In: Computer Science
Draw a landscape image using python coding.
In: Computer Science