1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
irga5000 [103]
3 years ago
12

Write out an algorithm where you know the cost of an item, the state tax rate on it; the federal tax rate on it; and the money a

customer gives you. Write out steps and formulas it takes to solve You will calculate and output to the customer the change you will to give them.
Computers and Technology
1 answer:
Dmitry_Shevchenko [17]3 years ago
8 0

Answer:

Algorithm:

1. Declare variables "cost","state_tax" and "federal_tax".

2.Initialize these variables.

3.Create a variable "cust_money".

   3.1 Ask user to give money.

   3.2 Assign this to "cust_money".

4. Calculate total_tax=state_tax+federal_tax

   4.1 Calculate total_to_be_paid=cost(1+total_tax)

5. Calculate change_to_give= cust_money-total_to_be_paid

6.Print the change_to_give

7. End the program.

Explanation:

Declare variables and initialize "cost"  with initial cost of item, "state_tax" with  state tax and "federal_tax"  with federal tax on the item. Ask user to give money and assign it  to "cust_money". calculate the total tax=state+federal tax. Then calculate the total to be paid for item as cost*(1+total tax). Subtract the total paid from customer money and print the change to give user.

You might be interested in
A _____ is a collection of binary digits, including message data and control characters for formatting and transmitting, sent fr
Keith_Richards [23]

Answer:

Packet

Explanation:

8 0
3 years ago
Please answer this please
dexar [7]

Answer:

It's not a question.

Explanation:

3 0
4 years ago
What effects convert colors in a picture to a wide variety of hues?
nadezda [96]
I believe it's color saturation.
3 0
3 years ago
Help its timed :plzzzzzz<br> fjndf,xn
Lerok [7]

Answer:

Please find attached the diagram of the different thrust of the spaceship created with Microsoft Visio with the numbers representing the following situations

(1) Thrust is less than weight. The spaceship does not launch

(2) Thrust is just a little greater than weight. The net force gives the spacecraft acceleration up, but not enough to gain the speed needed to reach orbit

(3) Thrust is greater than weight. The net force gives the spacecraft acceleration up. It gains enough speed to "fall around" Earth, constantly moving in a nearly circular path

(4) Thrust is a lot greater than weight. The very large net force gives the spacecraft a very large acceleration up. It gains so much speed that it escapes Earth

Explanation:

1) The thrust F < Weight = Mass of spacecraft, m × The acceleration due to gravity, g

F < W = m × g, the spacecraft remains on the Earth surface

2) The thrust, F > W, The space craft has an initial upwards acceleration, given by (F - W)/m

v < v_{orbit} \ Orbital \ velocity =\sqrt{\dfrac{G \cdot M}{r} }

3) F > W and  v  =v_{orbit} = \sqrt{\dfrac{G \cdot M}{r} }

4)  F > W and  v  \geq v_{esc} = \sqrt{\dfrac{2 \cdot G \cdot M}{r} }

4 0
3 years ago
Define a class called TreeNode containing three data fields: element, left and right. The element is a generic type. Create cons
m_a_m_a [10]

Answer:

See explaination

Explanation:

// Class for BinarySearchTreeNode

class TreeNode

{

// To store key value

public int key;

// To point to left child

public TreeNode left;

// To point to right child

public TreeNode right;

// Default constructor to initialize instance variables

public TreeNode(int key)

{

this.key = key;

left = null;

right = null;

key = 0;

}// End of default constructor

}// End of class

// Defines a class to crate binary tree

class BinaryTree

