WRITE IN C++
Add to the Coord class
Edit the provided code in C++
Write a member function named
int distance2origin()
that calculates the distance from the (x, y, z) point to the origin (0, 0, 0)
the ‘prototype’ in the class definition will be
int distance2origin()
outside the class definition
int Coord :: distance2origin()
{
// your code
}
_______________________________________________________________________________________________________
/**************************************************
*
* program name: Coord02
* Author:
* date due: 10/19/20
* remarks:
*
*
***************************************************/
/******************************************
* library includes
******************************************/
#include // needed for cin and cout
/******************************************
* pre-processor
******************************************/
#define PI 3.14159
using namespace std;
class Coord {
private:
int xCoord;
int yCoord;
int zCoord;
public:
Coord(int xCoord, int yCoord, int zCoord){
this->xCoord=xCoord;
this->yCoord=yCoord;
this->zCoord=zCoord;
}
inline void setXCoord(int xCoord){
this->xCoord=xCoord;
}
inline void setYCoord(int yCoord){
this->yCoord=yCoord;
}
inline void setZCood(int zCoord){
this->zCoord=zCoord;
}
inline int getXCoord(){
return this->xCoord;
}
inline int getYCoord(){
return this-> yCoord;
}
inline int getZCoord(){
return this->zCoord;
}
void display(){
cout<xCoord<yCoord<zCoord<
Please Explain Everything in detail. Thank you.
In: Computer Science
“Triangle Guessing” game in Python
The program accepts the lengths of three (3) sides of a triangle as input . The program output should indicate if the triangle is a right triangle, an acute triangle, or an obtuse triangle.
In: Computer Science
i need to find complexity and cost and runtime for each line of the following c++ code :
// A C++ program for Dijkstra's single source shortest path
algorithm.
// The program is for adjacency matrix representation of the
graph
#include <limits.h>
#include <stdio.h>
// Number of vertices in the graph
#define V 9
// A utility function to find the vertex with minimum distance
value, from
// the set of vertices not yet included in shortest path tree
int minDistance(int dist[], bool sptSet[])
{
// Initialize min value
int min = INT_MAX, min_index;
for (int v = 0; v < V; v++)
if (sptSet[v] == false &&
dist[v] <= min)
min = dist[v],
min_index = v;
return min_index;
}
// A utility function to print the constructed distance
array
void printSolution(int dist[])
{
printf("Vertex \t\t Distance from Source\n");
for (int i = 0; i < V; i++)
printf("%d \t\t %d\n", i,
dist[i]);
}
// Function that implements Dijkstra's single source shortest
path algorithm
// for a graph represented using adjacency matrix
representation
void dijkstra(int graph[V][V], int src)
{
int dist[V]; // The output array. dist[i] will hold
the shortest
// distance from src to i
bool sptSet[V]; // sptSet[i] will be true if vertex
i is included in shortest
// path tree or shortest distance from src to i is
finalized
// Initialize all distances as INFINITE and
stpSet[] as false
for (int i = 0; i < V; i++)
dist[i] = INT_MAX, sptSet[i] =
false;
// Distance of source vertex from itself is always
0
dist[src] = 0;
// Find shortest path for all vertices
for (int count = 0; count < V - 1; count++) {
// Pick the minimum distance vertex
from the set of vertices not
// yet processed. u is always equal
to src in the first iteration.
int u = minDistance(dist,
sptSet);
// Mark the picked vertex as
processed
sptSet[u] = true;
// Update dist value of the
adjacent vertices of the picked vertex.
for (int v = 0; v < V; v++)
// Update
dist[v] only if is not in sptSet, there is an edge from
// u to v, and
total weight of path from src to v through u is
// smaller than
current value of dist[v]
if (!sptSet[v]
&& graph[u][v] && dist[u] != INT_MAX
&& dist[u] + graph[u][v] <
dist[v])
dist[v] = dist[u] + graph[u][v];
}
// print the constructed distance array
printSolution(dist);
}
In: Computer Science
An ecologist observes an alarming number of frogs in agricultural areas that have extra limbs. She hypothesizes that the presence of Round-Up causes frogs to grow extra limbs (this is a real effect of Round-Up!).
She puts 25 tadpoles in an aquarium with pure water and labels these Group A.
She puts another 25 tadpoles in an aquarium with water and Round-Up and labels these Group B.
After all of the tadpoles develop into adult frogs, she counts the number of frogs in each group that have extra limbs.
1. Write a prediction for this hypothesis and experiment.
2. Identify the independent variable and dependent variable.
3. Identify the experimental group and the control group.
4. Name a variable she needs to control for in order to obtain reliable results.
In: Biology
66. You are deciding on a drug treatment for a patient with pancreatic cancer. You know that different drugs have different efficacies based on the nature of the specific type of tumor. You decide to identify the tumor type by transcriptional analysis. What experiment would you do to perform this analysis?Your analysis shows upregulation of a cluster of cell cycle genes, glucose metabolism genes and receptor tyrosine kinase signaling genes. Why do you suppose these 3 sets of genes would be upregulated? You decide to target the tyrosine kinase receptor signaling gene products for drug treatment. Name 2 protein targets and whether the drug would increase or decrease the targets activity.
This is how the question ask!!!!!!!!!!!!
In: Biology
Comprehensive Problem 2-2A
Ray and Maria Gomez have been married for 3 years. They live at 1610 Quince Ave., McAllen, TX 78701. Ray is a propane salesman for Palm Oil Corporation and Maria works as a city clerk for the City of McAllen. Maria's Social Security number is 444-65-9912 and Ray’s is 469-21-5523. Ray’s birthdate is February 21, 1988 and Marie’s is December 30, 1990. Ray and Maria’s earnings are reported on the following Form W-2s:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Ray and Maria have interest income of $641 from a savings account at McAllen State Bank. In addition, they own U.S. Savings bonds (Series EE). The bonds had a value of $10,000 on January 1, 2016, and their value is $10,700 on December 31, 2016. They have not made an election with respect to these bonds.
Ray has an ex-wife named Judy Gomez. Pursuant to their divorce decree, Ray pays her $455 per month in alimony. All payments were made on time in 2016. Judy's Social Security number is 566-74-8765.
During 2016, Ray was in the hospital for a successful operation. His health insurance company reimbursed Ray $4,732 for all of his hospital and doctor bills.
In June 2016, Maria's father died. Under a life insurance policy owned and paid for by her father, Maria was paid death benefits of $25,000.
Maria bought a Texas lottery ticket on impulse during 2016. Her ticket was lucky and she won $3,900. The winning amount was paid to Maria in November 2016, with no income tax withheld.
Palm Oil Corporation provide Ray with a company car to drive while he is working. The Corporation spent $5,000 to maintain this vehicle during 2016. Ray never uses the car for personal purposes.
Required:
Complete the Gomez's federal tax return for 2016. Use Form 1040 below. Make realistic assumptions about any missing data. If an amount box does not require an entry or the amount is zero, enter "0".
Click here to access the tax table to use for this problem.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
In: Accounting
In: Other
Mass M moves to the right with speed =v along a frictionless horizontal surface and crashes into an equal mass M initially at rest. Upon colliding, the two masses stick together and move with speed V to the right. Notice that v and V denote different speeds. After the collision the magnitude of the momentum of the system is:
(pick all correct answers)
2 M V
M V
0
2 M v
M v
In: Physics
Objectives:
•
Learn to write test cases with Junit
•
Learn to debug code
Problem: Sorting Book Objects
Download the provided zipped folder from Canvas. The source java files and test cases are in
the provided
folder. The Book class models a book. A Book has a unique id, title, and author.
The BookStore class stores book objects in a List, internally stored as an ArrayList. Also, the
following methods are implemented for the BookStore class.
•
addBook(Book b):
sto
res the book in the book list.
•
getBookSortedByAuthor():
returns a book list sorted by author name descending
alphabetically.
•
getBooksSortedByTitle():
returns a book listed sorted by title descending alphabetically.
•
getBooks():
returns the current book list
.
•
deleteBook(Book b5):
removes the given book from the book list.
•
countBookWithTitle(String title):
iterates through the book list counting the number of
books with the given title. Returns the count of books with the same title.
Write test cases to test t
he implementation.
The test case method stubs have been created.
Fill out the method stubs. After filling in the test case method stubs, run BookStoreTest to test
the BookStore.java code. Find and fix bugs in the BookStore.java code by using the debugger o
n
the test case method stubs.
Grade:
For this lab, we will need to see either
1)
Fully functional code solving the problem as specified or
Book.java
public class Book {
private int id; // the unique id assigned to
book
private String title; // book title
private String authorName;// author of the book
public Book() {
super();
}
public Book(int id, String authorName, String
title) {
this.id = id;
this.title = title;
this.authorName = authorName;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAuthorName() {
return authorName;
}
public void setAuthorName(String authorName)
{
this.authorName = authorName;
}
@Override
public String toString() {
return "\n Book [id=" + id + ",
title=" + title + ", authorName="
+ authorName + "]";
}
}
BookStore.java
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class BookStore {
private List<Book> books; // store books in a list
public BookStore() {
books = new
ArrayList<Book>();
}
public void addBook(Book b1) {
books.add(b1);
}
public List<Book> getBooksSortedByAuthor()
{
List<Book> temp = new
ArrayList<Book>(books);
Collections.sort(temp, new
Comparator<Book>() {
public int
compare(Book b1, Book b2) {
return
b1.getTitle().compareTo(b2.getAuthorName());
}
});
return books;
}
public int countBookWithTitle(String title) {
int count = 2;
for (Book book : books) {
if
(book.getTitle() == title) {
count++;
}
}
return count;
}
public void deleteBook(Book b5) {
books.remove(b5);
}
public List<Book> getBooks() {
return books;
}
public List<Book> getBooksSortedByTitle()
{
List<Book> temp = new
ArrayList<Book>(books);
Collections.sort(temp, new
Comparator<Book>() {
public int
compare(Book b1, Book b2) {
return
b1.getTitle().compareTo(b2.getAuthorName());
}
});
return temp;
}
}
BookStoreTest.java
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
public class BookStoreTest {
private BookStore store;
private Book b1 = new Book(1, "Harper Lee", "To Kill a
Mockingbird");
private Book b2 = new Book(2, "Harper Lee", "To Kill a
Mockingbird");
private Book b3 = new Book(3, "Frances Hodgson", "The
Secret Garden");
private Book b4 = new Book(5, "J.K. Rowling",
"Harry Potter
and the Sorcerer's Stone");
private Book b5 = new Book(4, "Douglas Adams",
"The
Hitchhiker's Guide to the Galaxy");
/**
* setup the store
*
*/
@Before
public void setUpBookStore() {
store = new BookStore();
store.addBook(b1);
store.addBook(b2);
store.addBook(b3);
store.addBook(b4);
}
/**
* tests the addition of book
*
*/
@Test
public void testAddBook() {
store.addBook(b1);
assertTrue(store.getBooks().contains(b1));
}
/**
* tests the deletion of book
*
*/
@Test
public void testDeleteBook() {
}
/**
* tests sorting of books by author name
*
*/
@Test
public void testGetBooksSortedByAuthor() {
}
/**
* tests sorting of books by title
*
*/
@Test
public void testGetBooksSortedByTitle() {
}
/**
* tests the number of copies of book in store
*
*/
@Test
public void testCountBookWithTitle() {
}
}
In: Computer Science
In: Computer Science