IN JAVA Inheritance Using super in the constructor Using super in the method Method overriding |
Write an application with five classes Vehicle, Car, Bus, Truck, and Tester class with main method in it.
The following characteristics should be used: make, weight, height, length, maxSpeed, numberDoors, maxPassenges, isConvertable, numberSeats, maxWeightLoad, and numberAxels.
Characteristics that are applicable to all vehicles should be instance variables in the Vehicle class. The others should be in the class(s) where they belong.
Class vehicle should have constructor that initializes all its data. Classes Car, Bus, and Truck will have constructors which will reuse their parents constructor and provide additional code for initializing their specific data.
Class Vehicle should have toString method that returns string representtion of all vehicle data. Classes Car, Bus, and Truck will override inherited toString method from class vehicle in order to provide appropriate string representation of all data for their classes which includes inherited data from Vehicle class and their own data.
Class Tester will instantiate 1-2 objects from those four classes (at least five total) and it will display the information about those objects by invoking their toString methods.
Submit one word document with code for all five classes, picture of program run from blueJ, and picture of UML diagram.
In: Computer Science
please i want solution for this question with algorithm and step by step with c++ language
In: Computer Science
list and discuss ten shortcomings of artificial neural networks
In: Computer Science
Introduction to Algorithms - Analysis of Algorithms
Solve the following recurrence relation: T(n) = T(an) + T((1 - a)n) + n
In: Computer Science
In: Computer Science
Complete the reading of NIST Special Publication 800-145 (2011).
NIST Definition of Cloud Computing, then branch out into Internet
research on how the term “Cloud Computing” has evolved and what it
means now. You can talk about how cloud services are increasingly
relevant to businesses today. Feel free to use an example for
Infrastructure as a Service (IaaS) or Software as a Service (Saas)
and talk about why companies are moving their onsite infrastructure
to the cloud in many cases. Think Microsoft Azure, Amazon Web
Services, Rackspace, or any number of cloud providers.
Go ahead and have a little fun with it if you like also: Pretend
you are an IT manager and need to recommend a solution for moving a
piece of software or hardware into the cloud. What provider would
you use and why? Or would you instead recommend keeping
servers/software in house?
You must post your initial response (with APA 6th ed or higher
references) before being able to review other students' responses.
Once you have made your first response, you will be able to reply
to other students’ posts. You are expected to make a minimum of 3
responses to your fellow students' posts.
In: Computer Science
What would have to be changed in the code if the while statement were changed to:
while (menu == 5);
Code is as follows
#include <stdio.h>
void printHelp ()
{
printf ("\n");
printf ("a: a(x) = x*x\n");
printf ("b: b(x) = x*x*x\n");
printf ("c: c(x) = x^2 + 2*x + 7\n");
printf ("d: shrink(x) = x/2\n");
printf ("q: quit\n");
}
void a(float x)
{
float v = x*x;
printf (" a(%.2f) = %.2f^2 = %.2f\n", x, x, v);
} // end function a
void b(float x)
{
float v = x*x*x;
printf (" b(%.2f) = %.2f^3 = %.2f\n", x, x, v);
} // end function b
void c(float x)
{
float v = x*x + 2*x + 7;
printf (" c(%.2f) = %.2f^2 + 2*%.2f + 7 = %.2f\n",
x, x, x, v);
} // end function c
void shrink(float x){
float v = x/2;
printf("shrink(%.2f) = %.2f/2 = %.2f\n", x, x, v);
}//end of function shrink
int menu ()
{
char selection;
float x;
printHelp ();
scanf ("%s", &selection);
if (selection == 'q')
return 1;
scanf ("%f", &x);
if (selection == 'a')
a(x);
if (selection == 'b')
b(x);
if (selection == 'c')
c(x);
if(selection == 'd')
shrink(x);
return 0;
} // end function menu
int main()
{
while (menu() == 0);
printf ("... bye ...\n");
return 0;
} // end main
In: Computer Science
Database Management Systems
IT344 -Fundamentals Of Database Systems book
Please Use your own words .
sorry No handwriting
no copy paste
Construct a B+ tree for the following set of key values under the assumption that the number of key values that fit in a node is 3.
Key values (3,10,12,14,29,38,45,55,60,68,11,30)
Show the step involved in inserting each key value.
thank you for your time and effort
In: Computer Science
In JAVA answer has to be able to do exact Sample Output shown
Write a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop should ask the user whether he or she wishes to perform the operation again. If so, the loop should repeat; otherwise it should terminate. Name your class as NumberSum and add to it your header and sample output as a block comments. Upload the NumberSum.java file to this link.
Sample output:
Enter a number: 1 Enter another number: 2 Their sum is 3.0 Do you wish to do this again? (Y/N) y Enter a number: 5 Enter another number: 9 Their sum is 14.0 Do you wish to do this again? (Y/N) n
In: Computer Science
A thief robbing a store can carry a maximum weight of W in their knapsack. There are n items and ith item weighs wi and is worth vi dollars. What items should the thief take to maximize the value of what is stolen?
The thief must adhere to the 0-1 binary rule which states that only whole items can be taken. The thief is not allowed to take a fraction of an item (such as ½ of a necklace or ¼ of a diamond ring). The thief must decide to either take or leave each item.
Develop an algorithm using Java and developed in the Cloud9 environment (or your own Java IDE) environment to solve the knapsack problem.
Your algorithms should use the following data as input.
Maximum weight (W) that can be carried by the thief is 20 pounds
There are 16 items in the store that the thief can take (n = 16). Their values and corresponding weights are defined by the following two lists.
Item Values: 10, 5, 30, 8, 12, 30, 50, 10, 2, 10, 40, 80, 100, 25, 10, 5
Item Weights: 1, 4, 6, 2, 5, 10, 8, 3, 9, 1, 4, 2, 5, 8, 9, 1
Your solution should be based upon dynamic programming principles as opposed to brute force.
The brute force approach would be to look at every possible combination of items that is less than or equal to 20 pounds. We know that the brute force approach will need to consider every possible combination of items which is 2n items or 65536.
The optimal solution is one that is less than or equal to 20 pounds of weight and one that has the highest value. The following algorithm is a ‘brute force’ solution to the knapsack problem. This approach would certainly work but would potentially be very expensive in terms of processing time because it requires 2n (65536) iterations
The following is a brute force algorithm for solving this problem. It is based upon the idea that if you view the 16 items as digits in a binary number that can either be 1 (selected) or 0 (not selected) than there are 65,536 possible combinations. The algorithm will count from 0 to 65,535, convert this number into a binary representation and every digit that has a 1 will be an item selected for the knapsack. Keep in mind that not ALL combinations will be valid because only those that meet the other rule of a maximum weight of 20 pounds can be considered. The algorithm will then look at each valid knapsack and select the one with the greatest value.
import java.lang.*;
import java.io.*;
public class Main {
/**
* @param args the command line
arguments
*/
public static void main(String[] args) {
int a, i, k, n, b,
Capacity, tempWeight, tempValue, bestValue, bestWeight;
int remainder,
nDigits;
int Weights[] = {1, 4,
6, 2, 5, 10, 8, 3, 9, 1, 4, 2, 5, 8, 9, 1};
int Values[] = { 10, 5,
30, 8, 12, 30, 50, 10, 2, 10, 40, 80, 100, 25, 10, 5 };
int A[];
A = new int[16];
Capacity = 20; // Max
pounds that can be carried
n = 16; // number of
items in the store
b=0;
tempWeight = 0;
tempValue = 0;
bestWeight = 0;
bestValue = 0;
for ( i=0; i<65536; i++) {
remainder = i;
// Initialize array to all 0's
for ( a=0; a<16; a++) {
A[a] = 0;
}
// Populate binary representation of counter i
//nDigits = Math.ceil(Math.log(i+0.0));
nDigits = 16;
for ( a=0; a<nDigits; a++ ) {
A[a] = remainder % 2;
remainder = remainder / 2;
}
// fill knapsack based upon binary representation
for (k = 0; k < n; k++) {
if ( A[k] == 1) {
if (tempWeight + Weights[k] <= Capacity) {
tempWeight = tempWeight + Weights[k];
tempValue = tempValue + Values[k];
}
}
}
// if this knapsack is better than the last one, save it
if (tempValue > bestValue) {
bestValue = tempValue;
bestWeight = tempWeight;
b++;
}
tempWeight = 0;
tempValue = 0;
}
System.out.printf("Weight: %d Value %d\n", bestWeight,
bestValue);
System.out.printf("Number of valid knapsack's: %d\n", b);
}
}
The brute force algorithm requires 65,536 iterations (216) to run
and returns the output defined below. The objective of this
assignment will be to develop a java algorithm designed with
dynamic programming principles that reduces the number of
iterations. The brute force algorithm requires an
algorithm with exponential 2n complexity where O(2n). You must
create a dynamic programming algorithm using java to solve the
knapsack problem. You must run your algorithm using Java and post
the results. You results must indicate the Weight of
the knapsack, the value of the contents, and the number of
iterations just as illustrated in the brute force output
below. You must also include a description of the Big O
complexity of your algorithm.
Output from the Brute Force Algorithm.
Weight: 20
Value: 280
Number of valid knapsack's: 45
For a hint on the dynamic programming approach see the
following:
The basic idea behind the dynamic programming approach: Compute the
solutions to the sub-problems once and store the solutions in a
table, so that they can be reused (repeatedly) later.
http://www.es.ele.tue.nl/education/5MC10/Solutions/knapsack.pdf
Some of these algorithms may take a long time to execute. If you have access to a java compiler on your local computer or the Virtual Computing Lab, you may want to test your code by running it and executing it with java directly as it can speed up the process of getting to a result. You should still execute your code within Java to get an understanding of how it executes. (To compile with java use the javac command. To run a compiled class file, use the java command)
In: Computer Science
Constructing Data Flow Diagrams: ATM Machine To start an ATM Withdrawal: • A card is inserted in the slot by the user, and the PIN (personal identification number) is entered. • The ATM reads information from the card, in particular, the card number and the expiry date, and accepts the PIN from the keyboard input. • The card is verified for expiry date, and then if valid, the card number and the PIN are sent to the bank for card validation by communication circuit. • The bank either sends confirmation or refusal. If confirmation is received, the user is invited to enter a transaction type. • Assuming that the transaction is a withdrawal of cash, one more validation is performed by the bank to check that the amount nominated is below or equal to the daily limit for withdrawals of 1000 AED, that the user’s weekly withdrawals do not exceed the weekly limit of 5000 AED, and that the account balance is in credit to cover the withdrawal. • If all these are OK the card is returned, the money is dispensed, and the withdrawal receipt is printed, with the date, account number, withdrawal amount and account balance. • The bank’s account records are updated to reflect the transaction. Based on the previous scenario, create the following:
a) Create a Context diagram
b) Create level zero DFD diagram
c) Select one process from level zero and develop it into level 1 diagram.
In: Computer Science
Remarks: In all algorithm, always explain how and why they work. If not by a proof, at least by a clear explanation. ALWAYS, analyze the running time complexity of your algorithms. In all algorithms, always try to get the fastest possible. A correct algorithm with slow running time may not get full credit. Do not write a program. Write pseudo codes or explain in words
Question 1: Say that we want to maintain both a Queue and a Priority Queue. This means that when you do Enqueue you also add the item to the Priority Queue and when you do Dequeue you also remove the item from the Priority Queue. And vise-versa. Show how to do it.
In: Computer Science
Three Patterns Given two numbers N and K, output three squares with the size N × N each with their own set of rules:
• The first square is made entirely using the ‘#’ symbol.
• The second square is made using the ‘.’ symbol except for every K rows use the ‘#’ symbol instead. • The third square is made using the ‘.’ symbol except for every K columns use the ‘#’ symbol instead.
Also print new line (\n) after printing each square. Look at sample input/output for more clarity.
Format Input The input consists of one line containing two numbers N and K.
Format Output The output consists of three squares with the size N × N according to the rules stated above. Don’t forget to print new line after printing each square!
Constraints
• 1 ≤ N, K ≤ 100
Sample Input 1 (standard input) :
5 2
Sample Output 1 (standard output):
#####
#####
#####
#####
#####
.....
#####
.....
#####
.....
.#.#.
.#.#.
.#.#.
.#.#.
.#.#.
Sample Input 2 (standard input):
9 3
Sample Output 2 (standard output):
#########
#########
#########
#########
#########
#########
#########
#########
#########
.........
.........
#########
.........
.........
#########
.........
.........
#########
..#..#..#
..#..#..#
..#..#..#
..#..#..#
..#..#..#
..#..#..#
..#..#..#
..#..#..#
..#..#..#
Sample Input 3 (standard input):
1 3
Sample Output 3 (standard output):
#
.
.
Note: Use long long int and c language
In: Computer Science
Using 64-bit IEEE 754 DOUBLE precision floating point with one(1) sign bit, eleven (11) exponent bits and fifty-two (52) mantissa bits, what is the decimal value of: 0xBFE4000000000000
In: Computer Science
*OBJECT ORIENTED PROGRAMMING*
*JAVA PROGRAMMING*
Create a program that simulates a race between several vehicles.
Details don't matter code must just have the following:
In: Computer Science