Questions
JAVA - Write a program that prompts the user (at the command line) for 4 positive...

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

Computer Science Multiple Choice: Please complete all 5 questions in exchange for an immediate upvote. Incomplete...

Computer Science Multiple Choice: Please complete all 5 questions in exchange for an immediate upvote. Incomplete answers will be downvoted so please move on if they aren't worth your time. Thank you!

  1. A node that is the root of a balanced tree is called a(n) _____ node.
    1. balanced
    2. master
    3. search
    4. AVL
  2. When there is an addition to a node’s right subtree that creates an unbalanced search tree, you can correct it with a(n)
    1. left rotation
    2. right rotation
    3. reheap
    4. sift up
  3. What type of rotation do you need to rebalance an AVL tree if the addition that unbalanced the tree occurred in the left subtree of node N, the unbalanced node’s left child?
    1. left rotation
    2. right rotation
    3. right-left rotation
    4. left-right rotation
  4. What type of rotation do you need to rebalance an AVL tree if the addition that unbalanced the tree occurred in the right subtree of node N, the unbalanced node’s left child?
    1. left rotation
    2. right rotation
    3. right-left rotation
    4. left-right rotation
  5. What type of rotation do you need to rebalance an AVL tree if the addition that unbalanced the tree occurred in the left subtree of node N, the unbalanced node’s right child?
    1. left rotation
    2. right rotation
    3. right-left rotation
    4. left-right rotation

In: Computer Science

Note: The built-in character analysis functions (isdigit(), islower(), etc.) may not be used. Exercise 6.1 Write...

Note: The built-in character analysis functions (isdigit(), islower(),
etc.) may not be used.

Exercise 6.1 Write to an output file
Open an output file (stream) and write your identifying information to the
associated output file using a function. Put your standard output informa-
tion in a function named ShowHeader(). The file stream must be passed by
reference to the function. To do this, an & (ampersand) is used between the
data type (ofstream) and the name of the argument (I like to use fOut for
output file stream objects and fIn for input file stream object names).

Exercise 6.2 Read from an input file
Read/Process an input file a character at a time. Open an input file (stream)
and read a single character on each pass through a loop (a while() loop is
probably easiest) until the end of file is reached. After reading the character,
write it to the output file created earlier. The output should contain the
same characters as the input file.

Exercise 6.3 Character Analysis
Suggestion: Develop the remainder of this program in piecewise manner–
specifically, add one character analysis operation at a time, before adding
the next.
Analyze the characters in a file using functions to display their charac-
teristics, e.g., lower case, digit etc. The logic for analysis will be inside the
loop above.
Specifically, test if the character:
• is a letter.
• test if it is lower case or upper case.
• if the character is a letter, test if it is a vowel or consonant.
• is a digit.
• if the character is a digit, test if the value is odd or even.
• is a punctuation character.
• is a logical operator symbol.
Write a short function for most operations in the list above. If a character
is a letter, then it is either upper or lower case, so we only need to write one
function to test the case of the character. Do not use the built-in functions.

Note: there are no I/O (input/output) operations in the functions, only a
single character is examined.

In: Computer Science

Describe a simple SIMD architecture for “Image processing” application.

Describe a simple SIMD architecture for “Image processing” application.

In: Computer Science

Hi I have an assignment that has this question basis on network protocols (multiple access protocols):...

Hi

I have an assignment that has this question basis on network protocols (multiple access protocols):

Q1 ) Explain why collision is an issue in random access protocols but not in channelization protocols?

I need an explanision for that question

In: Computer Science

Discuss in what areas of your organization, or an organization you are familiar with, should conduct...

Discuss in what areas of your organization, or an organization you are familiar with, should conduct association analysis. With what data objects should the organization attempt to discover relationships to other data objects. What would be the business benefits of uncovering these relationships?

In: Computer Science

Experiment with a simple derivation relationship between two classes. Put println statements in constructors of both...

Experiment with a simple derivation relationship between two classes. Put println statements in constructors of both the parent and child classes. Do not explicitly call the constructor of the parent in the child. What happens? Why? Change the child’s constructor to explicitly call the constructor of the parent. Now what happens?

In: Computer Science

