10)A famous example of illustrating the importance of
looking beyond the mean (or average) of a data set to understand
the data is ______ .
A) Exploratory data analysis
B) Anscombe's quartet
C) Infographics
D) Visualization of Napoleon's march on
Moscow
please provide the reason why you are choosing an option to be right. its for my understanding . and also why other options are not right
expecting an early response.will rate your answer.
thankyou
In: Computer Science
Car class Question
Design a class named car that has the following fields: YearModel: The yearModel field is an integer that holds the car's year model. Make: The make field references a string that holds the make of the car. Speed: The speed field is an integer that holds the car's current speed. In addition, the class should have the following constructor and other methods: Constructor: The constructor should accept the. car's year model and make as arguments. The values should be assigned to the object's yearModel and make fields. The constructor should also assign 0 to the speed field. Accessors: Design appropriate accessor methods to get the values stored in an object's yearModel, make, and speed fields. Accelerate: The accelerate method should add 5 to the speed field each time it is called. Brake: The brake method should subtract 5 from the speed field each time it is called. Next, design a program that creates a car object, and then cals the accelerate method fibe times. After each call to the accelerate method, get the current speed of the car and display it. Then call the brake method 5 times. After each call to the brake method, get the current speed of the car and display it..........
Thanks for the help guys pseudocode and flowchart please
In: Computer Science
c++
1. write a c++ function that received two doubles that represent the sides of a triangle and an integer that represents the number of triangles of that size. calculate the area of all these triangles. remember area of a triangle is ahalf base times width. and return this value as a double.
In: Computer Science
Write a Java program to convert octal (integer) numbers into their decimal number equivalents (exactly the opposite of what you have done in Assignment 4). Make sure that you create a new Project and Java class file for this assignment. Your file should be named “Main.java”. You can read about octal-to-decimal number conversions on wikepedia
Assignment 4 is at the bottom
Objective
Your program should prompt the user to enter a number of no greater than 8 digits. If the user enters a number greater than 8 digits or a value less than 0, it should re-prompt the user to enter a number again*. You do not need to check if the digits are valid octal numbers (0-7), as this is guaranteed.
Instructions
main(){
int oct = user input;
conversion(oct);
}
void conversion(int o){
// logic goes here.
print(decimal);
}
Goals
Sample Runs
Sample Program Run (user input is underlined)
Enter up to an 8-digit octal number and I will convert it for you: 77777777
16777215
Sample Program Run (user input is underlined)
Enter up to an 8-digit octal number and I will convert it for you: 775002
260610
Sample Program Run (user input is underlined)
Enter up to an 8-digit octal number and I will convert it for you: 0
0
Sample Program Run (user input is underlined)
Enter up to an 8-digit octal number and I will convert it for you: 55
45
Sample Program Run (user input is underlined)
Enter up to an 8-digit octal number and I will convert it for you: 777777777
Enter up to an 8-digit octal number and I will convert it for you: 777777777
Enter up to an 8-digit octal number and I will convert it for you: 700000000
Enter up to an 8-digit octal number and I will convert it for you: 77
63
Assignment 4:
// Main.java : Java program to convert decimal number to octal
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int inputNum, convertedNum;
Scanner scan = new Scanner(System.in);
// Input of integer number in decimal
System.out.print("Please enter a number between 0 and 2097151 to convert: ");
inputNum = scan.nextInt();
// validate the number
if(inputNum < 0 || inputNum > 2097151)
System.out.println("UNABLE TO CONVERT");
else
{
int weight=0; // weight of the digit, used for converting to octal
convertedNum = 0; // variable to store the number in octal
int temp = inputNum;
int digit;
// loop that continues till we convert the entire number to octal
while(temp > 0)
{
digit = (temp%8); // get the remainder when the number is divided by 8
// multiply the digit with its weight and add it to convertedNum
convertedNum += digit*Math.pow(10, weight);
temp = temp/8; // remove the last digit from the number
weight++; // increment the weight
}
// display the integer in octal
System.out.printf("Your integer number " + inputNum + " is %07d in octal",convertedNum);
}
scan.close();
}
}
In: Computer Science
malware is often embedded in links or documents transmitted to intended victims and activated when links are followed or documents opened . what guidelines do you recommend following to prevent from being a victim of such an attack?
In: Computer Science
Report for Movie: The Matrix
What philosophical issues were addressed or raised in the book(s) and movie(s)? Give your points of view on these issues. (400 words or above)
In: Computer Science
I am having issues using bool CustomerList::updateStore(). I am using strcpy in order to update input for the Store class, but all I am getting is the same input from before. Here is what I am trying to do:
Ex.
(1234, "Name", "Street Address", "City", "State", "Zip")
Using the function bool CustomerList::updateStore()
Updating..successful
New Address:
(1234, "Store", "111 Main St.", "Townsville", "GA", "67893")
CustomerList.h
#pragma once;
#include
#include "Store.h"
class CustomerList
{
public:
Store *m_pHead;
CustomerList();
~CustomerList();
bool addStore(Store *s);
Store *removeStore(int ID);
Store *getStore(int ID);
bool updateStore(int ID, char
*name, char *addr, char *city, char *st, char *zip);
void printStoresInfo();
};
CustomerList.cpp
#include
#include "CustomerList.h"
#include "Store.h"
using namespace std;
CustomerList::CustomerList()
{
m_pHead = NULL;
}
CustomerList::~CustomerList()
{
delete m_pHead;
}
bool CustomerList:: addStore(Store *s)
{
if(m_pHead==NULL)
{
m_pHead = new
Store(s->getStoreID(),s->getStoreName(),
s->getStoreAddress(), s->getStoreCity(),
s->getStoreState(), s->getStoreZip());
return true;
}
else
{
Store * temp;
temp=m_pHead;
while(temp->m_pNext != NULL)
{
temp =
temp->m_pNext;
}
temp->m_pNext = new Store(s->getStoreID(),s->getStoreName(), s->getStoreAddress(), s->getStoreCity(), s->getStoreState(), s->getStoreZip());
return true;
}
}
Store *CustomerList::removeStore(int ID)
{
Store *temp, *back;
temp = m_pHead;
back = NULL;
while((temp != NULL)&&(ID != temp ->getStoreID()))
{
back=temp;
temp=temp->m_pNext;
}
if(temp==NULL)
return NULL;
else if(back==NULL)
{
m_pHead = m_pHead
->m_pNext;
return temp;
}
else
{
back -> m_pNext = temp->
m_pNext;
return temp;
}
return NULL;
}
Store *CustomerList::getStore(int ID)
{
Store *temp;
temp = m_pHead;
while((temp != NULL) && (ID != temp ->getStoreID()))
{
temp =
temp->m_pNext;
}
if(temp == NULL)
return NULL;
else
{
Store *retStore = new
Store();
*retStore = *temp;
retStore->m_pNext = NULL;
return retStore;
}
}
bool CustomerList::updateStore(int ID, char *name, char *addr, char *city, char *st, char *zip)
{
Store *temp;
temp = m_pHead;
while((temp!=
NULL)&&(ID != temp->getStoreID()))
{
temp = temp->m_pNext;
}
if(temp == NULL)
{
return false;
}
else
{
strcpy(temp->getStoreName(),name);
strcpy(temp->getStoreAddress(),addr);
strcpy(temp->getStoreCity(),city);
strcpy(temp->getStoreState(),st);
strcpy(temp->getStoreZip(),zip);
return
true;
}
}
void CustomerList::printStoresInfo()
{
Store *temp;
if(m_pHead == NULL)
{
cout << " The List is
empty.\n" ;
}
else
{
temp = m_pHead;
while(temp != NULL)
{
temp->printStoreInfo();
temp = temp->m_pNext;
}
}
}
Store.h
#pragma once;
#include
#include
using namespace std;
class Store
{
private:
int
m_iStoreID;
char
m_sStoreName[64];
char
m_sAddress[64];
char m_sCity[32];
char
m_sState[32];
char m_sZip[11];
public:
Store *m_pNext;
Store();
// Default constructor
Store(int ID,
// Constructor
char
*name,
char
*addr,
char
*city,
char *st,
char
*zip);
~Store();
// Destructor
int getStoreID();
// Get/Set
store ID
void setStoreID(int ID);
char *getStoreName();
// Get/Set store name
void setStoreName(char
*name);
char
*getStoreAddress(); // Get/Set store
address
void setStoreAddress(char
*addr);
char *getStoreCity();
// Get/Set store city
void setStoreCity(char
*city);
char *getStoreState();
// Get/Set store state
void setStoreState(char
*state);
char *getStoreZip();
// Get/Set store zip
code
void setStoreZip(char *zip);
void printStoreInfo();
// Print all info on this
store
};
Store.cpp
#include "Store.h"
#include
using namespace std;
Store::Store()
{
m_pNext = NULL;
}
Store::Store(int ID, char *name, char *addr, char *city, char *st,
char *zip)
{
m_iStoreID = ID;
strcpy(m_sStoreName, name);
strcpy(m_sAddress, addr);
strcpy(m_sCity, city);
strcpy(m_sState, st);
strcpy(m_sZip, zip);
m_pNext = NULL;
}
Store::~Store()
{
// Nothing to do here
}
int Store::getStoreID()
{
return m_iStoreID;
}
void Store::setStoreID(int ID)
{
m_iStoreID = ID;
}
char *Store::getStoreName()
{
char *name = new char[strlen(m_sStoreName) + 1];
strcpy(name, m_sStoreName);
return name;
}
void Store::setStoreName(char *name)
{
strcpy(m_sStoreName, name);
}
char *Store::getStoreAddress()
{
char *addr = new char[strlen(m_sAddress) + 1];
strcpy(addr, m_sAddress);
return addr;
}
void Store::setStoreAddress(char *addr)
{
strcpy(m_sAddress, addr);
}
char *Store::getStoreCity()
{
char *city = new char[strlen(m_sCity) + 1];
strcpy(city, m_sCity);
return city;
}
void Store::setStoreCity(char *city)
{
strcpy(m_sCity, city);
}
char *Store::getStoreState()
{
char *state = new char[strlen(m_sState) + 1];
strcpy(state, m_sState);
return state;
}
void Store::setStoreState(char *state)
{
strcpy(m_sState, state);
}
char *Store::getStoreZip()
{
char *zip = new char[strlen(m_sZip) + 1];
strcpy(zip, m_sZip);
return zip;
}
void Store::setStoreZip(char *zip)
{
strcpy(m_sZip, zip);
}
void Store::printStoreInfo()
{
cout << m_iStoreID << setw(20) <<
m_sStoreName << setw(15) << m_sAddress
<< setw(15) << m_sCity
<< ", " << m_sState << setw(10) << m_sZip
<< "\n";
}
Employee Record.h
#pragma once
#include "CustomerList.h"
class EmployeeRecord
{
private:
int m_iEmployeeID;
char m_sLastName[32];
char m_sFirstName[32];
int m_iDeptID;
double m_dSalary;
public:
CustomerList
*getCustomerList();
CustomerList
*m_pCustomerList;
//The default
constructor
EmployeeRecord();
EmployeeRecord(int ID, char *fName,
char *lName, int dept, double sal);
~EmployeeRecord();
int getID();
void setID(int ID);
void getName(char *fName, char *lName);
void setName(char *fName, char *lName);
int getDept();
void setDept(int d);
double getSalary();
void setSalary(double sal);
void printRecord();
};
Employee Record.cpp
#include
#include "EmployeeRecord.h"
#include "CustomerList.h"
using namespace std;
//Default Constructor
EmployeeRecord::EmployeeRecord()
{
// The default constructor shall set the member variables to the
following
m_iEmployeeID = 0;
m_sFirstName[0] = '\0';
m_sLastName[0] = '\0';
m_iDeptID = 0;
m_dSalary = 0.0;
}
EmployeeRecord::EmployeeRecord(int ID, char *fName, char *lName,
int dept, double sal)
{
strcpy(m_sFirstName, fName);
strcpy(m_sLastName, lName);
m_iEmployeeID = ID;
m_iDeptID = dept;
m_dSalary = sal;
fName = NULL;
lName = NULL;
}
// Default Desctrutor
EmployeeRecord::~EmployeeRecord()
{
delete m_pCustomerList;
}
int EmployeeRecord:: getID()
{
return m_iEmployeeID;
}
void EmployeeRecord::setID(int ID)
{
m_iEmployeeID = ID;
}
void EmployeeRecord::getName(char *fName, char *lName)
{
strcpy(fName, m_sFirstName);
strcpy(lName, m_sLastName);
}
void EmployeeRecord::setName(char *fName, char *lName)
{
strcpy(m_sFirstName, fName);
strcpy(m_sLastName, lName);
}
int EmployeeRecord::getDept()
{
return m_iDeptID;
}
void EmployeeRecord::setDept(int d)
{
m_iDeptID = d;
}
double EmployeeRecord::getSalary()
{
return m_dSalary;
}
void EmployeeRecord::setSalary(double sal)
{
m_dSalary = sal;
}
void EmployeeRecord::printRecord()
{
cout << "ID: " << m_iEmployeeID << "\t";
cout << "\tName: " << m_sLastName <<
" , " << m_sFirstName << "\t";
cout << "\tDept: " << m_iDeptID <<
"\t" << "\t";
cout << "Salary: $" << m_dSalary <<
"\t" << endl << endl;
}
CustomerList *EmployeeRecord::getCustomerList()
{
CustomerList *m_pCustomerList = new
CustomerList();
return m_pCustomerList;
}
MainProgram.cpp
#include
#include "EmployeeRecord.h"
#include
using namespace std;
int main()
{
int employee_id = 100, dept_id = 42, IDNum;
char fname [32];
char lname [32];
double salary = 65000;
double salaryp;
double *p_salary ;
salaryp = 65000;
p_salary = &salaryp;
//=========================================================================EmployeeRecord
Testing==========================================================================================
EmployeeRecord *Employee1 = new
EmployeeRecord(dept_id, fname, lname, dept_id, salary);
Employee1->setID(employee_id);
Employee1->setName("John", "Doe");
Employee1->setDept(42);
Employee1->setSalary(salary);
IDNum = Employee1-> getID();
Employee1->getName(fname,lname);
Employee1->getDept();
Employee1->getSalary();
if(IDNum == employee_id)
//Test Successful
if((strcmp(fname, "John") ==
0)&&(strcmp(lname,"Doe") == 0))
//Test Successful
if(dept_id == 42)
//Test Successful
if(*p_salary == salary)
//Test Successful
Employee1->printRecord();
Employee1->setID(456);
Employee1->setName("Jane", "Smith");
Employee1->setDept(45);
Employee1->setSalary(4000);
IDNum = Employee1-> getID();
Employee1->getName(fname,lname);
Employee1->getDept();
Employee1->getSalary();
if(IDNum == 456)
//Test Successful
if((strcmp(fname, "Jane") ==
0)&&(strcmp(lname,"Smith") == 0))
//Test Successful
if(dept_id == 45)
//Test Successful
if(*p_salary == 4000)
Employee1->printRecord();
//=====================================Customer List Testing====================================
cout
<<"\n==============================================================================================================="
<< endl;
cout <<" Adding stores to the list "
<< endl;
cout
<<"==============================================================================================================="
<< endl << endl;
CustomerList *cl = Employee1
->getCustomerList();
//----Testing the addStore, and printStoresInfo
functions:--------------------------------------
Store *s = new Store(4567,"A Computer Store", "1111
Main St." ,"West City" ,"Alabama", "12345");
Store *s1 = new Store(7654,"Jones Computers", "1234
Main St." ,"North City" ,"Alabama", "54321");
Store *s2 = new Store(1234, "Smith Electronics", "2222
2nd St." ,"Eastville", "Alabama","12346");
cout <<"Calling printStoresInfo() after adding
one store to list."<< endl;
cout
<<"\n==============================================================================================================="
<< endl;
cout << " Stores in List " <<
endl;
cout
<<"==============================================================================================================="
<< endl;
cl -> addStore(s);
cl -> printStoresInfo();
cout
<<"==============================================================================================================="
<< endl << endl;
cout <<"Calling printStoresInfo() after
adding second store to list."<< endl;
cout
<<"\n==============================================================================================================="
<< endl;
cout << " Stores in List " <<
endl;
cout
<<"==============================================================================================================="
<< endl;
cl -> addStore(s1);
cl -> printStoresInfo();
cout
<<"==============================================================================================================="
<< endl<< endl;
cout <<"Calling printStoresInfo() after adding
third store to list."<< endl;
cout
<<"\n==============================================================================================================="
<< endl;
cout << " Stores in List " <<
endl;
cout
<<"==============================================================================================================="
<< endl;
cl -> addStore(s2);
cl -> printStoresInfo();
cout
<<"==============================================================================================================="
<< endl << endl;
//---Testing the get store function:---------
Store *s3 = NULL;
s3=cl->getStore(1234);
if((s3 != NULL) && (s3->getStoreID() ==
1234))
cout << "Testing
getStore(1234)...successful" << endl;
Store *s4 = NULL;
s4=cl->getStore(7654);
if((s4 != NULL) && (s4->getStoreID() ==
7654))
cout << "Testing
getStore(7654)...successful" << endl;
cout << "Testing getStore(9999)..." <<
endl;
Store *s9 = NULL;
s9 = cl->getStore(9999);
if(s9 == NULL)
cout << "getStore() correctly
reported failure to find the store." << endl;
//-------------------------------------------
//---Testing updateStore Function:
----------------------------------------------------------------------
bool chk = cl->updateStore(1234, "hello", "1111
TestAddress", "TestCity", "TestState", "TestZip");
if(chk)
{
cout
<<"\n==============================================================================================================="
<< endl;
cout << " Stores in List " <<
endl;
cout
<<"==============================================================================================================="
<< endl;
cl ->printStoresInfo();
cout
<<"==============================================================================================================="
<< endl;
}
else
cout << "updateStore test
failed\n";
bool chk1 = cl -> updateStore(9999, "NoName", "1111 NoAddress", "NoCity", "NoState", "NoZip");
if(!chk1)
cout << "updateStore negative
test passed.\n";
else
cout << "updateStore negative
test failed.\n";
//---------------------------------------------------------------------------------------------------------
//--Testing the removeStore function-------------------------------------------------------------------------------------------------
Store *s5;
s5 = cl ->removeStore(4567);
if(s5 == NULL)
Store *s5 = cl -> removeStore(4567);
if(( s5 != NULL) &&
(s5->getStoreID() == 4567))
cout << "\nRemoving store 4567 from the
list...successful" << endl;
cout << "Calling printStoresInfo after deleting
a store from the head of the list." << endl;
cout
<<"==============================================================================================================="
<< endl;
cout << " Stores in List " <<
endl;
cout
<<"==============================================================================================================="
<< endl;
cl -> printStoresInfo();
cout
<<"==============================================================================================================="
<< endl << endl;
Store *s6;
s6 = cl ->removeStore(1234);
if(s6 == NULL)
Store *s6 = cl -> removeStore(1234);
if(( s6 != NULL) && (s6->getStoreID() ==
1234))
cout << "\nRemoving store 1234 from the
list...successful" << endl;
cout << "Calling printStoresInfo after deleting
a store from the head of the list." << endl;
cout
<<"==============================================================================================================="
<< endl;
cout << " Stores in List " <<
endl;
cout
<<"==============================================================================================================="
<< endl;
cl -> printStoresInfo();
cout
<<"==============================================================================================================="
<< endl << endl;
Store *s7;
s7 = cl ->removeStore(7654);
if(s7 == NULL)
Store *s7 = cl -> removeStore(7654);
if(( s7 != NULL) &&
(s7->getStoreID() == 7654))
cout << "\nRemoving store 7654 from the
list...successful" << endl;
cout << "Calling printStoresInfo after deleting
a store from the head of the list." << endl;
cout
<<"==============================================================================================================="
<< endl;
cout << " Stores in List " <<
endl;
cout
<<"==============================================================================================================="
<< endl;
cl -> printStoresInfo();
cout
<<"==============================================================================================================="
<< endl << endl;
//---------------------------------------------------------------------------------------------------------------------------------------
//---Testing the
destructor-----------------
EmployeeRecord *e = new
EmployeeRecord();
delete e;
//------------------------------------------
system ("pause");
return 0;
}
In: Computer Science
The syntax of a language is quite simple. The alphabet of the
language is {a, b, d, #} where # stands for a space. The grammar
is
<sentence> → <word> | <sentence> #
<word>
<word> → <syllable> | <syllable> <word>
<syllable>
<syllable> → <plosive> | <plosive> <stop> |
a <plosive> | a <stop>
<plosive> → <stop> a
<stop> → b | d
Which of the following speakers is an imposter? An impostor does
not follow the rules of the language.
a: ba#ababadada#bad#dabbada Chimp:
b: abdabaadab#ada
c: Baboon: dad#ad#abaadad#badadbaad
In: Computer Science
In GoogleCollab (Python)
In: Computer Science
add the following numbers using 16-bit 2's complement.
show all the steps and calculations.
Please also show steps to verify that the answer is correct.
2368 and -772
In: Computer Science
Need hep with this c++ program
Declare an array of integers of size 8 and initialize it with any non-duplicate integer values you like. Don’t enter the values in any order. Print the unsorted array. Sort the array using selection sort or insertion sort in descending order. Print what sort you are using. Write any additional functions that you need for sorting. Keep monitoring the number of comparisons and number of swaps performed while sorting. Report both after sorting. Print the sorted array.
In: Computer Science
JAVA
Design and implement a class called Boxthat represents a 3-dimensional box.1.Instance DataYour Box class will need variables to store the size of the box. All of these variables will be of type ‘private double’.•width•height•depthYour Boxclass will also need a variable to keep track of whether or not the box is full. This will be of type ‘private boolean’.•full2.ConstructorDeclaration: public Box( double width, double height, double depth)•Your Boxconstructor will accept the width, height,and depthof the box.•In your constructor, initialize the width, height,and depthinstance variables to values passed in as parameters to the constructor.•Each newly created box will be empty. This means that you will also need to initialize fullto false in your constructor.3.Getter and Setter MethodsInclude getter and setter methods for all instance data. We will assume that all supplied dimension values are positive values. Here is an example of the method declarations for width to get you started.•Getter: public double getWidth()•Setter: public void setWidth(double width)4.Public Methods•Write a public double volume()method that will calculate and return the volume of the box based on the instance data values.•Write a public double surfaceArea()method that will calculate and return the surface area of the box based on the instance data values.5.toString MethodWrite apublic String toString() method that returns a one-line description of the box. The description should provide its dimensions and whether or not the box is full. Format all double values to 2 decimal places.Example: An empty 4.00x 5.00 x 2.00 box.Part 2: Testing your ClassNow, create a driver class called BoxTestand do the following in the main method.Create your first box1.Create a Boxvariable called smallBoxand instantiate it with width 4, height 5, and depth 2.2.Print the one-line description of smallBoxusing its toString()method.3.Confirm that smallBox’s width, height, and depth getter methods are returning the correct values.4.Confirm that smallBox’s volume()and surfaceArea()methods are returning the correct values.5.Use smallBox’s setter methods to change it from “empty” to “full” and to change its dimension values to width 2, height 3, and depth 1.6.Print the one-line description of smallBoxusing toString()again, and confirm that all changed values are reflected.7.Confirm that all getter and other methods return the correct values reflecting smallBox’s current dimensions and full value.Create several boxes and find the largest oneDo not delete what you did above! Add the following code to the end of your BoxTestclass.1.Declare and instantiate an ArrayListobject that will store your Boxobjects.See the listing below as a sample of how to use the ArrayListbut with Stringobjects.2.In a standard “for” loop that iterates 5 times, create a new Boxwith randomly generated width, height, and depth and add the box to your ArrayList. Limit dimension values to a reasonable range. Randomly generate a Boolean value and use it to call the Box’s method for setting “full” (use the nextBoolean()method in the Randomclass).3.In the loop, print outthe Box’s details, labeled according to the loop iteration (i.e. if this isthe first iteration of the loop, label the box as “Box 1: “ in the output).4.Use a for-each loop(as shown in the listing above)to find the Boxwith the largest volume. You will need to declare a largest box variable of type Boxto keep track of the largest box. This variable needs to be declared outside of the loop so that it will still be available when the loop ends. Use conditional statements inside the loop to compare the current Box to the largest Box, so far, and update the largest box variable when appropriate.5.After the loop, print the details of the largest Box. Confirm that you program identified the correct boxes.
In: Computer Science
create a program that will calculate a student s grade in a class that uses a weighted gradebook
In: Computer Science
Question 3: Write the following Java program.
A. Create a class called Quadrilateral that contains the following: [4 Marks]
• Five double type data fields for: side1, side2, side3, side4, and perimeter
• A no-argument constructor that creates a Quadrilateral with all sides equal to 1
• Methods named setSide1(double s1), setSide2(double s2), setSide3(double s3), and
setSide4(double s4) to set the values of the four sides
• A method named calculatePerimeter( ) to calculate and return the perimeter of the
quadrilateral
B. Create a child class called Square that contains a method named calculateArea() to
calculate the area of the Square. [2 Marks]
C. Create a java main class named TestQuad to do the following: [4 Marks]
• Create a Quadrilateral object named Quad1 and a Square object named Sq1.
• Call the methods setSide1(double s1), setSide2(double s2), setSide3(double s3), and
setSide4(double s4) to:
o set the sides of Quad1 to 10, 20, 25, and 30, respectively
o set all sides of Sq1 to 3
• Display the perimeter of Quad1 by calling the method calculatePerimeter ( ). Display
the perimeter of Sq1 by calling the method calculatePerimeter ( ).
• Display the area of Sq1 by calling the method calculateArea()
Hint: Perimeter = sum of all sides & Area of Square = side * side
In: Computer Science
JAVA - Write a program that prompts the user (at the command line) for 4 positive integers, then draws a pie chart in a window. Convert the numbers to percentages of the numbers’ total sum; color each segment differently; use Arc2D. No text fields (other than the window title) are required. Provide a driver in a separate source file to test your class.
Please use the following:
java.lang.Object
java.awt.Graphics
java.awt.Graphics2D
Take note of the following:
setPaint
setStroke
fill
// imports
public class PieChartPanel extends JPanel {
// attributes
// constructor
public void paintComponent(Graphics g) {
super.paintComponent (g);
Graphics2D g2d = ( Graphics2D ) g;
...
}
There should be a paintComponent method that calls its parent
In: Computer Science