{

// Creates root node

TreeNode root;

int numberElement;

// Default constructor to initialize root

public BinaryTree()

{

this.root = null;

numberElement = 0;

}// End of default constructor

// Method to insert key

public void insert(int key)

{

// Creates a node using parameterized constructor

TreeNode newNode = new TreeNode(key);

numberElement++;

// Checks if root is null then this node is the first node

if(root == null)

{

// root is pointing to new node

root = newNode;

return;

}// End of if condition

// Otherwise at least one node available

// Declares current node points to root

TreeNode currentNode = root;

// Declares parent node assigns null

TreeNode parentNode = null;

// Loops till node inserted

while(true)

{

// Parent node points to current node

parentNode = currentNode;

// Checks if parameter key is less than the current node key

if(key < currentNode.key)

{

// Current node points to current node left

currentNode = currentNode.left;

// Checks if current node is null

if(currentNode == null)

{

// Parent node left points to new node

parentNode.left = newNode;

return;

}// End of inner if condition

}// End of outer if condition

// Otherwise parameter key is greater than the current node key

else

{

// Current node points to current node right

currentNode = currentNode.right;

// Checks if current node is null

if(currentNode == null)

{

// Parent node right points to new node

parentNode.right = newNode;

return;

}// End of inner if condition

}// End of outer if condition

}// End of while

}// End of method

// Method to check tree is balanced or not

private int checkBalance(TreeNode currentNode)

{

// Checks if current node is null then return 0 for balanced

if (currentNode == null)

return 0;

// Recursively calls the method with left child and

// stores the return value as height of left sub tree

int leftSubtreeHeight = checkBalance(currentNode.left);

// Checks if left sub tree height is -1 then return -1

// for not balanced

if (leftSubtreeHeight == -1)

return -1;

// Recursively calls the method with right child and

// stores the return value as height of right sub tree

int rightSubtreeHeight = checkBalance(currentNode.right);

// Checks if right sub tree height is -1 then return -1

// for not balanced

if (rightSubtreeHeight == -1) return -1;

// Checks if left and right sub tree difference is greater than 1

// then return -1 for not balanced

if (Math.abs(leftSubtreeHeight - rightSubtreeHeight) > 1)

return -1;

// Returns the maximum value of left and right subtree plus one

return (Math.max(leftSubtreeHeight, rightSubtreeHeight) + 1);

}// End of method

// Method to calls the check balance method

// returns false for not balanced if check balance method returns -1

// otherwise return true for balanced

public boolean balanceCheck()

{

// Calls the method to check balance

// Returns false for not balanced if method returns -1

if (checkBalance(root) == -1)

return false;

// Otherwise returns true

return true;

}//End of method

// Method for In Order traversal

public void inorder()

{

inorder(root);

}//End of method

// Method for In Order traversal recursively

private void inorder(TreeNode root)

{

// Checks if root is not null

if (root != null)

{

// Recursively calls the method with left child

inorder(root.left);

// Displays current node value

System.out.print(root.key + " ");

// Recursively calls the method with right child

inorder(root.right);

}// End of if condition

}// End of method

}// End of class BinaryTree

// Driver class definition

class BalancedBinaryTreeCheck

{

// main method definition

public static void main(String args[])

{

// Creates an object of class BinaryTree

BinaryTree treeOne = new BinaryTree();

// Calls the method to insert node

treeOne.insert(1);

treeOne.insert(2);

treeOne.insert(3);

treeOne.insert(4);

treeOne.insert(5);

treeOne.insert(8);

// Calls the method to display in order traversal

System.out.print("\n In order traversal of Tree One: ");

treeOne.inorder();

if (treeOne.balanceCheck())

System.out.println("\n Tree One is balanced");

else

System.out.println("\n Tree One is not balanced");

BinaryTree

BinaryTree treeTwo = new BinaryTree();

treeTwo.insert(10);

treeTwo.insert(18);

treeTwo.insert(8);

treeTwo.insert(14);

treeTwo.insert(25);

treeTwo.insert(9);

treeTwo.insert(5);

System.out.print("\n\n In order traversal of Tree Two: ");

treeTwo.inorder();

if (treeTwo.balanceCheck())

System.out.println("\n Tree Two is balanced");

else

System.out.println("\n Tree Two is not balanced");

}// End of main method

}// End of driver class

5 0
4 years ago
Other questions:
  • Which software application should be used to communicate in writing about an upcoming event?
    12·2 answers
  • If you want to store the information that a user types in response to the input() function, what do you need to do? (select the
    11·1 answer
  • What is the only language a microprocessor can process directly but most programmers almost never write programs in this code? Q
    12·2 answers
  • Select the online reading comprehension tool that best fits the description. This tool lets users change text from one language
    6·2 answers
  • Write a function to prompt the user to enter the information for one movie (title, release date, mpaa rating and number of stars
    8·1 answer
  • What is the different between information and data
    5·1 answer
  • Help! What is this graph and what does it represent?
    12·1 answer
  • Create an application named SalesTransactionDemo that declares several SalesTransaction objects and displays their values and th
    12·1 answer
  • When you started the vi editor, you forgot to specify the name for the new file you are creating. To save steps next time, how c
    14·1 answer
  • The user can close all the programs if he closes the open virtual desktop true false
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!