What would be the system objectives of an early learning(1st – 3rd grade) website? Please list...

What would be the system objectives of an early learning(1st – 3rd grade) website? Please list at least 10.

In: Computer Science

Topic: Database Design - Entity Relationship Modeling (Please answer the below question in 250 words or...

Topic: Database Design - Entity Relationship Modeling (Please answer the below question in 250 words or more). Thank you!

If you have an entity with 100 different attributes, what would be some strategies to model this entity? Why/Why not would you want to use a single entity? What are some questions you would want to know about the individual attributes?

In: Computer Science

I get an error in my code, here is the prompt and code along with the...

I get an error in my code, here is the prompt and code along with the error.

Write a spell checking program (java) which uses a dictionary of words (input by the user as a string) to find misspelled words in a second string, the test string. Your program should prompt the user for the input string and the dictionary string. A valid dictionary string contains an alphabetized list of words.

Functional requirements:

  1. For each word in the input string, your program should search the dictionary string for the given word. If the word is not in the dictionary, you program should print the message "Unknown word found" to standard output.
  2. After traversing the entire input string, your program should print a message describing the total number of misspelled words in the string.
  3. A dictionary string may contain words in uppercase, lowercase, or a mixture of both. The test string may also combine upper and lower case letters. You program should recognize words regardless of case. So if "dog" is in the dictionary string, the word "dOG" should be recognized as a valid word. Similarly, if "CaT" is in the dictionary string, the word "cat" she be recognized as a valid word.
  4. Within a string, a word is a white-space delimited string of characters. So the last word in "Hello world!" is "world!".

CODE:

dictionary.java

import java.io.*;
import java.util.*;

public class dictionary
{
public static void main(String args[]) throws Exception
{
     
  
   String dString;
   String uString;
  
   Scanner input=new Scanner(System.in);
  
   System.out.println("Enter distionary string :");
  
   dString = input.nextLine();
  
   System.out.println("Enter input string :");
  
   uString = input.nextLine();
  
   String[] dict = dString.split(" ");//split dictionay string and save to array fo string
  
   boolean found = false;
  
   //ieterate over dictionary string array
   for (String a : dict)
   {
       //compare and print message accordingly       
       if((uString.toLowerCase().compareTo(a.toLowerCase())) == 0)
       {
   System.out.println("word found!");
           found = true;
           break;
       }
   }
  
   if(found == false)
   {
       System.out.println("Unknown word found!");
   }
  
  
  
}
}

ERROR:

Main.java:4: error: class dictionary is public, should be declared in a file named dictionary.java
public class dictionary
^
1 error
compiler exit status 1

In: Computer Science

Using only <iostream>, implement a dynamic array. You are to build a class called MyDynamicArray. Your...

Using only <iostream>, implement a dynamic array. You are to build a class called MyDynamicArray. Your dynamic array class should manage the storage of an array that can grow and shrink. The public methods of your class should be the following:

MyDynamicArray(); Default Constructor. The array should be of size 2.

MyDynamicArray(int s); For this constructor the array should be of size s.

~MyDynamicArray();Destructor for the class.

int& operator[](int i); Traditional [] operator. Should print a message if i is out of bounds and return a reference to a zero value.

void add(int v); increases the size of the array by 1 and stores v there.

void del(); reduces the size of the array by 1.

int length(); returns the length of the array.

int clear(); Frees any space currently used and starts over with an array of size 2.

Here is a sample main.cpp file:
#include <iostream>
using namespace std;
#include "MyDynamicArray.cpp"
int main() {
MyDynamicArray x;
for (int i=0; i<100; i++){
x.add(i);
}
int sum = 0;
for (int i=0; i<x.length(); i++){
sum+=x[i];
}
cout << "The sum is : " << sum << endl;
for (int i=0; i<95; i++)
x.del();
x[60] = 27;

MyDynamicArray y(10);
for (int i=0; i<y.length(); i++) y[i] = i*i;
for (int i=0; i<200; i++){
y.add(i);
}
sum = 0;
for (int i=0; i<y.length(); i++){
sum+=y[i];
}
cout << "The sum is : " << sum << endl;
for (int i=0; i<195; i++)
y.del();
y[60] = 27;
for (int i=0; i<200; i++){
y.add(i);
}
sum = 0;
for (int i=0; i<y.length(); i++){
sum+=y[i];
}
cout << "The sum is : " << sum << endl;

}
Here is the output from the main.cpp above :
Doubling to : 4
Doubling to : 8
Doubling to : 16
Doubling to : 32
Doubling to : 64
Doubling to : 128
The sum is : 4950
Reducing to : 64
Reducing to : 32
Reducing to : 16
Out of bounds reference : 60
Doubling to : 20
Doubling to : 40
Doubling to : 80
Doubling to : 160
Doubling to : 320
The sum is : 20185
Reducing to : 160
Reducing to : 80
Reducing to : 40
Out of bounds reference : 60
Doubling to : 80
Doubling to : 160
Doubling to : 320
The sum is : 20195

In: Computer Science

How would you describe Structure of Management Information (SMI)? Also justify, how it is useful for...

How would you describe Structure of Management Information (SMI)? Also justify, how it is useful for a managed object?

In: Computer Science

Introduction to IS & IT IT101 What problems are caused by data redundancy? Can data redundancies...

Introduction to IS & IT

IT101

What problems are caused by data redundancy? Can data redundancies be completely eliminated when the database approach is used? Justify your answer in your own words.

In: Computer Science

You will write several classes for this program in Java. The name of all classes for...

You will write several classes for this program in Java. The name of all classes for this program will start with y2y3.

Concepts to be applied :

Classes and objects, inheritance, polymorphism

Assignment:

An electronic store, named carrefoure, services many customers. The customers’ orders for electronics are delivered. Carrefoure bills their customers once each month. At the end of each month, the regional store manager requests a report of all customers. In this program, you will develop the inheritance hierarchy for the program. The set of classes developed for the program will be used for future assignments.

            The superclass for this assignment will represent a Customer of Carrefoure.

            Some of the Customers will be tax exempt customers (will not pay taxes on the) but others will be non tax exempt customers (will pay tax on the bill balance at a given percent).

            The fields are the instance variables of the classes in the hierarchy:

  • Customer name (String)
  • Customer ID (numeric integer)

o            phone number (numeric integer)

o            Amount paid (numeric)

o            Reason for tax exemption (only for tax-exempt-customers) – String, for example: education, non-profit, etc

o            Tax percent (only for non-tax-exempt customers) – decimal, for example: .08 for 8%, .075 for 7.5%

The customers served by careffoure are of two types: tax-exempt or non-tax-exempt. The tax-exempt customer will have an instance field to store the reason for the tax exemptions: education, non-profit, government, other (String). The non-tax exempt customers, will have an instance field to store the percent of tax that the customer will pay (numeric) on the bill balance.

From the information provided, write a solution that includes the following:

A suitable inheritance hierarchy which represents the customers serviced by the office supply company. There should be 3 classes for this program. I suggest a Customer class and two suitable subclasses. The tax percent field only applies for a non-tax exempt customer. The reason for tax exemption only applies to a tax exempt customer.  

            For all classes include the following:

o            Instance variables

o            Constructors

o            Accessor and mutator methods

o            Suitable toString() methods

Write a class y2y3 which does the following in the main method:

            Create two objects for customers who are tax exempt and create two objects for customers who are non-tax exempt.

            Print all the information about the objects as shown below:

Output:

Non tax exempt customers:

1 PWC   $750   18002500830     0.08%   $60

2 E&Y   $970    18003409845     0.08%   $77.6

Tax exempt customers:

3 AHS   $255.50     19734508345             Non-profit

4 PIO      $500        18002708855           Non-profit

In: Computer Science

Use python. DO NOT use pres existing libraries. Suppose there exists a text file called "expressions.txt"....

Use python. DO NOT use pres existing libraries. Suppose there exists a text file called "expressions.txt". This file contains simple arithmetic expressions written in infix notation. Using the Stack class, write code to implement the Shunting Yard Algorithm to generate postfix expressions. Each expression in expressions.txt is written on a single line. Moreover, each expression contains only numbers comprising a single digit. Each token is separated by whitespace. Write each postfix expression generated to a file "answers.txt". Only consider the operations +, -, /, *, and ^.

In: Computer Science