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
ICE Princess25 [194]
3 years ago
14

Write a program that uses a custom function to return the cost of purchasing an item, possibly in multiple quantities. The item

might be subject to 7% sales tax. The main function should prompt the user to enter the quantity, unit price, and taxable data. The main function should call the custom function with these three inputs as arguments and print the cost of the purchase in currency format.
Computers and Technology
1 answer:
alexandr402 [8]3 years ago
3 0

Answer:

def cost(quantity, unit_price, taxable):

   if taxable == "Yes":

       total = (quantity * unit_price) + (quantity * unit_price * 0.07)

   elif taxable == "No":

       total = quantity * unit_price

   return total

q = int(input("Enter the quantity: "))

p = float(input("Enter the unit price: "))

t = input("Is %7 tax applicable? (Yes/No): ")

print(str("$" + str(cost(q, p, t))))

Explanation:

- Create a function called cost that takes three parameters, quantity, unit price, and taxable

- If the tax is applicable, calculate the total with tax. Otherwise, do not add the tax.

- Return the total

- Ask the user for the inputs

- Call the function with given inputs and print the result

You might be interested in
The Account class contains a definition for a simple bank account class with methods to withdraw, deposit, get the balance and a
melamori03 [73]

Answer:

I've updated the Account class as per the instructions. The instructions mention "the constructor for this class creates a random account number" although I didn't find where that was. As a result, I created a simple method to generates the account number (located at the bottom of the class). Be sure you understand the changes (highlighted in yellow) and feel free to ask follow-up questions:

Explanation:

//*******************************************************

// Account.java

//

// A bank account class with methods to deposit to, withdraw from,

// change the name on, and get a String representation

// of the account.

//*******************************************************

import java.util.Random;   // Used for Random # generator

public class Account

{

      private double balance;

  private String name;

     private long acctNum;

      //----------------------------------------------

 //Constructor -- initializes balance, owner, and account number

  //----------------------------------------------

 public Account(double initBal, String owner, long number)

{

        balance = initBal;

               name = owner;

            acctNum = number;

}

// !!!!!! New Constructor !!!!!!

public Account(double initBal, String owner)

     {

        balance = initBal;

               name = owner;

            acctNum = generateAccountNumber();

       }

  // !!!!!! New Constructor !!!!!!

 public Account(String owner)

     {

        balance = 0;

             name = owner;

            acctNum = generateAccountNumber();

       }

   //----------------------------------------------

 // Checks to see if balance is sufficient for withdrawal.

// If so, decrements balance by amount; if not, prints message.

  //----------------------------------------------

 public void withdraw(double amount)

      {

        if (balance >= amount)

                balance -= amount;

               else

                     System.out.println("Insufficient funds");

}

 // !!!!!! New withdraw() method !!!!!!

   public void withdraw(double amount, double fee)

  {

        double amountWithFee = amount + fee;

               if (balance >= amountWithFee)

                 balance -= amountWithFee;

        else

                     System.out.println("Insufficient funds");

}

   //----------------------------------------------

 // Adds deposit amount to balance.

       //----------------------------------------------

 public void deposit(double amount)

       {

        balance += amount;

       }

  //----------------------------------------------

 // Returns balance.

      //----------------------------------------------

 public double getBalance()

       {

        return balance;

  }

    //----------------------------------------------

 // Returns a string containing the name, account number, and balance.

    //----------------------------------------------

 public String toString()

 {

        return "Name:" + name +

          "\nAccount Number: " + acctNum +

         "\nBalance: " + balance;

 }

 // !!!! NEW PRIVATE HELPER METHOD TO GENERATE ACCOUNT NUMBERS !!!!!

//-------------------------------------------------------

// Returns a random account number between 10000 - 99999

 //--------------------------------------------------------

       private long generateAccountNumber()

     {

        Random r = new Random();        // Seed the random number genertor with the system time

         return 10000 + r.nextInt(89999);        // .nextInt(89999) will return a value between 0 and 89999)

      }

}

8 0
4 years ago
IN YOUR OWN WORDS, create a new thread and compare and contrast paraphrasing, summarizing, and quoting and how to do each succes
choli [55]

Answer:

Such three ways to include the work of other writers in your own writing differ depending on whether you are close to the source.

Explanation:

Quotations must be the same as the original, using a narrow source segment. We must be word for word on the source document and the original author must be credited.

Paraphrasing means putting your own words into a line from the source material. The original source should also be assigned a paraphrase. Paraphrased material usually is shorter than the original one, which takes and slightly condenses a somewhat broader part of the source.

In summary, you have to put the main idea(s), including only the main point(s), in your own words. Again, summarized ideas must be attributed to the source. Summaries are much shorter than the original and give a broad overview of the source documents.

8 0
4 years ago
If your vehicle has fuel injection and the engine is cold,
olga nikolaevna [1]
D. Press the accelerator to the floor once and release it.
6 0
3 years ago
Deb needs to add borders on the cells and around the table she has inserted into her Word document.
slavikrds [6]

Answer:

Design tab

Explanation:

  1. Select the call or table that you will like to use
  2. Then select the <em>design tab</em>
  3. In the group <em>page background</em> select <em>Page Borders</em>
  4. There you will have multiple choses for where you want your border
  5. You can even customize your border by pressing <em>Custom Border </em>at the bottom of the list for <em>Page Borders</em>
4 0
3 years ago
Read 2 more answers
What technology made it possible for computers to become small enough to fit on a person's desk (and later in a pocket)?
ira [324]

Answer: Silicon chips

Explanation:

Silicon chips are the integrated circuit(IC) devices that are used in computing systems and devices for processing.They are made with silicon as the main element as it is available in abundant amount at low cost. It has the property of conduction as well insulation accordingly.

  • Gathering several silicon chips togather to make a unit of processor is the prime function.It is the component that is tending to make the computing system to size down generation by generation.
  • Transistors are made for the devices that contain the silicon chips.If the size of transistor is decreased or the number of chips placed in transistor is decreased then the size of device also decreases.This is the major factor due to which size of technology is decreasing with the same processing.
8 0
3 years ago
Other questions:
  • Jason is a computer hardware engineer. His work involves assembling computers. What will Jason need to assemble a microcomputer
    11·2 answers
  • In a newspaper advertisement for a hybrid car, which of these presentation methods would be most effective
    6·2 answers
  • How can a Word user insert a page break into a document to isolate a table on a new page?
    13·2 answers
  • How many cells are included in the range A1:B3
    10·1 answer
  • A computer that supports LoJack technology must have two main components installed. It needs an Application Agent (residing in t
    13·1 answer
  • Which two components are configured via software in order for a PC to participate in a network environment
    5·1 answer
  • . 。 • ゚ 。 .
    10·2 answers
  • Does anyone know what this logo is??
    11·2 answers
  • Lists Five Examples of simple statement<br>​
    5·2 answers
  • A ____ transmits all data received to all network devices connected to it, regardless of which device the data is being sent to.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!