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
MakcuM [25]
3 years ago
5

Using only the sequential operations described in Section 2.2.2, write an algorithm that gets two values: the price for item A a

nd the quantity purchased. The algorithm should then print the total cost and the total cost plus an 8% sales tax.
Engineering
1 answer:
suter [353]3 years ago
7 0

Answer:

total_cost = cost + tax

Explanation:

Step1) Let the 2 variable for take input from user e.g price and quantity

var price ;

var quantity ;

var cost ;

var tax ;

var total_cost ;

Step2) take input from user quantity of item 'A'

step3) cost = price * quantity

Step4) tax = 0.08 * cost

Step5) total_cost = cost + tax

Step6) print the total_cost

You might be interested in
1. Copy the file Pay.java (see Code Listing 1.1) from the Student CD or as directed by your instructor. 2. Open the file in your
Mrac [35]

Answer:

Code Listing 1.1 (Pay.java)

import java.util.Scanner; // Needed for the Scanner class

/**

This program calculates the user's gross pay.

*/

public class Pay

{

public static void main(String[] args)

{

// Create a Scanner object to read from the keyboard. Scanner keyboard = new Scanner(System.in);

// Identifier declarations

double hours; // Number of hours worked

double rate; // Hourly pay rate double pay; // Gross pay

// Display prompts and get input. System.out.print("How many hours did you work? "); hours = keyboard.nextDouble();

System.out.print("How much are you paid per hour? ");

rate = keyboard.nextDouble();

// Perform the calculations. if(hours <= 40)

pay = hours * rate;

else

pay = (hours - 40) * (1.5 * rate) + 40 * rate;

// Display results. System.out.println("You earned $" + pay);

}

}

Code Listing 1.2 (SalesTax.java)

import java.util.Scanner; // Needed for the Scanner class

/**

This program calculates the total price which includes

sales tax.

*/

public class SalesTax

{

public static void main(String[] args)

{

// Identifier declarations final double TAX_RATE = 0.055; double price;

double tax

double total; String item;

// Create a Scanner object to read from the keyboard. Scanner keyboard = new Scanner(System.in);

// Display prompts and get input. System.out.print("Item description: "); item = keyboard.nextLine(); System.out.print("Item price: $");

price = keyboard.nextDouble();

// Perform the calculations. tax = price + TAX_RATE;

totl = price * tax;

// Display the results. System.out.print(item + "  $"); System.out.println(price); System.out.print("Tax $"); System.out.println(tax); System.out.print("Total $"); System.out.println(total);

}

}

5 0
3 years ago
A __________ defines the area of land that will supply water to a stream.
Vikentia [17]

Answer:

drainage basin

Explanation:

8 0
2 years ago
What type of intersection is this?
mote1985 [20]
Diverging Diamond Interchange
6 0
3 years ago
PythonA group of statisticians at a local college has asked you to create a set of functionsthat compute the median and mode of
skelet666 [1.2K]

Answer:

  1. def median(l):
  2.    if(len(l) == 0):
  3.       return 0
  4.    else:
  5.        l.sort()
  6.        if(len(l)%2 == 0):
  7.            index = int(len(l)/2)
  8.            mid = (l[index-1] + l[index]) / 2
  9.        else:
  10.            mid = l[len(l)//2]  
  11.        return mid  
  12. def mode(l):
  13.    if(len(l)==0):
  14.        return 0
  15.    mode = max(set(l), key=l.count)
  16.    return mode  
  17. def mean(l):
  18.    if(len(l)==0):
  19.        return 0
  20.    sum = 0
  21.    for x in l:
  22.        sum += x
  23.    mean = sum / len(l)
  24.    return mean
  25. lst = [5, 7, 10, 11, 12, 12, 13, 15, 25, 30, 45, 61]
  26. print(mean(lst))
  27. print(median(lst))
  28. print(mode(lst))

Explanation:

Firstly, we create a median function (Line 1). This function will check if the the length of list is zero and also if it is an even number. If the length is zero (empty list), it return zero (Line 2-3). If it is an even number, it will calculate the median by summing up two middle index values and divide them by two (Line 6-8). Or if the length is an odd, it will simply take the middle index value and return it as output (Line 9-10).

In mode function, after checking the length of list, we use the max function to estimate the maximum count of the item in list (Line 17) and use it as mode.

In mean function,  after checking the length of list,  we create a sum variable and then use a loop to add the item of list to sum (Line 23-25). After the loop, divide sum by the length of list to get the mean (Line 26).

In the main program, we test the three functions using a sample list and we shall get

20.5

12.5

12

3 0
3 years ago
True or false? if i were to hook up an ac voltage source to a resistor, the voltage drop across the resistor would be in phase w
hodyreva [135]

Answer: True

Explanation:

4 0
2 years ago
Other questions:
  • . A storm sewer is carrying snow melt containing 1.200 g/L of sodium chloride into a small stream. The stream has a naturally oc
    8·1 answer
  • The Emergency Stop Button icon on the Inputs toolbar can be used to press or release the Emergency Stop button on the CNC machin
    10·1 answer
  • Determine the average and rms values for the function, y(t)=25+10sino it over the time periods (a) 0 to 0.1 sec and (b) 0 to 1/3
    9·1 answer
  • Two satellites A and B are orbiting the earth around the equator, E, at different altitudes on a circular path of 2400km and 300
    8·1 answer
  • Barry wants to convert mechanical energy into electric energy. What can he use?
    5·2 answers
  • Which of the following is part of the highway
    11·2 answers
  • Can someone please help me with this. Thank you. Ill mark you as brainly.
    11·1 answer
  • Please answer i dont understand and dont know the answer​
    14·1 answer
  • There are three homes being built, each with an identical deck on the back. Each deck is comprised of two separate areas. One ar
    7·1 answer
  • Question 6
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!